Skip to content

Commit

Permalink
feature: initial version if no tags are created
Browse files Browse the repository at this point in the history
  • Loading branch information
sagebind committed Jan 12, 2018
1 parent 568f425 commit 72eb9e4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ versioning {

Below are all the available settings and what they do.

| Name | Default value | Description |
| ----------- | ------------- | ----------- |
| tagPrefix | `null` | A prefix that tags must start with in order to be considered a version tag. The prefix is removed from the final version string. |
| excludeTags | `null` | A regular expression for tags that should be ignored. |
| dirtyMark | `true` | Whether a `-dirty` suffix should be added to the version string if the Git working directory is dirty. |
| Name | Default value | Description |
| -------------- | ------------- | ----------- |
| initialVersion | `"0.0.0"` | An initial version number to use if no tags are available. Can also be overridden by setting `version` manually. |
| tagPrefix | `null` | A prefix that tags must start with in order to be considered a version tag. The prefix is removed from the final version string. |
| excludeTags | `null` | A regular expression for tags that should be ignored. |
| dirtyMark | `true` | Whether a `-dirty` suffix should be added to the version string if the Git working directory is dirty. |

### Automatic publishing
If you are using Travis, the following configuration works quite nicely:
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/widen/versioning/Settings.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
package com.widen.versioning;

public class Settings {
/**
* An initial version number to use if no tags are available.
*/
public String initialVersion = "0.0.0";

/**
* A prefix that tags must start with in order to be considered a version tag.
*/
public String tagPrefix;

/**
* A regular expression for tags that should be ignored.
*/
public String excludeTags;

/**
* Whether a `-dirty` suffix should be added to the version string if the Git working directory is dirty.
*/
public boolean dirtyMark = true;
}
3 changes: 3 additions & 0 deletions src/main/java/com/widen/versioning/VersioningPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public void apply(final Project project) {
if (version != null) {
p.setVersion(version);
}
else if ("unspecified".equals(p.getVersion())) {
p.setVersion(settings.initialVersion);
}
});
}
}

0 comments on commit 72eb9e4

Please sign in to comment.