diff --git a/.changeset/cyan-sloths-unite.md b/.changeset/cyan-sloths-unite.md new file mode 100644 index 0000000..f2f96ef --- /dev/null +++ b/.changeset/cyan-sloths-unite.md @@ -0,0 +1,5 @@ +--- +"changesets": minor +--- + +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. diff --git a/README.md b/README.md index 056c41e..745ac88 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,39 @@ to enable easier management of changelogs and semantically versioned releases. Our goal is to keep compatibility with the files and formats of the original implementation as far as it makes sense, so that users recognize the ways of working and feel at home. -This is it, at the moment. Stay tuned for more docs later on, thanks! \ No newline at end of file +This is it, at the moment. Stay tuned for more docs later on, thanks! + +# Release Maven Plugin Integration + +To delegate versioning to the Release Maven Plugin, you can use the `ChangesetsVersionPolicy` together with the `useReleasePluginIntegration` flag: + +``` + + + + se.fortnox.changesets + changesets-maven-plugin + ${changesets.plugin.version} + + true + + + + maven-release-plugin + 3.1.1 + + changesets + v@{project.version} + + + + se.fortnox.changesets + changesets-maven-plugin + ${changesets.plugin.version} + + + + +``` + +Goals should then be invoked as `changesets:prepare release:prepare release:perform`. `changesets:release` should *not* be used. \ No newline at end of file diff --git a/changesets-java/pom.xml b/changesets-java/pom.xml index 6a18d2d..0f049bf 100644 --- a/changesets-java/pom.xml +++ b/changesets-java/pom.xml @@ -1,108 +1,108 @@ - - 4.0.0 - - se.fortnox.changesets - changesets - 0.1.1-SNAPSHOT - + 4.0.0 + + se.fortnox.changesets + changesets + 0.1.1-SNAPSHOT + - changesets-java - Java library for handling of changesets + changesets-java + Java library for handling of changesets - - - org.apache.maven - maven-plugin-api - provided - - - org.apache.maven - maven-core - provided - - - org.apache.maven - maven-artifact - provided - - - org.apache.maven - maven-compat - test - - - org.apache.maven.plugin-tools - maven-plugin-annotations - provided - - - org.slf4j - slf4j-api - - - org.semver4j - semver4j - + + + org.apache.maven + maven-plugin-api + provided + + + org.apache.maven + maven-core + provided + + + org.apache.maven + maven-artifact + provided + + + org.apache.maven + maven-compat + test + + + org.apache.maven.plugin-tools + maven-plugin-annotations + provided + + + org.slf4j + slf4j-api + + + org.semver4j + semver4j + - - org.codehaus.mojo.versions - versions-common - - - com.vladsch.flexmark - flexmark-all - + + org.codehaus.mojo.versions + versions-common + + + com.vladsch.flexmark + flexmark-all + - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - - - org.mockito - mockito-core - test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-params - test - - - org.assertj - assertj-core - test - - - ch.qos.logback - logback-core - test - - - ch.qos.logback - logback-classic - test - + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + org.mockito + mockito-core + test + + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-params + test + + + org.assertj + assertj-core + test + + + ch.qos.logback + logback-core + test + + + ch.qos.logback + logback-classic + test + - - io.hosuaby - inject-resources-core - test - - - io.hosuaby - inject-resources-junit-jupiter - test - - + + io.hosuaby + inject-resources-core + test + + + io.hosuaby + inject-resources-junit-jupiter + test + + \ No newline at end of file diff --git a/changesets-java/src/main/java/se/fortnox/changesets/VersionCalculator.java b/changesets-java/src/main/java/se/fortnox/changesets/VersionCalculator.java index 959b878..8adf1ab 100644 --- a/changesets-java/src/main/java/se/fortnox/changesets/VersionCalculator.java +++ b/changesets-java/src/main/java/se/fortnox/changesets/VersionCalculator.java @@ -27,4 +27,10 @@ public static String getNewVersion(String version, List changes) { } return semanticVersion.getVersion(); } + + public static String nextDevelopmentVersion(String actualVersion) { + return Optional.ofNullable(Semver.coerce(actualVersion)) + .map(semver -> semver.withIncPatch().withPreRelease("SNAPSHOT").getVersion()) + .orElseThrow(() -> new IllegalArgumentException("Cannot coerce \"%s\" into a semantic version.".formatted(actualVersion))); + } } diff --git a/changesets-maven-plugin/pom.xml b/changesets-maven-plugin/pom.xml index d944eb7..a230e38 100644 --- a/changesets-maven-plugin/pom.xml +++ b/changesets-maven-plugin/pom.xml @@ -1,179 +1,206 @@ - - 4.0.0 - - se.fortnox.changesets - changesets - 0.1.1-SNAPSHOT - + 4.0.0 + + se.fortnox.changesets + changesets + 0.1.1-SNAPSHOT + - changesets-maven-plugin - maven-plugin + changesets-maven-plugin + maven-plugin - - - github - scm:git:https://github.com/FortnoxAB/changesets-java.git - - + + + github + scm:git:https://github.com/FortnoxAB/changesets-java.git + + - - - ${project.groupId} - changesets-java - ${project.version} - - - org.apache.maven - maven-plugin-api - provided - - - org.apache.maven - maven-core - provided - - - org.apache.maven - maven-artifact - provided - - - org.apache.maven.shared - maven-shared-utils - 3.4.2 - - - org.apache.maven - maven-compat - test - - - org.apache.maven.plugin-tools - maven-plugin-annotations - provided - - - org.slf4j - slf4j-api - - - org.codehaus.mojo.versions - versions-common - - - org.assertj - assertj-core - test - - + + + ${project.groupId} + changesets-java + ${project.version} + + + org.apache.maven + maven-plugin-api + provided + + + org.apache.maven + maven-core + provided + + + org.apache.maven + maven-artifact + provided + + + org.apache.maven.shared + maven-shared-utils + + + org.apache.maven.release + maven-release-api + + + org.apache.maven + maven-compat + test + + + org.apache.maven.plugin-tools + maven-plugin-annotations + provided + + + org.slf4j + slf4j-api + + + org.codehaus.mojo.versions + versions-common + + + org.assertj + assertj-core + test + + - - - - org.apache.maven.plugins - maven-plugin-plugin - - true - changesets - - - - mojo-descriptor - - descriptor - - - - help-goal - - helpmojo - - - - - - org.apache.maven.plugins - maven-site-plugin - 3.21.0 - - - default-site - - site - stage - - site - - - - false - - - - org.apache.maven.plugins - maven-scm-publish-plugin - 3.3.0 - - gh-pages - - - - + + + + org.codehaus.plexus + plexus-component-metadata + + + process-classes + + generate-metadata + + + + + + org.apache.maven.plugins + maven-plugin-plugin + + true + changesets + + + + mojo-descriptor + + descriptor + + + + help-goal + + helpmojo + + + + + + org.eclipse.sisu + sisu-maven-plugin + + + generate-index + + main-index + + + + + + org.apache.maven.plugins + maven-site-plugin + 3.21.0 + + + default-site + + site + stage + + site + + + + false + + + + org.apache.maven.plugins + maven-scm-publish-plugin + 3.3.0 + + gh-pages + + + + - - - run-its - - true - - - - - org.apache.maven.plugins - maven-invoker-plugin - 3.9.0 - - verify - ${project.build.directory}/local-repo - src/it/settings.xml - true - true - - clean - test-compile - - - - - integration-test - - install - integration-test - verify - - - - - - - - + + + run-its + + true + + + + + org.apache.maven.plugins + maven-invoker-plugin + 3.9.0 + + verify + ${project.build.directory}/local-repo + src/it/settings.xml + true + true + + clean + test-compile + + + + + integration-test + + install + integration-test + verify + + + + + + + + org.apache.maven.plugins maven-plugin-report-plugin - - - - report - - - + + + + report + + + diff --git a/changesets-maven-plugin/src/it/prepare-release-plugin-integration/.changeset/VERSION b/changesets-maven-plugin/src/it/prepare-release-plugin-integration/.changeset/VERSION new file mode 100644 index 0000000..26f8b8b --- /dev/null +++ b/changesets-maven-plugin/src/it/prepare-release-plugin-integration/.changeset/VERSION @@ -0,0 +1 @@ +2.4.5 \ No newline at end of file diff --git a/changesets-maven-plugin/src/it/prepare-release-plugin-integration/.changeset/nine-owls-knock.md b/changesets-maven-plugin/src/it/prepare-release-plugin-integration/.changeset/nine-owls-knock.md new file mode 100644 index 0000000..d7e69f0 --- /dev/null +++ b/changesets-maven-plugin/src/it/prepare-release-plugin-integration/.changeset/nine-owls-knock.md @@ -0,0 +1,5 @@ +--- +"my-package": patch +--- + +A tiny change diff --git a/changesets-maven-plugin/src/it/prepare-release-plugin-integration/.changeset/seven-owls-suspect.md b/changesets-maven-plugin/src/it/prepare-release-plugin-integration/.changeset/seven-owls-suspect.md new file mode 100644 index 0000000..e37c41c --- /dev/null +++ b/changesets-maven-plugin/src/it/prepare-release-plugin-integration/.changeset/seven-owls-suspect.md @@ -0,0 +1,5 @@ +--- +"my-package": minor +--- + +A medium change diff --git a/changesets-maven-plugin/src/it/prepare-release-plugin-integration/EXPECTED_CHANGELOG.md b/changesets-maven-plugin/src/it/prepare-release-plugin-integration/EXPECTED_CHANGELOG.md new file mode 100644 index 0000000..4104f4f --- /dev/null +++ b/changesets-maven-plugin/src/it/prepare-release-plugin-integration/EXPECTED_CHANGELOG.md @@ -0,0 +1,12 @@ +# my-package + +## 2.5.0 + +### Minor Changes + +- A medium change + +### Patch Changes + +- A tiny change + diff --git a/changesets-maven-plugin/src/it/prepare-release-plugin-integration/invoker.properties b/changesets-maven-plugin/src/it/prepare-release-plugin-integration/invoker.properties new file mode 100644 index 0000000..20eb64a --- /dev/null +++ b/changesets-maven-plugin/src/it/prepare-release-plugin-integration/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals.1=${project.groupId}:${project.artifactId}:${project.version}:prepare +invoker.goals.2=release:update-versions \ No newline at end of file diff --git a/changesets-maven-plugin/src/it/prepare-release-plugin-integration/pom.xml b/changesets-maven-plugin/src/it/prepare-release-plugin-integration/pom.xml new file mode 100644 index 0000000..d05c9f0 --- /dev/null +++ b/changesets-maven-plugin/src/it/prepare-release-plugin-integration/pom.xml @@ -0,0 +1,35 @@ + + + 4.0.0 + + se.fortnox.maven.it + my-package + 2.4.6-SNAPSHOT + + A simple IT verifying the basic use case. + + + UTF-8 + + + + + + maven-release-plugin + 3.1.1 + + changesets + false + + + + se.fortnox.changesets + changesets-maven-plugin + @project.version@ + + + + + + diff --git a/changesets-maven-plugin/src/it/prepare-release-plugin-integration/test.properties b/changesets-maven-plugin/src/it/prepare-release-plugin-integration/test.properties new file mode 100644 index 0000000..08a82ac --- /dev/null +++ b/changesets-maven-plugin/src/it/prepare-release-plugin-integration/test.properties @@ -0,0 +1 @@ +useReleasePluginIntegration=true diff --git a/changesets-maven-plugin/src/it/prepare-release-plugin-integration/verify.groovy b/changesets-maven-plugin/src/it/prepare-release-plugin-integration/verify.groovy new file mode 100644 index 0000000..f4502bb --- /dev/null +++ b/changesets-maven-plugin/src/it/prepare-release-plugin-integration/verify.groovy @@ -0,0 +1,23 @@ +import groovy.xml.XmlSlurper + +import static org.assertj.core.api.Assertions.assertThat + +String expectedVersion = '2.5.0'; +String expectedSnapshot = '2.5.1-SNAPSHOT'; + +// The VERSION file should contain the correct version number +assertThat(new File(basedir, '.changeset/VERSION')) + .content() + .isEqualTo(expectedVersion) + +// The root pom version should be increased by one patch and be a snapshot +def project = new XmlSlurper().parse(new File(basedir, 'pom.xml')) +assertThat(project.version).isEqualTo(expectedSnapshot) + +// Verify that the CHANGELOG.md has been created correctly +assertThat(new File(basedir, 'CHANGELOG.md')) + .hasSameTextualContentAs(new File(basedir, 'EXPECTED_CHANGELOG.md')) + +def buildLog = new File( basedir, "build.log").text +assert buildLog =~ /Changesets processed, but not updating POMs due to useReleasePluginIntegration being set to true/ +true \ No newline at end of file diff --git a/changesets-maven-plugin/src/main/java/se/fortnox/changesets/VersionFile.java b/changesets-maven-plugin/src/main/java/se/fortnox/changesets/VersionFile.java new file mode 100644 index 0000000..2f00f1f --- /dev/null +++ b/changesets-maven-plugin/src/main/java/se/fortnox/changesets/VersionFile.java @@ -0,0 +1,45 @@ +package se.fortnox.changesets; + +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.logging.Logger; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; +import java.util.Optional; + +import static se.fortnox.changesets.ChangesetWriter.CHANGESET_DIR; + +@Singleton +public class VersionFile { + private final Path versionFile; + + @Inject + public VersionFile(MavenProject project, Logger log) { + this.versionFile = project.getBasedir().toPath().resolve(CHANGESET_DIR).resolve("VERSION").toAbsolutePath(); + log.info("Using version file " + versionFile); + } + + public Optional currentVersion() { + if(!Files.exists(versionFile)) { + return Optional.empty(); + } + try { + return Optional.of(Files.readString(versionFile)); + } catch (IOException e) { + return Optional.empty(); + } + } + + public void assignVersion(String newVersion) { + try { + Files.writeString(versionFile, newVersion, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/changesets-maven-plugin/src/main/java/se/fortnox/changesets/maven/PrepareMojo.java b/changesets-maven-plugin/src/main/java/se/fortnox/changesets/maven/PrepareMojo.java index d085773..d4a7f47 100644 --- a/changesets-maven-plugin/src/main/java/se/fortnox/changesets/maven/PrepareMojo.java +++ b/changesets-maven-plugin/src/main/java/se/fortnox/changesets/maven/PrepareMojo.java @@ -4,23 +4,21 @@ import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.logging.Logger; import org.semver4j.Semver; import se.fortnox.changesets.ChangelogAggregator; import se.fortnox.changesets.Changeset; import se.fortnox.changesets.ChangesetLocator; import se.fortnox.changesets.VersionCalculator; +import se.fortnox.changesets.VersionFile; +import javax.inject.Inject; import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.NoSuchFileException; import java.nio.file.Path; -import java.nio.file.StandardOpenOption; import java.util.List; import java.util.Optional; -import static se.fortnox.changesets.ChangesetWriter.CHANGESET_DIR; - /** * Applies all changesets into the changelog and calculates the new version number. *

@@ -28,8 +26,22 @@ */ @Mojo(name = "prepare", defaultPhase = LifecyclePhase.INITIALIZE) public class PrepareMojo extends AbstractMojo { - @Parameter(defaultValue = "${project}", readonly = true, required = true) - private org.apache.maven.project.MavenProject project; + private final org.apache.maven.project.MavenProject project; + private final VersionFile versionFile; + private final Logger logger; + + @Inject + public PrepareMojo(MavenProject project, VersionFile versionFile, Logger logger) { + this.project = project; + this.versionFile = versionFile; + this.logger = logger; + } + + /* + * Set to true in order to just process changeset files, avoiding any changes to the POM(s). + */ + @Parameter(property = "useReleasePluginIntegration", defaultValue = "false") + protected boolean useReleasePluginIntegration = false; public void execute() { Path baseDir = project.getBasedir().toPath(); @@ -40,23 +52,25 @@ public void execute() { List changesets = changesetLocator.getChangesets(packageName); if (changesets.isEmpty()) { - getLog().info("No changesets for package: " + packageName + " found in " + baseDir); + logger.info("No changesets for package: " + packageName + " found in " + baseDir); return; } // Calculate new version - String currentVersion = getCurrentVersion(); + String currentVersion = versionFile.currentVersion().orElse("0.0.0");; String newVersion = VersionCalculator.getNewVersion(currentVersion, changesets); - getLog().info("Old version was " + currentVersion + ", will be updated to " + newVersion); + logger.info("Old version was " + currentVersion + ", will be updated to " + newVersion); // Move changesets into CHANGELOG.md ChangelogAggregator changelogAggregator = new ChangelogAggregator(baseDir); changelogAggregator.mergeChangesetsToChangelog(packageName, newVersion); - try { - Files.writeString(project.getBasedir().toPath().resolve(CHANGESET_DIR).resolve("VERSION"), newVersion, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); - } catch (IOException e) { - throw new RuntimeException(e); + // Advance to version deduced from changesets + versionFile.assignVersion(newVersion); + + if(useReleasePluginIntegration) { + logger.info("Changesets processed, but not updating POMs due to useReleasePluginIntegration being set to true."); + return; } // Set newVersion property to be used by versions:set @@ -66,30 +80,16 @@ public void execute() { .orElseThrow(() -> new IllegalArgumentException("Cannot coerce \"%s\" into a semantic version.".formatted(currentVersion))); - getLog().info("Updating " + project.getFile() + " to " + pomVersion); + logger.info("Updating " + project.getFile() + " to " + pomVersion); PomUpdater.setProjectVersion(project.getFile(), pomVersion); // Update submodules to reference the parent project with the new version List modules = project.getModules(); modules.forEach(module -> { File modulePom = baseDir.resolve(module).resolve("pom.xml").toFile(); - getLog().info("Updating submodule" + modulePom + " to " + pomVersion); + logger.info("Updating submodule" + modulePom + " to " + pomVersion); PomUpdater.setProjectParentVersion(modulePom, pomVersion); }); } } - - private String getCurrentVersion() { - try { - Path versionFile = project.getBasedir().toPath().resolve(CHANGESET_DIR).resolve("VERSION"); - getLog().info("Reading version from " + versionFile); - return Files.readString(versionFile); - - } catch (NoSuchFileException exception) { - return "0.0.0"; - - } catch (IOException e) { - throw new RuntimeException(e); - } - } } diff --git a/changesets-maven-plugin/src/main/java/se/fortnox/changesets/maven/ReleaseMojo.java b/changesets-maven-plugin/src/main/java/se/fortnox/changesets/maven/ReleaseMojo.java index 1b151fa..fdaf90a 100644 --- a/changesets-maven-plugin/src/main/java/se/fortnox/changesets/maven/ReleaseMojo.java +++ b/changesets-maven-plugin/src/main/java/se/fortnox/changesets/maven/ReleaseMojo.java @@ -3,50 +3,41 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.logging.Logger; +import se.fortnox.changesets.VersionFile; +import javax.inject.Inject; import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.util.List; -import static se.fortnox.changesets.ChangesetWriter.CHANGESET_DIR; - @Mojo(name = "release", defaultPhase = LifecyclePhase.INITIALIZE, aggregator = true) public class ReleaseMojo extends AbstractMojo { - @Parameter(defaultValue = "${project}", readonly = true, required = true) - private MavenProject project; + private final MavenProject project; + private final VersionFile versionFile; + private final Logger log; + + @Inject + public ReleaseMojo(MavenProject project, VersionFile versionFile, Logger log) { + this.project = project; + this.versionFile = versionFile; + this.log = log; + } public void execute() { Path baseDir = project.getBasedir().toPath(); - String pomVersion = getCurrentVersion(); + String pomVersion = versionFile.currentVersion().orElse("0.0.0"); - getLog().info("Updating " + project.getFile() + " to " + pomVersion); + log.info("Updating " + project.getFile() + " to " + pomVersion); PomUpdater.setProjectVersion(project.getFile(), pomVersion); // Update submodules to reference the parent project with the new version List modules = project.getModules(); modules.forEach(module -> { File modulePom = baseDir.resolve(module).resolve("pom.xml").toFile(); - getLog().info("Updating submodule" + modulePom + " to " + pomVersion); + log.info("Updating submodule" + modulePom + " to " + pomVersion); PomUpdater.setProjectParentVersion(modulePom, pomVersion); }); } - - private String getCurrentVersion() { - try { - Path versionFile = project.getBasedir().toPath().resolve(CHANGESET_DIR).resolve("VERSION"); - getLog().info("Reading version from " + versionFile); - return Files.readString(versionFile); - - } catch (NoSuchFileException exception) { - return "0.0.0"; - - } catch (IOException e) { - throw new RuntimeException(e); - } - } } diff --git a/changesets-maven-plugin/src/main/java/se/fortnox/changesets/maven/policy/ChangesetsVersionPolicy.java b/changesets-maven-plugin/src/main/java/se/fortnox/changesets/maven/policy/ChangesetsVersionPolicy.java new file mode 100644 index 0000000..9b4082c --- /dev/null +++ b/changesets-maven-plugin/src/main/java/se/fortnox/changesets/maven/policy/ChangesetsVersionPolicy.java @@ -0,0 +1,61 @@ +package se.fortnox.changesets.maven.policy; + +import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.release.policy.PolicyException; +import org.apache.maven.shared.release.policy.version.VersionPolicy; +import org.apache.maven.shared.release.policy.version.VersionPolicyRequest; +import org.apache.maven.shared.release.policy.version.VersionPolicyResult; +import org.apache.maven.shared.release.versions.VersionParseException; +import org.codehaus.plexus.component.annotations.Component; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.inject.Inject; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import static se.fortnox.changesets.VersionCalculator.nextDevelopmentVersion; + +@Component(role = VersionPolicy.class, + hint = "changesets", + description = "A VersionPolicy implementation that uses changesets-java to calculate the current and next version.") +public class ChangesetsVersionPolicy implements VersionPolicy { + private final Logger logger = LoggerFactory.getLogger(getClass()); + public static final String CHANGESET_DIR = ".changeset"; + + private final MavenProject project; + + @Inject + public ChangesetsVersionPolicy(MavenProject project) { + this.project = project; + } + + @Override + public VersionPolicyResult getReleaseVersion(VersionPolicyRequest versionPolicyRequest) throws PolicyException, VersionParseException { + Path versionFile = project.getBasedir().toPath().resolve(CHANGESET_DIR).resolve("VERSION"); + logger.info("Reading version from " + versionFile); + try { + String version = Files.readString(versionFile); + return new VersionPolicyResult() + .setVersion(version); + } catch (IOException e) { + throw new RuntimeException(e); + } + + + } + + @Override + public VersionPolicyResult getDevelopmentVersion(VersionPolicyRequest versionPolicyRequest) throws PolicyException, VersionParseException { + Path versionFile = project.getBasedir().toPath().resolve(CHANGESET_DIR).resolve("VERSION"); + try { + String version = Files.readString(versionFile); + return new VersionPolicyResult() + .setVersion(nextDevelopmentVersion(version)); + } catch (IOException e) { + throw new RuntimeException(e); + } + + } +} diff --git a/pom.xml b/pom.xml index 910ea44..9c3c56b 100644 --- a/pom.xml +++ b/pom.xml @@ -1,324 +1,345 @@ - - 4.0.0 + 4.0.0 - se.fortnox.changesets - changesets - 0.1.1-SNAPSHOT - pom + se.fortnox.changesets + changesets + 0.1.1-SNAPSHOT + pom - Changesets Java - - This is an attempt to bring the changesets (https://github.com/changesets/changesets) way of working to the Java ecosystem, - to enable easier management of changelogs and semantically versioned releases. - - https://github.com/FortnoxAB/changesets-java + Changesets Java + + This is an attempt to bring the changesets (https://github.com/changesets/changesets) way of working to the Java ecosystem, + to enable easier management of changelogs and semantically versioned releases. + + https://github.com/FortnoxAB/changesets-java - - - MIT License - https://opensource.org/license/mit - - - - - Niklas Gärdebrand - info@fortnox.se - Fortnox AB - https://www.fortnox.se - - - Magnus Persson - info@fortnox.se - Fortnox AB - https://www.fortnox.se - - - - scm:git:git://github.com/FortnoxAB/changesets-java.git - scm:git:ssh://github.com:FortnoxAB/changesets-java.git - https://github.com/FortnoxAB/changesets-java/tree/main - + + + MIT License + https://opensource.org/license/mit + + + + + Niklas Gärdebrand + info@fortnox.se + Fortnox AB + https://www.fortnox.se + + + Magnus Persson + info@fortnox.se + Fortnox AB + https://www.fortnox.se + + + + scm:git:git://github.com/FortnoxAB/changesets-java.git + scm:git:ssh://github.com:FortnoxAB/changesets-java.git + https://github.com/FortnoxAB/changesets-java/tree/main + - - - central - Maven Central - https://central.sonatype.com/artifact/se.fortnox.changesets/changesets-java - - + + + central + Maven Central + https://central.sonatype.com/artifact/se.fortnox.changesets/changesets-java + + - - changesets-java - changesets-maven-plugin - + + changesets-java + changesets-maven-plugin + - - UTF-8 - 17 - 17 - 3.9.9 - 5.12.0 - 1.0.0 - 3.15.1 - + + UTF-8 + 17 + 17 + 3.9.9 + 5.12.0 + 1.0.0 + 3.15.1 + 0.3.5 + - - - - org.apache.maven - maven-plugin-api - ${maven.version} - provided - - - org.apache.maven - maven-core - ${maven.version} - provided - - - org.apache.maven - maven-artifact - ${maven.version} - provided - - - org.apache.maven - maven-compat - ${maven.version} - test - - - org.apache.maven.plugin-tools - maven-plugin-annotations - 3.15.1 - provided - - - org.slf4j - slf4j-api - 2.0.17 - - - org.semver4j - semver4j - 5.6.0 - - - org.codehaus.mojo.versions - versions-common - 2.18.0 - - - commons-io - commons-io - 2.18.0 - - - com.vladsch.flexmark - flexmark-all - 0.64.8 - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - 2.18.3 - - - org.mockito - mockito-core - 5.16.0 - test - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-params - ${junit-jupiter.version} - test - - - org.assertj - assertj-core - 3.27.3 - test - - - ch.qos.logback - logback-core - 1.5.17 - test - - - ch.qos.logback - logback-classic - 1.5.17 - test - + + + + org.apache.maven + maven-plugin-api + ${maven.version} + provided + + + org.apache.maven + maven-core + ${maven.version} + provided + + + org.apache.maven + maven-artifact + ${maven.version} + provided + + + org.apache.maven.shared + maven-shared-utils + 3.4.2 + + + org.apache.maven + maven-compat + ${maven.version} + test + + + org.apache.maven.plugin-tools + maven-plugin-annotations + 3.15.1 + provided + + + org.slf4j + slf4j-api + 2.0.17 + + + org.semver4j + semver4j + 5.6.0 + + + org.codehaus.mojo.versions + versions-common + 2.18.0 + + + commons-io + commons-io + 2.18.0 + + + org.apache.maven.release + maven-release-api + 3.1.1 + + + com.vladsch.flexmark + flexmark-all + 0.64.8 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + 2.18.3 + + + org.mockito + mockito-core + 5.16.0 + test + + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter.version} + test + + + org.junit.jupiter + junit-jupiter-params + ${junit-jupiter.version} + test + + + org.assertj + assertj-core + 3.27.3 + test + + + ch.qos.logback + logback-core + 1.5.17 + test + + + ch.qos.logback + logback-classic + 1.5.17 + test + - - io.hosuaby - inject-resources-core - ${inject-resources.version} - test - - - io.hosuaby - inject-resources-junit-jupiter - ${inject-resources.version} - test - - - + + io.hosuaby + inject-resources-core + ${inject-resources.version} + test + + + io.hosuaby + inject-resources-junit-jupiter + ${inject-resources.version} + test + + + - - - - - - maven-clean-plugin - 3.4.1 - - - maven-site-plugin - 3.21.0 - - true - - - - maven-project-info-reports-plugin - 3.9.0 - - - - maven-resources-plugin - 3.3.1 - - - maven-compiler-plugin - 3.14.0 - - - maven-plugin-plugin - ${maven-plugin-plugin.version} - - - maven-surefire-plugin - 3.5.2 - - - maven-jar-plugin - 3.4.2 - - - maven-install-plugin - 3.1.4 - - - maven-deploy-plugin - 3.1.4 - - - maven-invoker-plugin - 3.9.0 - - - com.diffplug.spotless - spotless-maven-plugin - 2.44.3 - - - + + + + + + maven-clean-plugin + 3.4.1 + + + maven-site-plugin + 3.21.0 + + true + + + + maven-project-info-reports-plugin + 3.9.0 + + + + maven-resources-plugin + 3.3.1 + + + maven-compiler-plugin + 3.14.0 + + + maven-plugin-plugin + ${maven-plugin-plugin.version} + + + maven-surefire-plugin + 3.5.2 + + + maven-jar-plugin + 3.4.2 + + + maven-install-plugin + 3.1.4 + + + maven-deploy-plugin + 3.1.4 + + + maven-invoker-plugin + 3.9.0 + + + com.diffplug.spotless + spotless-maven-plugin + 2.44.3 + + + - - - - - - org.apache.maven.plugins - maven-plugin-report-plugin - ${maven-plugin-plugin.version} - - - - + + + + + + org.apache.maven.plugins + maven-plugin-report-plugin + ${maven-plugin-plugin.version} + + + org.eclipse.sisu + sisu-maven-plugin + ${sisu-maven-plugin.version} + + + org.codehaus.plexus + plexus-component-metadata + 2.2.0 + + + + - - - - publish - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.11.2 - - - attach-javadocs - - jar - - - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.7 - - - sign-artifacts - verify - - sign - - - - - - --pinentry-mode - loopback - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.7.0 - true - - central - - false - - - - - - + + + + publish + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.11.2 + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.7 + + + sign-artifacts + verify + + sign + + + + + + --pinentry-mode + loopback + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.7.0 + true + + central + + false + + + + + +