Skip to content

Commit 8e6cd06

Browse files
committed
Bug: 5047 proposed sollution to fix issue
1 parent a28e51b commit 8e6cd06

2 files changed

Lines changed: 31 additions & 14 deletions

File tree

tycho-its/projects/packaging.buildsimplequalifier/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<artifactId>tycho-packaging-plugin</artifactId>
3232
<version>${tycho-version}</version>
3333
<configuration>
34+
<stripQualifierMatchingMicro>false</stripQualifierMatchingMicro>
3435
<forceContextQualifier>1</forceContextQualifier>
3536
</configuration>
3637
</plugin>

tycho-packaging-plugin/src/main/java/org/eclipse/tycho/buildversion/BuildQualifierMojo.java

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,27 @@
5353
* </ol>
5454
* </p>
5555
* <p>
56-
* The generated qualifier is assigned to <code>buildQualifier</code> project property. The
57-
* unqualified project version is assigned to <code>unqualifiedVersion</code> project property. The
58-
* unqualified version is calculated based on <code>${project.version}</code> and can be used for
59-
* any Tycho project and regular Maven project. Different projects can use different formats to
60-
* expand the timestamp (not recommended). The concatenation of <code>${unqualifiedVersion}</code>
61-
* and <code>${buildQualifier}</code>, if not empty, is assigned to the project property
62-
* <code>qualifiedVersion</code>.
56+
* The generated qualifier is assigned to <code>buildQualifier</code> project
57+
* property. The unqualified project version is assigned to
58+
* <code>unqualifiedVersion</code> project property. The unqualified version is
59+
* calculated based on <code>${project.version}</code> and can be used for any
60+
* Tycho project and regular Maven project. Different projects can use different
61+
* formats to expand the timestamp (not recommended). The concatenation of
62+
* <code>${unqualifiedVersion}</code> and <code>${buildQualifier}</code>, if not
63+
* empty, is assigned to the project property <code>qualifiedVersion</code>.
6364
* </p>
6465
* <p>
65-
* The timestamp generation logic is extensible. The primary use case is to generate build version
66-
* qualifier based on the timestamp of the last project commit. Here is example pom.xml snippet that
67-
* enables custom timestamp generation logic
66+
* The timestamp generation logic is extensible. The primary use case is to
67+
* generate build version qualifier based on the timestamp of the last project
68+
* commit. Here is example pom.xml snippet that enables custom timestamp
69+
* generation logic
70+
* </p>
71+
* <p>
72+
* If configured build qualifier will strip repeated qualifier if matching to
73+
* micro version. If <code>stripQualifierIfDuplicates</code> property is
74+
* enabled, it will generate for version 1.0.0.qualifier and qualifier equal 0
75+
* version 1.0.0. If disabled, it will generate for same version 1.0.0.0 so the
76+
* last part is not stripped off.
6877
*
6978
* <pre>
7079
* ...
@@ -81,6 +90,7 @@
8190
* &lt;/dependencies&gt;
8291
* &lt;configuration&gt;
8392
* &lt;timestampProvider&gt;custom&lt;/timestampProvider&gt;
93+
* &lt;stripQualifierIfDuplicates&gt;false&lt;/stripQualifierIfDuplicates&gt;
8494
* &lt;/configuration&gt;
8595
* &lt;/plugin&gt;
8696
* ...
@@ -124,6 +134,9 @@ public class BuildQualifierMojo extends AbstractVersionMojo {
124134
@Parameter(property = "mojoExecution", readonly = true)
125135
protected MojoExecution execution;
126136

137+
@Parameter(name = "stripQualifierMatchingMicro", defaultValue = "true", property = "tycho.buildqualifier.stripqualifiermatchingmicro")
138+
protected boolean stripQualifierMatchingMicro;
139+
127140
@Inject
128141
protected Map<String, BuildTimestampProvider> timestampProviders;
129142

@@ -181,10 +194,13 @@ private TychoProjectVersion calculateQualifiedVersion(Date timestamp)
181194
validateQualifier(forceContextQualifier, qualifier);
182195

183196
String pomOSGiVersion = getUnqualifiedVersion();
184-
String suffix = "." + qualifier;
185-
if (pomOSGiVersion.endsWith(suffix)) {
186-
return new TychoProjectVersion(pomOSGiVersion.substring(0, pomOSGiVersion.length() - suffix.length()),
187-
qualifier);
197+
if (stripQualifierMatchingMicro) {
198+
// Equal qualifier should be stripped only if enabled.
199+
String suffix = "." + qualifier;
200+
if (pomOSGiVersion.endsWith(suffix)) {
201+
return new TychoProjectVersion(pomOSGiVersion.substring(0, pomOSGiVersion.length() - suffix.length()),
202+
qualifier);
203+
}
188204
}
189205
return new TychoProjectVersion(pomOSGiVersion, qualifier);
190206
}

0 commit comments

Comments
 (0)