Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schreiber2015-04-16 09:03:48 -0400
committerGerrit Code Review @ Eclipse.org2015-04-20 07:17:14 -0400
commitbfc69954d480b444ef4a93fe4ff68bbf99612caf (patch)
tree04bff9b9dffdfac0b33eba685a50e41e14bdb7a7
parentd0c7a30fc076952e9a5d8d71803a6d863dbed308 (diff)
downloadorg.eclipse.tycho-bfc69954d480b444ef4a93fe4ff68bbf99612caf.tar.gz
org.eclipse.tycho-bfc69954d480b444ef4a93fe4ff68bbf99612caf.tar.xz
org.eclipse.tycho-bfc69954d480b444ef4a93fe4ff68bbf99612caf.zip
464649 Check maven and OSGI version for snapshot or release decision
_If either the maven version string ends with "SNAPSHOT" or the OSGI version is ending with ".qualifier", the project is considered to be a snapshot project and the version strings are checked as such. _Adding an appropriate error message for wrong maven snapshot version strings _Adding tests for the different scenarios Bug: 464649 Change-Id: Id1dc9e68fd37b6a2aaf12603b5fedfd2c2a44356 Signed-off-by: Martin Schreiber <m.schreiber@bachmann.info>
-rw-r--r--tycho-packaging-plugin/src/main/java/org/eclipse/tycho/buildversion/ValidateVersionMojo.java6
-rw-r--r--tycho-packaging-plugin/src/test/java/org/eclipse/tycho/buildnumber/test/ValidateVersionTest.java29
2 files changed, 28 insertions, 7 deletions
diff --git a/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/buildversion/ValidateVersionMojo.java b/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/buildversion/ValidateVersionMojo.java
index c993e8956..dd29eaa88 100644
--- a/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/buildversion/ValidateVersionMojo.java
+++ b/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/buildversion/ValidateVersionMojo.java
@@ -11,6 +11,7 @@
*******************************************************************************/
package org.eclipse.tycho.buildversion;
+import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
@@ -44,7 +45,7 @@ public class ValidateVersionMojo extends AbstractVersionMojo {
return;
}
- if (project.getArtifact().isSnapshot()) {
+ if (project.getArtifact().isSnapshot() || osgiVersion.endsWith(VersioningHelper.QUALIFIER)) {
validateSnapshotVersion(mavenVersion, osgiVersion);
} else {
validateReleaseVersion(mavenVersion, osgiVersion);
@@ -77,6 +78,9 @@ public class ValidateVersionMojo extends AbstractVersionMojo {
}
public void validateSnapshotVersion(String mavenVersion, String osgiVersion) throws MojoExecutionException {
+ if (!mavenVersion.endsWith(Artifact.SNAPSHOT_VERSION)) {
+ fail("Maven version " + mavenVersion + " must have -SNAPSHOT qualifier for SNAPSHOT builds");
+ }
if (!osgiVersion.endsWith(VersioningHelper.QUALIFIER)) {
fail("OSGi version " + osgiVersion + " must have .qualifier qualifier for SNAPSHOT builds");
} else {
diff --git a/tycho-packaging-plugin/src/test/java/org/eclipse/tycho/buildnumber/test/ValidateVersionTest.java b/tycho-packaging-plugin/src/test/java/org/eclipse/tycho/buildnumber/test/ValidateVersionTest.java
index 0597041b6..f95936581 100644
--- a/tycho-packaging-plugin/src/test/java/org/eclipse/tycho/buildnumber/test/ValidateVersionTest.java
+++ b/tycho-packaging-plugin/src/test/java/org/eclipse/tycho/buildnumber/test/ValidateVersionTest.java
@@ -14,6 +14,8 @@ import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.testing.SilentLog;
import org.eclipse.tycho.buildversion.ValidateVersionMojo;
import org.eclipse.tycho.testing.AbstractTychoMojoTestCase;
+import org.junit.Assert;
+import org.junit.Test;
public class ValidateVersionTest extends AbstractTychoMojoTestCase {
@@ -27,21 +29,36 @@ public class ValidateVersionTest extends AbstractTychoMojoTestCase {
mojo.setLog(new SilentLog());
}
- public void testValidateVersion() throws MojoExecutionException {
-
+ @Test
+ public void testValidateVersionWithVersionMatches() throws MojoExecutionException {
mojo.validateReleaseVersion("1.2.3", "1.2.3");
mojo.validateSnapshotVersion("1.2.3-SNAPSHOT", "1.2.3.qualifier");
+ }
+
+ @Test
+ public void testValidateSnapshotVersionWithInvalidVersions() {
+ assertInvalidSnapshotVersion("1.2.3-SNAPSHOT", "1.2.3",
+ "OSGi version 1.2.3 must have .qualifier qualifier for SNAPSHOT builds");
+
+ assertInvalidSnapshotVersion("1.2.3", "1.2.3.qualifier",
+ "Maven version 1.2.3 must have -SNAPSHOT qualifier for SNAPSHOT builds");
+
+ assertInvalidSnapshotVersion("1.2.3-SNAPSHOT", "1.2.0.qualifier",
+ "Unqualified OSGi version 1.2.0.qualifier must match unqualified Maven version 1.2.3-SNAPSHOT for SNAPSHOT builds");
+
+ assertInvalidSnapshotVersion("1.2.3.qualifier", "1.2.3.qualifier",
+ "Maven version 1.2.3.qualifier must have -SNAPSHOT qualifier for SNAPSHOT builds");
- assertInvalidSnapshotVersion("1.2.3-SNAPSHOT", "1.2.3");
- assertInvalidSnapshotVersion("1.2.3-SNAPSHOT", "1.2.0.qualifier");
+ assertInvalidSnapshotVersion("1.2.3-SNAPSHOT", "1.2.3.SNAPSHOT",
+ "OSGi version 1.2.3.SNAPSHOT must have .qualifier qualifier for SNAPSHOT builds");
}
- private void assertInvalidSnapshotVersion(String maven, String osgi) {
+ private void assertInvalidSnapshotVersion(String maven, String osgi, String expectedMessage) {
try {
mojo.validateSnapshotVersion(maven, osgi);
fail();
} catch (MojoExecutionException e) {
- // expected
+ Assert.assertEquals(expectedMessage, e.getMessage());
}
}
}

Back to the top