Skip to content

Commit 9e7e3f3

Browse files
committed
feat: set current version
1 parent 14f6366 commit 9e7e3f3

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ Or in `pom.xml`:
217217
</goals>
218218
<configuration>
219219
<!-- Suffix version with -SNAPSHOT //-->
220-
<updatePomWithNextSemanticVersionSuffixSnapshot>true</updatePomWithNextSemanticVersionSuffixSnapshot>
220+
<updatePomWithNextSemanticVersionSuffixSnapshot>false</updatePomWithNextSemanticVersionSuffixSnapshot>
221+
<updatePomWithCurrentSemanticVersionSuffixSnapshotIfNotTagged>true</updatePomWithCurrentSemanticVersionSuffixSnapshotIfNotTagged>
221222

222223
<!-- Regexp patterns used to identify next version can optionally be adjusted //-->
223224
<semanticMajorVersionPattern>^[Bb]reaking</semanticMajorVersionPattern>

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4444
<maven.compiler.target>1.8</maven.compiler.target>
4545
<maven.compiler.source>1.8</maven.compiler.source>
46-
<changelog-lib>1.173.0</changelog-lib>
46+
<changelog-lib>1.174.0</changelog-lib>
4747
</properties>
4848

4949
<dependencies>

src/main/java/se/bjurr/gitchangelog/plugin/SemanticVersionMojo.java

+15-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,16 @@ public class SemanticVersionMojo extends AbstractMojo {
1919
@Component private MavenProject project;
2020

2121
@Parameter(
22-
property = "updatePomWithNextSemanticVersionSuffixSnapshot",
22+
property = "updatePomWithCurrentSemanticVersionSuffixSnapshot",
23+
required = false,
24+
defaultValue = "false")
25+
private boolean updatePomWithCurrentSemanticVersionSuffixSnapshot;
26+
27+
@Parameter(
28+
property = "updatePomWithCurrentSemanticVersionSuffixSnapshotIfNotTagged",
2329
required = false,
2430
defaultValue = "true")
25-
private boolean updatePomWithNextSemanticVersionSuffixSnapshot;
31+
private boolean updatePomWithCurrentSemanticVersionSuffixSnapshotIfNotTagged;
2632

2733
@Parameter(property = "semanticMajorVersionPattern", required = false)
2834
private String semanticMajorVersionPattern;
@@ -52,9 +58,14 @@ public void execute() throws MojoExecutionException {
5258
if (this.isSupplied(this.ignoreTagsIfNameMatches)) {
5359
gitChangelogApiBuilder.withIgnoreTagsIfNameMatches(this.ignoreTagsIfNameMatches);
5460
}
55-
final SemanticVersion nextSemanticVersion = gitChangelogApiBuilder.getNextSemanticVersion();
61+
final SemanticVersion nextSemanticVersion =
62+
gitChangelogApiBuilder.getCurrentSemanticVersion();
63+
final boolean notTagged = nextSemanticVersion.findTag().isEmpty();
64+
final boolean suffixWithSnapshot =
65+
this.updatePomWithCurrentSemanticVersionSuffixSnapshot
66+
|| this.updatePomWithCurrentSemanticVersionSuffixSnapshotIfNotTagged && notTagged;
5667
final String nextVersion =
57-
this.updatePomWithNextSemanticVersionSuffixSnapshot
68+
suffixWithSnapshot
5869
? nextSemanticVersion.getVersion() + "-SNAPSHOT"
5970
: nextSemanticVersion.getVersion();
6071

0 commit comments

Comments
 (0)