diff --git a/tycho-its/projects/packaging.buildsimplequalifier/mavenPlugin/pom.xml b/tycho-its/projects/packaging.buildsimplequalifier/mavenPlugin/pom.xml
new file mode 100644
index 0000000000..e567d1f131
--- /dev/null
+++ b/tycho-its/projects/packaging.buildsimplequalifier/mavenPlugin/pom.xml
@@ -0,0 +1,31 @@
+
+
+ 4.0.0
+
+
+ packaging.buildtimestamp
+ packaging.buildtimestamp.parent
+ 1.0.0-SNAPSHOT
+
+
+ packaging.buildtimestamp
+ packaging.buildtimestamp.mavenplugin
+ 1.0.0-SNAPSHOT
+ jar
+
+
+ ${maven.build.timestamp}
+
+
+
+
+
+
+ src/main/resources
+ true
+
+
+
+
+
\ No newline at end of file
diff --git a/tycho-its/projects/packaging.buildsimplequalifier/mavenPlugin/src/main/resources/buildtimestamp.txt b/tycho-its/projects/packaging.buildsimplequalifier/mavenPlugin/src/main/resources/buildtimestamp.txt
new file mode 100644
index 0000000000..ee065e24d8
--- /dev/null
+++ b/tycho-its/projects/packaging.buildsimplequalifier/mavenPlugin/src/main/resources/buildtimestamp.txt
@@ -0,0 +1 @@
+${theBuildTimestamp}
\ No newline at end of file
diff --git a/tycho-its/projects/packaging.buildsimplequalifier/plugin01/META-INF/MANIFEST.MF b/tycho-its/projects/packaging.buildsimplequalifier/plugin01/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..66c91b2ff5
--- /dev/null
+++ b/tycho-its/projects/packaging.buildsimplequalifier/plugin01/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: packaging.buildtimestamp.plugin01;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-ClassPath: .
+Bundle-Name: packaging.buildtimestamp.plugin01
diff --git a/tycho-its/projects/packaging.buildsimplequalifier/plugin01/build.properties b/tycho-its/projects/packaging.buildsimplequalifier/plugin01/build.properties
new file mode 100644
index 0000000000..7594fab8d5
--- /dev/null
+++ b/tycho-its/projects/packaging.buildsimplequalifier/plugin01/build.properties
@@ -0,0 +1,2 @@
+bin.includes = META-INF/,\
+ .
diff --git a/tycho-its/projects/packaging.buildsimplequalifier/plugin01/pom.xml b/tycho-its/projects/packaging.buildsimplequalifier/plugin01/pom.xml
new file mode 100644
index 0000000000..881601724d
--- /dev/null
+++ b/tycho-its/projects/packaging.buildsimplequalifier/plugin01/pom.xml
@@ -0,0 +1,17 @@
+
+
+ 4.0.0
+
+
+ packaging.buildtimestamp
+ packaging.buildtimestamp.parent
+ 1.0.0-SNAPSHOT
+
+
+ packaging.buildtimestamp
+ packaging.buildtimestamp.plugin01
+ 1.0.0-SNAPSHOT
+ eclipse-plugin
+
+
\ No newline at end of file
diff --git a/tycho-its/projects/packaging.buildsimplequalifier/plugin02/META-INF/MANIFEST.MF b/tycho-its/projects/packaging.buildsimplequalifier/plugin02/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..cfe7b75adf
--- /dev/null
+++ b/tycho-its/projects/packaging.buildsimplequalifier/plugin02/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: packaging.buildtimestamp.plugin02;singleton:=true
+Bundle-Version: 1.0.1.qualifier
+Bundle-ClassPath: .
+Bundle-Name: packaging.buildtimestamp.plugin02
diff --git a/tycho-its/projects/packaging.buildsimplequalifier/plugin02/build.properties b/tycho-its/projects/packaging.buildsimplequalifier/plugin02/build.properties
new file mode 100644
index 0000000000..7594fab8d5
--- /dev/null
+++ b/tycho-its/projects/packaging.buildsimplequalifier/plugin02/build.properties
@@ -0,0 +1,2 @@
+bin.includes = META-INF/,\
+ .
diff --git a/tycho-its/projects/packaging.buildsimplequalifier/plugin02/pom.xml b/tycho-its/projects/packaging.buildsimplequalifier/plugin02/pom.xml
new file mode 100644
index 0000000000..a56e97d761
--- /dev/null
+++ b/tycho-its/projects/packaging.buildsimplequalifier/plugin02/pom.xml
@@ -0,0 +1,17 @@
+
+
+ 4.0.0
+
+
+ packaging.buildtimestamp
+ packaging.buildtimestamp.parent
+ 1.0.0-SNAPSHOT
+
+
+ packaging.buildtimestamp
+ packaging.buildtimestamp.plugin02
+ 1.0.1-SNAPSHOT
+ eclipse-plugin
+
+
\ No newline at end of file
diff --git a/tycho-its/projects/packaging.buildsimplequalifier/pom.xml b/tycho-its/projects/packaging.buildsimplequalifier/pom.xml
new file mode 100644
index 0000000000..841bd902f9
--- /dev/null
+++ b/tycho-its/projects/packaging.buildsimplequalifier/pom.xml
@@ -0,0 +1,41 @@
+
+
+ 4.0.0
+
+ packaging.buildtimestamp
+ packaging.buildtimestamp.parent
+ 1.0.0-SNAPSHOT
+ pom
+
+
+ yyyyMMddHHmmssSSS
+
+
+
+ plugin01
+ plugin02
+ mavenPlugin
+
+
+
+
+
+ org.eclipse.tycho
+ tycho-maven-plugin
+ ${tycho-version}
+ true
+
+
+ org.eclipse.tycho
+ tycho-packaging-plugin
+ ${tycho-version}
+
+ false
+ 1
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/packaging/DefaultBuildSimpleQualifierTest.java b/tycho-its/src/test/java/org/eclipse/tycho/test/packaging/DefaultBuildSimpleQualifierTest.java
new file mode 100644
index 0000000000..cf5fb90424
--- /dev/null
+++ b/tycho-its/src/test/java/org/eclipse/tycho/test/packaging/DefaultBuildSimpleQualifierTest.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2016, 2021 Bachmann electronic GmbH. and others.
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Bachmann electronic GmbH. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tycho.test.packaging;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import org.apache.maven.it.Verifier;
+import org.eclipse.tycho.test.AbstractTychoIntegrationTest;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * This test uses a project that contains 3 plugins (2 eclipse-plugins and one
+ * maven plugin). The maven plugin contains a text file where the
+ * maven.build.buildtimestamp is written to. It compares the content of that
+ * file with the qualifier of the Bundle-Version in the eclipse plugins manifest
+ * files.
+ *
+ * The test is ensuring qualifier to be presented
+ */
+public class DefaultBuildSimpleQualifierTest extends AbstractTychoIntegrationTest {
+
+ @Test
+ public void testDefaulBuildTimestampIsTheMavenBuildTimestamp() throws Exception {
+ Verifier verifier = getVerifier("/packaging.buildsimplequalifier", false);
+ verifier.executeGoal("verify");
+ verifier.verifyErrorFreeLog();
+ File baseDir = new File(verifier.getBasedir());
+
+ String plugin1Manifest = Files.readString(Paths.get(baseDir.getAbsolutePath(), "plugin01/target/MANIFEST.MF"));
+ String plugin2Manifest = Files.readString(Paths.get(baseDir.getAbsolutePath(), "plugin02/target/MANIFEST.MF"));
+ String expectedBundle1Version = "Bundle-Version: 1.0.0.1";
+ String expectedBundle2Version = "Bundle-Version: 1.0.1.1";
+ Assert.assertTrue(
+ "Expected Bundle-Version in MANIFEST: '" + expectedBundle1Version + "'\nbut was\n" + plugin1Manifest,
+ plugin1Manifest.contains(expectedBundle1Version));
+
+ Assert.assertTrue(
+ "Expected Bundle-Version in MANIFEST: '" + expectedBundle2Version + "'\nbut was\n" + plugin2Manifest,
+ plugin2Manifest.contains(expectedBundle2Version));
+ }
+
+}
diff --git a/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/buildversion/BuildQualifierMojo.java b/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/buildversion/BuildQualifierMojo.java
index 25073a26f9..abf3f5fdb7 100644
--- a/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/buildversion/BuildQualifierMojo.java
+++ b/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/buildversion/BuildQualifierMojo.java
@@ -53,18 +53,27 @@
*
*
*
- * The generated qualifier is assigned to buildQualifier project property. The
- * unqualified project version is assigned to unqualifiedVersion project property. The
- * unqualified version is calculated based on ${project.version} and can be used for
- * any Tycho project and regular Maven project. Different projects can use different formats to
- * expand the timestamp (not recommended). The concatenation of ${unqualifiedVersion}
- * and ${buildQualifier}, if not empty, is assigned to the project property
- * qualifiedVersion.
+ * The generated qualifier is assigned to buildQualifier project
+ * property. The unqualified project version is assigned to
+ * unqualifiedVersion project property. The unqualified version is
+ * calculated based on ${project.version} and can be used for any
+ * Tycho project and regular Maven project. Different projects can use different
+ * formats to expand the timestamp (not recommended). The concatenation of
+ * ${unqualifiedVersion} and ${buildQualifier}, if not
+ * empty, is assigned to the project property qualifiedVersion.
*
*
- * The timestamp generation logic is extensible. The primary use case is to generate build version
- * qualifier based on the timestamp of the last project commit. Here is example pom.xml snippet that
- * enables custom timestamp generation logic
+ * The timestamp generation logic is extensible. The primary use case is to
+ * generate build version qualifier based on the timestamp of the last project
+ * commit. Here is example pom.xml snippet that enables custom timestamp
+ * generation logic
+ *
+ *
+ * If configured build qualifier will strip repeated qualifier if matching to
+ * micro version. If stripQualifierIfDuplicates property is
+ * enabled, it will generate for version 1.0.0.qualifier and qualifier equal 0
+ * version 1.0.0. If disabled, it will generate for same version 1.0.0.0 so the
+ * last part is not stripped off.
*
*
* ...
@@ -81,6 +90,7 @@
* </dependencies>
* <configuration>
* <timestampProvider>custom</timestampProvider>
+ * <stripQualifierIfDuplicates>false</stripQualifierIfDuplicates>
* </configuration>
* </plugin>
* ...
@@ -124,6 +134,9 @@ public class BuildQualifierMojo extends AbstractVersionMojo {
@Parameter(property = "mojoExecution", readonly = true)
protected MojoExecution execution;
+ @Parameter(name = "stripQualifierMatchingMicro", defaultValue = "true", property = "tycho.buildqualifier.stripqualifiermatchingmicro")
+ protected boolean stripQualifierMatchingMicro;
+
@Inject
protected Map timestampProviders;
@@ -181,10 +194,13 @@ private TychoProjectVersion calculateQualifiedVersion(Date timestamp)
validateQualifier(forceContextQualifier, qualifier);
String pomOSGiVersion = getUnqualifiedVersion();
- String suffix = "." + qualifier;
- if (pomOSGiVersion.endsWith(suffix)) {
- return new TychoProjectVersion(pomOSGiVersion.substring(0, pomOSGiVersion.length() - suffix.length()),
- qualifier);
+ if (stripQualifierMatchingMicro) {
+ // Equal qualifier should be stripped only if enabled.
+ String suffix = "." + qualifier;
+ if (pomOSGiVersion.endsWith(suffix)) {
+ return new TychoProjectVersion(pomOSGiVersion.substring(0, pomOSGiVersion.length() - suffix.length()),
+ qualifier);
+ }
}
return new TychoProjectVersion(pomOSGiVersion, qualifier);
}