Skip to content

Commit 62a521b

Browse files
authored
Merge pull request #73 from FortnoxAB/changeset-version-policy
Tie versioning to a Maven Release version policy
2 parents 2fb5ff6 + 5059eed commit 62a521b

18 files changed

Lines changed: 902 additions & 627 deletions

File tree

.changeset/cyan-sloths-unite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"changesets": minor
3+
---
4+
5+
This change introduces a version policy (`ChangesetsVersionPolicy`) compatible with the Release Maven plugin, together with a flag `useReleasePluginIntegration` (default `false`) on the `prepare` goal. Enabling this flag will disable updating POM versions in `prepare` and only perform changeset processing. Updating versions in POMs can then be delegated to the Release plugin, together with all the other facilities that plugin provides.

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,39 @@ to enable easier management of changelogs and semantically versioned releases.
66
Our goal is to keep compatibility with the files and formats of the original implementation as far as it makes sense, so that
77
users recognize the ways of working and feel at home.
88

9-
This is it, at the moment. Stay tuned for more docs later on, thanks!
9+
This is it, at the moment. Stay tuned for more docs later on, thanks!
10+
11+
# Release Maven Plugin Integration
12+
13+
To delegate versioning to the Release Maven Plugin, you can use the `ChangesetsVersionPolicy` together with the `useReleasePluginIntegration` flag:
14+
15+
```
16+
<build>
17+
<plugins>
18+
<plugin>
19+
<groupId>se.fortnox.changesets</groupId>
20+
<artifactId>changesets-maven-plugin</artifactId>
21+
<version>${changesets.plugin.version}</version>
22+
<configuration>
23+
<useReleasePluginIntegration>true</useReleasePluginIntegration> <!-- Disables version updates in prepare goal -->
24+
</configuration>
25+
</plugin>
26+
<plugin>
27+
<artifactId>maven-release-plugin</artifactId>
28+
<version>3.1.1</version>
29+
<configuration>
30+
<projectVersionPolicyId>changesets</projectVersionPolicyId>
31+
<tagNameFormat>v@{project.version}</tagNameFormat>
32+
</configuration>
33+
<dependencies>
34+
<dependency>
35+
<groupId>se.fortnox.changesets</groupId>
36+
<artifactId>changesets-maven-plugin</artifactId>
37+
<version>${changesets.plugin.version}</version>
38+
</dependency>
39+
</dependencies>
40+
</plugin>
41+
</plugins>
42+
```
43+
44+
Goals should then be invoked as `changesets:prepare release:prepare release:perform`. `changesets:release` should *not* be used.

changesets-java/pom.xml

Lines changed: 97 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,108 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5-
<modelVersion>4.0.0</modelVersion>
6-
<parent>
7-
<groupId>se.fortnox.changesets</groupId>
8-
<artifactId>changesets</artifactId>
9-
<version>0.1.1-SNAPSHOT</version>
10-
</parent>
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>se.fortnox.changesets</groupId>
8+
<artifactId>changesets</artifactId>
9+
<version>0.1.1-SNAPSHOT</version>
10+
</parent>
1111

12-
<artifactId>changesets-java</artifactId>
13-
<description>Java library for handling of changesets</description>
12+
<artifactId>changesets-java</artifactId>
13+
<description>Java library for handling of changesets</description>
1414

15-
<dependencies>
16-
<dependency>
17-
<groupId>org.apache.maven</groupId>
18-
<artifactId>maven-plugin-api</artifactId>
19-
<scope>provided</scope>
20-
</dependency>
21-
<dependency>
22-
<groupId>org.apache.maven</groupId>
23-
<artifactId>maven-core</artifactId>
24-
<scope>provided</scope>
25-
</dependency>
26-
<dependency>
27-
<groupId>org.apache.maven</groupId>
28-
<artifactId>maven-artifact</artifactId>
29-
<scope>provided</scope>
30-
</dependency>
31-
<dependency>
32-
<groupId>org.apache.maven</groupId>
33-
<artifactId>maven-compat</artifactId>
34-
<scope>test</scope>
35-
</dependency>
36-
<dependency>
37-
<groupId>org.apache.maven.plugin-tools</groupId>
38-
<artifactId>maven-plugin-annotations</artifactId>
39-
<scope>provided</scope>
40-
</dependency>
41-
<dependency>
42-
<groupId>org.slf4j</groupId>
43-
<artifactId>slf4j-api</artifactId>
44-
</dependency>
45-
<dependency>
46-
<groupId>org.semver4j</groupId>
47-
<artifactId>semver4j</artifactId>
48-
</dependency>
15+
<dependencies>
16+
<dependency>
17+
<groupId>org.apache.maven</groupId>
18+
<artifactId>maven-plugin-api</artifactId>
19+
<scope>provided</scope>
20+
</dependency>
21+
<dependency>
22+
<groupId>org.apache.maven</groupId>
23+
<artifactId>maven-core</artifactId>
24+
<scope>provided</scope>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.apache.maven</groupId>
28+
<artifactId>maven-artifact</artifactId>
29+
<scope>provided</scope>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.apache.maven</groupId>
33+
<artifactId>maven-compat</artifactId>
34+
<scope>test</scope>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.apache.maven.plugin-tools</groupId>
38+
<artifactId>maven-plugin-annotations</artifactId>
39+
<scope>provided</scope>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.slf4j</groupId>
43+
<artifactId>slf4j-api</artifactId>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.semver4j</groupId>
47+
<artifactId>semver4j</artifactId>
48+
</dependency>
4949

50-
<dependency>
51-
<groupId>org.codehaus.mojo.versions</groupId>
52-
<artifactId>versions-common</artifactId>
53-
</dependency>
54-
<dependency>
55-
<groupId>com.vladsch.flexmark</groupId>
56-
<artifactId>flexmark-all</artifactId>
57-
</dependency>
50+
<dependency>
51+
<groupId>org.codehaus.mojo.versions</groupId>
52+
<artifactId>versions-common</artifactId>
53+
</dependency>
54+
<dependency>
55+
<groupId>com.vladsch.flexmark</groupId>
56+
<artifactId>flexmark-all</artifactId>
57+
</dependency>
5858

5959

60-
<dependency>
61-
<groupId>com.fasterxml.jackson.dataformat</groupId>
62-
<artifactId>jackson-dataformat-yaml</artifactId>
63-
</dependency>
64-
<dependency>
65-
<groupId>org.mockito</groupId>
66-
<artifactId>mockito-core</artifactId>
67-
<scope>test</scope>
68-
</dependency>
69-
<dependency>
70-
<groupId>org.junit.jupiter</groupId>
71-
<artifactId>junit-jupiter-api</artifactId>
72-
<scope>test</scope>
73-
</dependency>
74-
<dependency>
75-
<groupId>org.junit.jupiter</groupId>
76-
<artifactId>junit-jupiter-params</artifactId>
77-
<scope>test</scope>
78-
</dependency>
79-
<dependency>
80-
<groupId>org.assertj</groupId>
81-
<artifactId>assertj-core</artifactId>
82-
<scope>test</scope>
83-
</dependency>
84-
<dependency>
85-
<groupId>ch.qos.logback</groupId>
86-
<artifactId>logback-core</artifactId>
87-
<scope>test</scope>
88-
</dependency>
89-
<dependency>
90-
<groupId>ch.qos.logback</groupId>
91-
<artifactId>logback-classic</artifactId>
92-
<scope>test</scope>
93-
</dependency>
60+
<dependency>
61+
<groupId>com.fasterxml.jackson.dataformat</groupId>
62+
<artifactId>jackson-dataformat-yaml</artifactId>
63+
</dependency>
64+
<dependency>
65+
<groupId>org.mockito</groupId>
66+
<artifactId>mockito-core</artifactId>
67+
<scope>test</scope>
68+
</dependency>
69+
<dependency>
70+
<groupId>org.junit.jupiter</groupId>
71+
<artifactId>junit-jupiter-api</artifactId>
72+
<scope>test</scope>
73+
</dependency>
74+
<dependency>
75+
<groupId>org.junit.jupiter</groupId>
76+
<artifactId>junit-jupiter-params</artifactId>
77+
<scope>test</scope>
78+
</dependency>
79+
<dependency>
80+
<groupId>org.assertj</groupId>
81+
<artifactId>assertj-core</artifactId>
82+
<scope>test</scope>
83+
</dependency>
84+
<dependency>
85+
<groupId>ch.qos.logback</groupId>
86+
<artifactId>logback-core</artifactId>
87+
<scope>test</scope>
88+
</dependency>
89+
<dependency>
90+
<groupId>ch.qos.logback</groupId>
91+
<artifactId>logback-classic</artifactId>
92+
<scope>test</scope>
93+
</dependency>
9494

95-
<dependency>
96-
<groupId>io.hosuaby</groupId>
97-
<artifactId>inject-resources-core</artifactId>
98-
<scope>test</scope>
99-
</dependency>
100-
<dependency>
101-
<groupId>io.hosuaby</groupId>
102-
<artifactId>inject-resources-junit-jupiter</artifactId>
103-
<scope>test</scope>
104-
</dependency>
105-
</dependencies>
95+
<dependency>
96+
<groupId>io.hosuaby</groupId>
97+
<artifactId>inject-resources-core</artifactId>
98+
<scope>test</scope>
99+
</dependency>
100+
<dependency>
101+
<groupId>io.hosuaby</groupId>
102+
<artifactId>inject-resources-junit-jupiter</artifactId>
103+
<scope>test</scope>
104+
</dependency>
105+
</dependencies>
106106

107107

108108
</project>

changesets-java/src/main/java/se/fortnox/changesets/VersionCalculator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,10 @@ public static String getNewVersion(String version, List<Changeset> changes) {
2727
}
2828
return semanticVersion.getVersion();
2929
}
30+
31+
public static String nextDevelopmentVersion(String actualVersion) {
32+
return Optional.ofNullable(Semver.coerce(actualVersion))
33+
.map(semver -> semver.withIncPatch().withPreRelease("SNAPSHOT").getVersion())
34+
.orElseThrow(() -> new IllegalArgumentException("Cannot coerce \"%s\" into a semantic version.".formatted(actualVersion)));
35+
}
3036
}

0 commit comments

Comments
 (0)