Skip to content

Commit

Permalink
Restore PrepareMojo
Browse files Browse the repository at this point in the history
  • Loading branch information
magnusp committed Jan 16, 2025
1 parent 2544b63 commit 493aa31
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
import se.fortnox.changesets.ChangesetLocator;
import se.fortnox.changesets.VersionCalculator;

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;

Expand Down Expand Up @@ -56,6 +58,25 @@ public void execute() {
} catch (IOException e) {
throw new RuntimeException(e);
}

// Set newVersion property to be used by versions:set
if (!newVersion.equals(currentVersion)) {
String pomVersion = Optional.ofNullable(Semver.coerce(newVersion))
.map(semver -> semver.withIncPatch().withPreRelease("SNAPSHOT").getVersion())
.orElseThrow(() -> new IllegalArgumentException("Cannot coerce \"%s\" into a semantic version.".formatted(currentVersion)));


getLog().info("Updating " + project.getFile() + " to " + pomVersion);
PomUpdater.setProjectVersion(project.getFile(), pomVersion);

// Update submodules to reference the parent project with the new version
List<String> modules = project.getModules();
modules.forEach(module -> {
File modulePom = baseDir.resolve(module).resolve("pom.xml").toFile();
getLog().info("Updating submodule" + modulePom + " to " + pomVersion);
PomUpdater.setProjectParentVersion(modulePom, pomVersion);
});
}
}

private String getCurrentVersion() {
Expand Down

0 comments on commit 493aa31

Please sign in to comment.