* By default, the plugin will automatically find a suitable build number.
- * It will start at version 0 and increment this with each release.
+ * It will start at 0 and increment this with each release.
*
*
- * This can be specified using a command line parameter ("-DbuildNumber=2")
- * or in this plugin's configuration.
+ * This can be specified using a command line parameter (e.g.
+ * -DbuildNumber=2) or in this plugin's configuration.
*
+ *
+ * null vs. "": if you do not define the build number it
+ * is treated as null and the plugin will start at 0. If you
+ * pass an empty string both the build number and the delimiter that
+ * precedes it will be omitted. To define an empty string on the CLI use
+ * -DbuildNumber=''. For the same effect in the POM you can
+ * use <buildNumber>""</buildNumber> as Maven does
+ * not support empty strings for configuration properties. The plugin will
+ * convert this accordingly.
+ *
*/
+ // Maven has historically never supported empty strings in XML plugin configuration (see
+ // http://mail-archives.apache.org/mod_mbox/maven-users/200708.mbox/%3C5a2cf1f60708090246l216f156esf46cc1e968b37ccd@mail.gmail.com%3E
+ // from 2007). Hence, if a project defines the property here will be null. However,
+ // Maven does support -DbuildNumber='' on the CLI.
@Parameter(property = "buildNumber")
- protected Long buildNumber;
+ protected String buildNumber;
+ public void setBuildNumber(String buildNumber) {
+ if ("\"\"".equals(buildNumber)) {
+ this.buildNumber = StringUtils.EMPTY;
+ } else {
+ this.buildNumber = buildNumber;
+ }
+ }
/**
*
@@ -252,5 +275,4 @@ protected static String getRemoteUrlOrNullIfNoneSet(Scm originalScm, Scm actualS
}
return GitHelper.scmUrlToRemote(remote);
}
-
}
diff --git a/src/main/java/com/github/danielflower/mavenplugins/release/Reactor.java b/src/main/java/com/github/danielflower/mavenplugins/release/Reactor.java
index b1422036..a9926204 100644
--- a/src/main/java/com/github/danielflower/mavenplugins/release/Reactor.java
+++ b/src/main/java/com/github/danielflower/mavenplugins/release/Reactor.java
@@ -1,5 +1,6 @@
package com.github.danielflower.mavenplugins.release;
+import org.apache.commons.lang3.StringUtils;
import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
@@ -28,7 +29,7 @@ public List getModulesInBuildOrder() {
return modulesInBuildOrder;
}
- public static Reactor fromProjects(Log log, LocalGitRepo gitRepo, MavenProject rootProject, List projects, Long buildNumber, List modulesToForceRelease, NoChangesAction actionWhenNoChangesDetected, ResolverWrapper resolverWrapper, VersionNamer versionNamer) throws ValidationException, GitAPIException, MojoExecutionException {
+ public static Reactor fromProjects(Log log, LocalGitRepo gitRepo, MavenProject rootProject, List projects, String buildNumber, List modulesToForceRelease, NoChangesAction actionWhenNoChangesDetected, ResolverWrapper resolverWrapper, VersionNamer versionNamer) throws ValidationException, GitAPIException, MojoExecutionException {
DiffDetector detector = new TreeWalkingDiffDetector(gitRepo.git.getRepository());
List modules = new ArrayList();
@@ -42,14 +43,14 @@ public static Reactor fromProjects(Log log, LocalGitRepo gitRepo, MavenProject r
List previousTagsForThisModule = annotatedTagFinder.tagsForVersion(gitRepo.git, artifactId, versionWithoutBuildNumber);
- Collection previousBuildNumbers = new ArrayList();
+ Collection previousBuildNumbers = new ArrayList<>();
if (previousTagsForThisModule != null) {
for (AnnotatedTag previousTag : previousTagsForThisModule) {
previousBuildNumbers.add(previousTag.buildNumber());
}
}
- Collection remoteBuildNumbers = getRemoteBuildNumbers(gitRepo, artifactId, versionWithoutBuildNumber, versionNamer);
+ Collection remoteBuildNumbers = getRemoteBuildNumbers(gitRepo, artifactId, versionWithoutBuildNumber, versionNamer);
previousBuildNumbers.addAll(remoteBuildNumbers);
VersionName newVersion = versionNamer.name(project.getVersion(), buildNumber, previousBuildNumbers);
@@ -145,14 +146,14 @@ private static boolean hasSameMavenGAByDependencyLocation(ReleasableModule modul
return modelId[0].equals(module.getGroupId()) && modelId[1].equals(module.getArtifactId());
}
- private static Collection getRemoteBuildNumbers(LocalGitRepo gitRepo, String artifactId, String versionWithoutBuildNumber, VersionNamer versionNamer) throws GitAPIException {
+ private static Collection getRemoteBuildNumbers(LocalGitRepo gitRepo, String artifactId, String versionWithoutBuildNumber, VersionNamer versionNamer) throws GitAPIException {
Collection remoteTagRefs = gitRepo.allTags();
- Collection remoteBuildNumbers = new ArrayList();
+ Collection remoteBuildNumbers = new ArrayList<>();
String tagWithoutBuildNumber = artifactId + "-" + versionWithoutBuildNumber;
AnnotatedTagFinder annotatedTagFinder = new AnnotatedTagFinder(versionNamer);
for (Ref remoteTagRef : remoteTagRefs) {
String remoteTagName = remoteTagRef.getName();
- Long buildNumber = annotatedTagFinder.buildNumberOf(tagWithoutBuildNumber, remoteTagName);
+ String buildNumber = annotatedTagFinder.buildNumberOf(tagWithoutBuildNumber, remoteTagName);
if (buildNumber != null) {
remoteBuildNumbers.add(buildNumber);
}
@@ -190,20 +191,25 @@ static AnnotatedTag hasChangedSinceLastRelease(List previousTagsFo
try {
if (previousTagsForThisModule.size() == 0) return null;
boolean hasChanged = detector.hasChangedSince(relativePathToModule, project.getModel().getModules(), previousTagsForThisModule);
- return hasChanged ? null : tagWithHighestBuildNumber(previousTagsForThisModule);
+ return hasChanged ? null : findTagWithHighestBuildNumber(previousTagsForThisModule);
} catch (Exception e) {
throw new MojoExecutionException("Error while detecting whether or not " + project.getArtifactId() + " has changed since the last release", e);
}
}
- private static AnnotatedTag tagWithHighestBuildNumber(List tags) {
- AnnotatedTag cur = null;
+ // Ignores any tags with non-numeric build numbers and finds the one with the largest build number among the others.
+ // The tags are guaranteed to be for the same /business version/ i.e. it's likely a small list.
+ private static AnnotatedTag findTagWithHighestBuildNumber(List tags) {
+ AnnotatedTag tagWithHighestBuildNumber = null;
for (AnnotatedTag tag : tags) {
- if (cur == null || tag.buildNumber() > cur.buildNumber()) {
- cur = tag;
+ if(StringUtils.isNumeric(tag.buildNumber())) {
+ if (tagWithHighestBuildNumber == null ||
+ Long.parseLong(tag.buildNumber()) > Long.parseLong(tagWithHighestBuildNumber.buildNumber())) {
+ tagWithHighestBuildNumber = tag;
+ }
}
}
- return cur;
+ return tagWithHighestBuildNumber;
}
public ReleasableModule findByLabel(String label) {
diff --git a/src/main/java/com/github/danielflower/mavenplugins/release/ReleasableModule.java b/src/main/java/com/github/danielflower/mavenplugins/release/ReleasableModule.java
index d76f0cd5..a70fbe2c 100644
--- a/src/main/java/com/github/danielflower/mavenplugins/release/ReleasableModule.java
+++ b/src/main/java/com/github/danielflower/mavenplugins/release/ReleasableModule.java
@@ -44,7 +44,7 @@ public String getVersion() {
return version.businessVersion();
}
- public long getBuildNumber() {
+ public String getBuildNumber() {
return version.buildNumber();
}
diff --git a/src/main/java/com/github/danielflower/mavenplugins/release/VersionName.java b/src/main/java/com/github/danielflower/mavenplugins/release/VersionName.java
index f6d13cad..01bdda80 100644
--- a/src/main/java/com/github/danielflower/mavenplugins/release/VersionName.java
+++ b/src/main/java/com/github/danielflower/mavenplugins/release/VersionName.java
@@ -1,12 +1,15 @@
package com.github.danielflower.mavenplugins.release;
+import org.apache.commons.lang3.StringUtils;
+
public class VersionName {
private final String version;
- private final long buildNumber;
+ private final String buildNumber;
private final String developmentVersion;
private final String delimiter;
+ private final String releaseVersion;
- public VersionName(String developmentVersion, String version, long buildNumber, String delimiter) {
+ public VersionName(String developmentVersion, String version, String buildNumber, String delimiter) {
Guard.notBlank("developmentVersion", developmentVersion);
Guard.notBlank("version", version);
Guard.notNull("buildNumber", buildNumber);
@@ -14,20 +17,21 @@ public VersionName(String developmentVersion, String version, long buildNumber,
this.buildNumber = buildNumber;
this.developmentVersion = developmentVersion;
this.delimiter = delimiter;
+ this.releaseVersion = buildNumber.length() > 0 ? version + delimiter + buildNumber : version;
}
- public VersionName(String developmentVersion, String version, long buildNumber) {
+ public VersionName(String developmentVersion, String version, String buildNumber) {
this(developmentVersion, version, buildNumber, ".");
}
/**
- * For example, "1.0" if the development version is "1.0-SNAPSHOT"
+ * For example, "1.0" if the development version is "1.0-SNAPSHOT".
*/
public String businessVersion() {
return version;
}
- public long buildNumber() {
+ public String buildNumber() {
return buildNumber;
}
@@ -42,6 +46,6 @@ public String developmentVersion() {
* The business version with the build number appended, e.g. "1.0.1"
*/
public String releaseVersion() {
- return version + delimiter + buildNumber;
+ return releaseVersion;
}
}
diff --git a/src/main/java/com/github/danielflower/mavenplugins/release/VersionNamer.java b/src/main/java/com/github/danielflower/mavenplugins/release/VersionNamer.java
index 3c9d77ff..7763539a 100644
--- a/src/main/java/com/github/danielflower/mavenplugins/release/VersionNamer.java
+++ b/src/main/java/com/github/danielflower/mavenplugins/release/VersionNamer.java
@@ -1,5 +1,6 @@
package com.github.danielflower.mavenplugins.release;
+import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugins.annotations.Parameter;
import org.eclipse.jgit.lib.Repository;
@@ -33,35 +34,38 @@ public VersionNamer() {
this(".");
}
- public VersionName name(String pomVersion, Long buildNumber, Collection previousBuildNumbers) throws ValidationException {
-
+ public VersionName name(String pomVersion, String buildNumber, Collection previousBuildNumbers) throws ValidationException {
+ String effectiveBuildNumber = buildNumber;
if (buildNumber == null) {
- if (previousBuildNumbers.size() == 0) {
- buildNumber = 0L;
+ if (previousBuildNumbers == null || previousBuildNumbers.isEmpty()) {
+ effectiveBuildNumber = "0";
} else {
- buildNumber = nextBuildNumber(previousBuildNumbers);
+ effectiveBuildNumber = nextBuildNumber(previousBuildNumbers);
}
}
- VersionName versionName = new VersionName(pomVersion, pomVersion.replace("-SNAPSHOT", ""), buildNumber, this.delimiter);
+ VersionName versionName = new VersionName(pomVersion, pomVersion.replace("-SNAPSHOT", ""), effectiveBuildNumber, this.delimiter);
if (!Repository.isValidRefName("refs/tags/" + versionName.releaseVersion())) {
String summary = "Sorry, '" + versionName.releaseVersion() + "' is not a valid version.";
throw new ValidationException(summary, asList(
summary,
- "Version numbers are used in the Git tag, and so can only contain characters that are valid in git tags.",
+ "Version numbers are used in the Git tag, and so can only contain characters that are valid in Git tags.",
"Please see https://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html for tag naming rules."
));
}
return versionName;
}
- private static long nextBuildNumber(Collection previousBuildNumbers) {
+ // Increments the largest previous build number. Skips over any non-numeric previous build numbers.
+ private static String nextBuildNumber(Collection previousBuildNumbers) {
long max = 0;
- for (Long buildNumber : previousBuildNumbers) {
- max = Math.max(max, buildNumber);
+ for (String buildNumber : previousBuildNumbers) {
+ if (StringUtils.isNumeric(buildNumber)) {
+ max = Math.max(max, Long.parseLong(buildNumber));
+ }
}
- return max + 1;
+ return String.valueOf(max + 1);
}
String getDelimiter() {
diff --git a/src/site/markdown/changelog.md b/src/site/markdown/changelog.md
index 408c267a..b0d59c26 100644
--- a/src/site/markdown/changelog.md
+++ b/src/site/markdown/changelog.md
@@ -1,6 +1,10 @@
Changelog
---------
+### 3.3.0
+
+* Allow build numbers to be arbitrary strings or null, #75
+
### 3.2.0
* Added support for processing version properties e.g. `${foo.version}`
diff --git a/src/test/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinderTest.java b/src/test/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinderTest.java
index ff93802a..dc1e1a1e 100644
--- a/src/test/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinderTest.java
+++ b/src/test/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinderTest.java
@@ -22,22 +22,22 @@ public class AnnotatedTagFinderTest {
public void findsTheLatestCommitWhereThereHaveBeenNoBranches() throws Exception {
TestProject project = TestProject.independentVersionsProject();
- AnnotatedTag tag1 = saveFileInModule(project, "console-app", "1.2", 3);
- AnnotatedTag tag2 = saveFileInModule(project, "core-utils", "2", 0);
- AnnotatedTag tag3 = saveFileInModule(project, "console-app", "1.2", 4);
+ AnnotatedTag tag1 = saveFileInModule(project, "console-app", "1.2", "3");
+ AnnotatedTag tag2 = saveFileInModule(project, "core-utils", "2", "0");
+ AnnotatedTag tag3 = saveFileInModule(project, "console-app", "1.2", "4");
assertThat(annotatedTagFinder.tagsForVersion(project.local, "console-app", "1.3"), hasSize(0));
assertThat(annotatedTagFinder.tagsForVersion(project.local, "console-app", "1.2"), containsInAnyOrder(tag1, tag3));
assertThat(annotatedTagFinder.tagsForVersion(project.local, "core-utils", "2"), contains(tag2));
}
- static AnnotatedTag saveFileInModule(TestProject project, String moduleName, String version, long buildNumber) throws IOException, GitAPIException {
+ static AnnotatedTag saveFileInModule(TestProject project, String moduleName, String version, String buildNumber) throws IOException, GitAPIException {
project.commitRandomFile(moduleName);
String nameForTag = moduleName.equals(".") ? "root" : moduleName;
return tagLocalRepo(project, nameForTag + "-" + version + versionNamer.getDelimiter() + buildNumber, version, buildNumber);
}
- private static AnnotatedTag tagLocalRepo(TestProject project, String tagName, String version, long buildNumber) throws GitAPIException {
+ private static AnnotatedTag tagLocalRepo(TestProject project, String tagName, String version, String buildNumber) throws GitAPIException {
AnnotatedTag tag = AnnotatedTag.create(tagName, version, buildNumber);
tag.saveAtHEAD(project.local);
return tag;
@@ -54,10 +54,10 @@ public void canRecogniseTagsThatArePotentiallyOfTheSameVersion() {
@Test
public void returnsMultipleTagsOnASingleCommit() throws IOException, GitAPIException, MojoExecutionException {
TestProject project = TestProject.independentVersionsProject();
- saveFileInModule(project, "console-app", "1.2", 1);
- AnnotatedTag tag1 = tagLocalRepo(project, "console-app-1.1.1.1", "1.1.1", 1);
- AnnotatedTag tag3 = tagLocalRepo(project, "console-app-1.1.1.3", "1.1.1", 3);
- AnnotatedTag tag2 = tagLocalRepo(project, "console-app-1.1.1.2", "1.1.1", 2);
+ saveFileInModule(project, "console-app", "1.2", "1");
+ AnnotatedTag tag1 = tagLocalRepo(project, "console-app-1.1.1.1", "1.1.1", "1");
+ AnnotatedTag tag3 = tagLocalRepo(project, "console-app-1.1.1.3", "1.1.1", "3");
+ AnnotatedTag tag2 = tagLocalRepo(project, "console-app-1.1.1.2", "1.1.1", "2");
List annotatedTags = annotatedTagFinder.tagsForVersion(project.local, "console-app", "1.1.1");
assertThat(annotatedTags, containsInAnyOrder(tag1, tag2, tag3));
}
@@ -65,7 +65,7 @@ public void returnsMultipleTagsOnASingleCommit() throws IOException, GitAPIExcep
@Test
public void versionNamerCaresNotForOrderOfTags() throws ValidationException {
VersionNamer versionNamer = new VersionNamer();
- VersionName name = versionNamer.name("1.1.1", null, asList(1L, 3L, 2L));
+ VersionName name = versionNamer.name("1.1.1", null, asList("1", "3", "2"));
assertThat(name.releaseVersion(), equalTo("1.1.1.4"));
}
@@ -76,15 +76,15 @@ public void respectDelimiterWhenExtractingBuildNumber() {
// This should actually be implemented with a parameterized JUnit test but since this class isn't set up for
// that yet we'll use our own data-driven harness.
Arrays.asList(new Object[][]{
+ new Object[]{"libs-1.0.0", refPrefix + "libs-1.0.0-1", "1"}, // proper match with expected delimiter
+ new Object[]{"libs-1.0.0", refPrefix + "libs-1.0.0-A", "A"}, // non-numeric build number
new Object[]{"libs-1.0.0", refPrefix + "foo-1.0.0-1", null}, // artifact ID does not match -> expect null
- new Object[]{"libs-1.0.0", refPrefix + "libs-1.0.0-1", 1L}, // proper match with expected delimiter
new Object[]{"libs-1.0.0", refPrefix + "libs-1.0.0.1", null}, // no delimiter match
new Object[]{"libs-1.0.0", refPrefix + "libs-1.0.0@1", null}, // no delimiter match
- new Object[]{"libs-1.0.0", refPrefix + "libs-1.0.0-A", null} // format exception on build number
})
.forEach(dataSet -> {
final Object expectedBuildNumber = dataSet[2];
- final Long buildNumber = tagFinder.buildNumberOf(dataSet[0].toString(), dataSet[1].toString());
+ final String buildNumber = tagFinder.buildNumberOf(dataSet[0].toString(), dataSet[1].toString());
assertThat(buildNumber, is(expectedBuildNumber));
});
}
diff --git a/src/test/java/com/github/danielflower/mavenplugins/release/AnnotatedTagTest.java b/src/test/java/com/github/danielflower/mavenplugins/release/AnnotatedTagTest.java
index 1abce6fa..7b68b8df 100644
--- a/src/test/java/com/github/danielflower/mavenplugins/release/AnnotatedTagTest.java
+++ b/src/test/java/com/github/danielflower/mavenplugins/release/AnnotatedTagTest.java
@@ -12,25 +12,25 @@
public class AnnotatedTagTest {
@Test
- public void gettersReturnValuesPassedIn() throws Exception {
+ public void gettersReturnValuesPassedIn() {
// yep, testing getters... but only because it isn't a simple POJO
- AnnotatedTag tag = AnnotatedTag.create("my-name", "the-version", 2134);
+ AnnotatedTag tag = AnnotatedTag.create("my-name", "the-version", "2134");
assertThat(tag.name(), equalTo("my-name"));
assertThat(tag.version(), equalTo("the-version"));
- assertThat(tag.buildNumber(), equalTo(2134L));
+ assertThat(tag.buildNumber(), equalTo("2134"));
}
@Test
public void aTagCanBeCreatedFromAGitTag() throws GitAPIException, IOException {
TestProject project = TestProject.singleModuleProject();
- AnnotatedTag tag = AnnotatedTag.create("my-name", "the-version", 2134);
+ AnnotatedTag tag = AnnotatedTag.create("my-name", "the-version", "2134");
tag.saveAtHEAD(project.local);
Ref ref = project.local.tagList().call().get(0);
AnnotatedTag inflatedTag = AnnotatedTag.fromRef(project.local.getRepository(), ref);
assertThat(inflatedTag.name(), equalTo("my-name"));
assertThat(inflatedTag.version(), equalTo("the-version"));
- assertThat(inflatedTag.buildNumber(), equalTo(2134L));
+ assertThat(inflatedTag.buildNumber(), equalTo("2134"));
}
@Test
@@ -42,7 +42,7 @@ public void ifATagIsSavedWithoutJsonThenTheVersionIsSetTo0Dot0() throws GitAPIEx
AnnotatedTag inflatedTag = AnnotatedTag.fromRef(project.local.getRepository(), ref);
assertThat(inflatedTag.name(), equalTo("my-name-1.0.2"));
assertThat(inflatedTag.version(), equalTo("0"));
- assertThat(inflatedTag.buildNumber(), equalTo(0L));
+ assertThat(inflatedTag.buildNumber(), equalTo("0"));
}
}
diff --git a/src/test/java/com/github/danielflower/mavenplugins/release/DiffDetectorTest.java b/src/test/java/com/github/danielflower/mavenplugins/release/DiffDetectorTest.java
index d465d357..1570c27e 100644
--- a/src/test/java/com/github/danielflower/mavenplugins/release/DiffDetectorTest.java
+++ b/src/test/java/com/github/danielflower/mavenplugins/release/DiffDetectorTest.java
@@ -18,9 +18,9 @@ public class DiffDetectorTest {
public void canDetectIfFilesHaveBeenChangedForAModuleSinceSomeSpecificTag() throws Exception {
TestProject project = TestProject.independentVersionsProject();
- AnnotatedTag tag1 = saveFileInModule(project, "console-app", "1.2", 3);
- AnnotatedTag tag2 = saveFileInModule(project, "core-utils", "2", 0);
- AnnotatedTag tag3 = saveFileInModule(project, "console-app", "1.2", 4);
+ AnnotatedTag tag1 = saveFileInModule(project, "console-app", "1.2", "3");
+ AnnotatedTag tag2 = saveFileInModule(project, "core-utils", "2", "0");
+ AnnotatedTag tag3 = saveFileInModule(project, "console-app", "1.2", "4");
DiffDetector detector = new TreeWalkingDiffDetector(project.local.getRepository());
@@ -32,12 +32,12 @@ public void canDetectIfFilesHaveBeenChangedForAModuleSinceSomeSpecificTag() thro
@Test
public void canDetectThingsInTheRoot() throws IOException, GitAPIException {
TestProject simple = TestProject.singleModuleProject();
- AnnotatedTag tag1 = saveFileInModule(simple, ".", "1.0", 1);
+ AnnotatedTag tag1 = saveFileInModule(simple, ".", "1.0", "1");
simple.commitRandomFile(".");
DiffDetector detector = new TreeWalkingDiffDetector(simple.local.getRepository());
assertThat(detector.hasChangedSince(".", noChildModules(), asList(tag1)), is(true));
- AnnotatedTag tag2 = saveFileInModule(simple, ".", "1.0", 2);
+ AnnotatedTag tag2 = saveFileInModule(simple, ".", "1.0", "2");
assertThat(detector.hasChangedSince(".", noChildModules(), asList(tag2)), is(false));
}
@@ -45,9 +45,9 @@ public void canDetectThingsInTheRoot() throws IOException, GitAPIException {
public void canDetectChangesAfterTheLastTag() throws IOException, GitAPIException {
TestProject project = TestProject.independentVersionsProject();
- saveFileInModule(project, "console-app", "1.2", 3);
- saveFileInModule(project, "core-utils", "2", 0);
- AnnotatedTag tag3 = saveFileInModule(project, "console-app", "1.2", 4);
+ saveFileInModule(project, "console-app", "1.2", "3");
+ saveFileInModule(project, "core-utils", "2", "0");
+ AnnotatedTag tag3 = saveFileInModule(project, "console-app", "1.2", "4");
project.commitRandomFile("console-app");
DiffDetector detector = new TreeWalkingDiffDetector(project.local.getRepository());
@@ -58,7 +58,7 @@ public void canDetectChangesAfterTheLastTag() throws IOException, GitAPIExceptio
public void canIgnoreChangesInModuleFolders() throws IOException, GitAPIException {
TestProject project = TestProject.nestedProject();
- AnnotatedTag tag1 = saveFileInModule(project, "server-modules", "1.0.2.4", 0);
+ AnnotatedTag tag1 = saveFileInModule(project, "server-modules", "1.0.2.4", "0");
project.commitRandomFile("server-modules/server-module-a");
DiffDetector detector = new TreeWalkingDiffDetector(project.local.getRepository());
@@ -70,7 +70,7 @@ public void canIgnoreChangesInModuleFolders() throws IOException, GitAPIExceptio
public void canDetectLocalChangesWithModuleFolders() throws IOException, GitAPIException {
TestProject project = TestProject.nestedProject();
- AnnotatedTag tag1 = saveFileInModule(project, "server-modules", "1.0.2.4", 0);
+ AnnotatedTag tag1 = saveFileInModule(project, "server-modules", "1.0.2.4", "0");
project.commitRandomFile("server-modules");
DiffDetector detector = new TreeWalkingDiffDetector(project.local.getRepository());
diff --git a/src/test/java/com/github/danielflower/mavenplugins/release/LocalGitRepoTest.java b/src/test/java/com/github/danielflower/mavenplugins/release/LocalGitRepoTest.java
index aa7ee251..e206fe4f 100644
--- a/src/test/java/com/github/danielflower/mavenplugins/release/LocalGitRepoTest.java
+++ b/src/test/java/com/github/danielflower/mavenplugins/release/LocalGitRepoTest.java
@@ -70,9 +70,9 @@ public void canHaveManyTags() throws GitAPIException {
}
private static List tags(String... tagNames) {
- List tags = new ArrayList();
+ List tags = new ArrayList<>();
for (String tagName : tagNames) {
- tags.add(AnnotatedTag.create(tagName, "1", 0));
+ tags.add(AnnotatedTag.create(tagName, "1", "0"));
}
return tags;
}
diff --git a/src/test/java/com/github/danielflower/mavenplugins/release/ReactorTest.java b/src/test/java/com/github/danielflower/mavenplugins/release/ReactorTest.java
index 0ba29111..bb2e83b0 100644
--- a/src/test/java/com/github/danielflower/mavenplugins/release/ReactorTest.java
+++ b/src/test/java/com/github/danielflower/mavenplugins/release/ReactorTest.java
@@ -49,8 +49,8 @@ public void ifNotFoundThenAUnresolvedSnapshotDependencyExceptionIsThrown() throw
@Test
public void returnsTheLatestTagIfThereAreChanges() throws MojoExecutionException {
- AnnotatedTag onePointNine = AnnotatedTag.create("whatever-1.1.9", "1.1", 9);
- AnnotatedTag onePointTen = AnnotatedTag.create("whatever-1.1.10", "1.1", 10);
+ AnnotatedTag onePointNine = AnnotatedTag.create("whatever-1.1.9", "1.1", "9");
+ AnnotatedTag onePointTen = AnnotatedTag.create("whatever-1.1.10", "1.1", "10");
assertThat(Reactor.hasChangedSinceLastRelease(asList(onePointNine, onePointTen), new NeverChanged(), new MavenProject(), "whatever"), is(onePointTen));
assertThat(Reactor.hasChangedSinceLastRelease(asList(onePointTen, onePointNine), new NeverChanged(), new MavenProject(), "whatever"), is(onePointTen));
}
diff --git a/src/test/java/com/github/danielflower/mavenplugins/release/ReleasableModuleTest.java b/src/test/java/com/github/danielflower/mavenplugins/release/ReleasableModuleTest.java
index 5f7b10b6..ccd44b2e 100644
--- a/src/test/java/com/github/danielflower/mavenplugins/release/ReleasableModuleTest.java
+++ b/src/test/java/com/github/danielflower/mavenplugins/release/ReleasableModuleTest.java
@@ -20,18 +20,18 @@ public void getsTheTagFromTheArtifactAndVersion() throws Exception {
}
@Test
- public void aReleaseableModuleCanBeCreatedFromAnUnreleasableOne() {
+ public void aReleasableModuleCanBeCreatedFromAnUnreleasableOne() {
MavenProject project = new MavenProject();
project.setArtifactId("some-arty");
project.setGroupId("some-group");
ReleasableModule first = new ReleasableModule(
- project, new VersionName("1.2.3-SNAPSHOT", "1.2.3", 12), "1.2.3.11", "somewhere"
+ project, new VersionName("1.2.3-SNAPSHOT", "1.2.3", "12"), "1.2.3.11", "somewhere"
);
assertThat(first.willBeReleased(), is(false));
ReleasableModule changed = first.createReleasableVersion();
assertThat(changed.getArtifactId(), equalTo("some-arty"));
- assertThat(changed.getBuildNumber(), equalTo(12L));
+ assertThat(changed.getBuildNumber(), equalTo("12"));
assertThat(changed.getGroupId(), equalTo("some-group"));
assertThat(changed.getNewVersion(), equalTo("1.2.3.12"));
assertThat(changed.getProject(), is(project));
diff --git a/src/test/java/com/github/danielflower/mavenplugins/release/VersionNameTest.java b/src/test/java/com/github/danielflower/mavenplugins/release/VersionNameTest.java
new file mode 100644
index 00000000..fb016b72
--- /dev/null
+++ b/src/test/java/com/github/danielflower/mavenplugins/release/VersionNameTest.java
@@ -0,0 +1,49 @@
+package com.github.danielflower.mavenplugins.release;
+
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.MatcherAssert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Parameterized.class)
+public class VersionNameTest {
+
+ @Parameter
+ public String version;
+
+ @Parameter(1)
+ public String buildNumber;
+
+ @Parameter(2)
+ public String expectedReleaseVersion;
+
+ @Parameters(name = "{0} {1} -> {2}")
+ public static Collection