|
52 | 52 | * </ol> |
53 | 53 | * </p> |
54 | 54 | * <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>. |
62 | 63 | * </p> |
63 | 64 | * <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. |
67 | 76 | * |
68 | 77 | * <pre> |
69 | 78 | * ... |
|
80 | 89 | * </dependencies> |
81 | 90 | * <configuration> |
82 | 91 | * <timestampProvider>custom</timestampProvider> |
| 92 | + * <stripQualifierIfDuplicates>false</stripQualifierIfDuplicates> |
83 | 93 | * </configuration> |
84 | 94 | * </plugin> |
85 | 95 | * ... |
@@ -123,6 +133,9 @@ public class BuildQualifierMojo extends AbstractVersionMojo { |
123 | 133 | @Parameter(property = "mojoExecution", readonly = true) |
124 | 134 | protected MojoExecution execution; |
125 | 135 |
|
| 136 | + @Parameter(name = "stripQualifierMatchingMicro", defaultValue = "true", property = "tycho.buildqualifier.stripqualifiermatchingmicro") |
| 137 | + protected boolean stripQualifierMatchingMicro; |
| 138 | + |
126 | 139 | @Component(role = BuildTimestampProvider.class) |
127 | 140 | protected Map<String, BuildTimestampProvider> timestampProviders; |
128 | 141 |
|
@@ -180,10 +193,13 @@ private TychoProjectVersion calculateQualifiedVersion(Date timestamp) |
180 | 193 | validateQualifier(forceContextQualifier, qualifier); |
181 | 194 |
|
182 | 195 | 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 | + } |
187 | 203 | } |
188 | 204 | return new TychoProjectVersion(pomOSGiVersion, qualifier); |
189 | 205 | } |
|
0 commit comments