Skip to content

Commit b680fc6

Browse files
committed
Bug: 5047 proposed sollution to fix issue
1 parent 331b904 commit b680fc6

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

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
@@ -52,18 +52,27 @@
5252
* </ol>
5353
* </p>
5454
* <p>
55-
* The generated qualifier is assigned to <code>buildQualifier</code> project property. The
56-
* unqualified project version is assigned to <code>unqualifiedVersion</code> project property. The
57-
* unqualified version is calculated based on <code>${project.version}</code> and can be used for
58-
* any Tycho project and regular Maven project. Different projects can use different formats to
59-
* expand the timestamp (not recommended). The concatenation of <code>${unqualifiedVersion}</code>
60-
* and <code>${buildQualifier}</code>, if not empty, is assigned to the project property
61-
* <code>qualifiedVersion</code>.
55+
* The generated qualifier is assigned to <code>buildQualifier</code> project
56+
* property. The unqualified project version is assigned to
57+
* <code>unqualifiedVersion</code> project property. The unqualified version is
58+
* calculated based on <code>${project.version}</code> and can be used for any
59+
* Tycho project and regular Maven project. Different projects can use different
60+
* formats to expand the timestamp (not recommended). The concatenation of
61+
* <code>${unqualifiedVersion}</code> and <code>${buildQualifier}</code>, if not
62+
* empty, is assigned to the project property <code>qualifiedVersion</code>.
6263
* </p>
6364
* <p>
64-
* The timestamp generation logic is extensible. The primary use case is to generate build version
65-
* qualifier based on the timestamp of the last project commit. Here is example pom.xml snippet that
66-
* enables custom timestamp generation logic
65+
* The timestamp generation logic is extensible. The primary use case is to
66+
* generate build version qualifier based on the timestamp of the last project
67+
* commit. Here is example pom.xml snippet that enables custom timestamp
68+
* generation logic
69+
* </p>
70+
* <p>
71+
* If configured build qualifier will strip repeated qualifier if matching to
72+
* micro version. If <code>stripQualifierIfDuplicates</code> property is
73+
* enabled, it will generate for version 1.0.0.qualifier and qualifier equal 0
74+
* version 1.0.0. If disabled, it will generate for same version 1.0.0.0 so the
75+
* last part is not stripped off.
6776
*
6877
* <pre>
6978
* ...
@@ -80,6 +89,7 @@
8089
* &lt;/dependencies&gt;
8190
* &lt;configuration&gt;
8291
* &lt;timestampProvider&gt;custom&lt;/timestampProvider&gt;
92+
* &lt;stripQualifierIfDuplicates&gt;false&lt;/stripQualifierIfDuplicates&gt;
8393
* &lt;/configuration&gt;
8494
* &lt;/plugin&gt;
8595
* ...
@@ -123,6 +133,9 @@ public class BuildQualifierMojo extends AbstractVersionMojo {
123133
@Parameter(property = "mojoExecution", readonly = true)
124134
protected MojoExecution execution;
125135

136+
@Parameter(name = "stripQualifierMatchingMicro", defaultValue = "true", property = "tycho.buildqualifier.stripqualifiermatchingmicro")
137+
protected boolean stripQualifierMatchingMicro;
138+
126139
@Component(role = BuildTimestampProvider.class)
127140
protected Map<String, BuildTimestampProvider> timestampProviders;
128141

@@ -180,10 +193,13 @@ private TychoProjectVersion calculateQualifiedVersion(Date timestamp)
180193
validateQualifier(forceContextQualifier, qualifier);
181194

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

0 commit comments

Comments
 (0)