use of com.itemis.maven.plugins.unleash.ReleasePhase in project unleash-maven-plugin by shillner.
the class AbstractTychoVersionsStep method execute.
@Override
public void execute(ExecutionContext context) throws MojoExecutionException, MojoFailureException {
this.cachedPOMs = Maps.newHashMap();
this.cachedModuleVersions = Maps.newHashMap();
VersionsEngine versionsEngine = initializeVersionsEngine();
try {
for (MavenProject module : this.reactorProjects) {
ArtifactCoordinates coordinates = ProjectToCoordinates.EMPTY_VERSION.apply(module);
Optional<Document> parsedPOM = PomUtil.parsePOM(this.project);
if (parsedPOM.isPresent()) {
this.cachedPOMs.put(coordinates, parsedPOM.get());
}
this.cachedModuleVersions.put(coordinates, module.getVersion());
Map<ReleasePhase, ArtifactCoordinates> coordinatesByPhase = this.metadata.getArtifactCoordinatesByPhase(module.getGroupId(), module.getArtifactId());
String version = coordinatesByPhase.get(currentReleasePhase()).getVersion();
versionsEngine.addVersionChange(module.getArtifactId(), version);
if (module.getModel().getVersion() != null) {
module.getModel().setVersion(version);
}
}
versionsEngine.apply();
adaptProjectMetadataWithNewVersions();
} catch (IOException e) {
throw new MojoExecutionException("Error during tycho version upgrade.", e);
}
}
use of com.itemis.maven.plugins.unleash.ReleasePhase in project unleash-maven-plugin by shillner.
the class AbstractTychoVersionsStep method adaptProjectMetadataWithNewVersions.
private void adaptProjectMetadataWithNewVersions() {
// this needs to be done in order to make the changes reversible
// if the metadata is not adapted reverting the changes wouldn't be possible for pom-less builds since the metadata
// is initialized only once before the build starts
this.metadataReader.getProjects().forEach(data -> {
PomFile pom = data.getMetadata(PomFile.class);
Map<ReleasePhase, ArtifactCoordinates> coordinatesByPhase = this.metadata.getArtifactCoordinatesByPhase(pom.getGroupId(), pom.getArtifactId());
String version = coordinatesByPhase.get(currentReleasePhase()).getVersion();
pom.setVersion(version);
});
}
use of com.itemis.maven.plugins.unleash.ReleasePhase in project unleash-maven-plugin by shillner.
the class CheckParentVersions method execute.
@Override
public void execute(ExecutionContext context) throws MojoExecutionException, MojoFailureException {
this.log.info("Checking that the project modules do not reference SNAPSHOT parents that are not scheduled for release.");
Map<String, String> snapshotParentReferences = Maps.newHashMap();
for (MavenProject p : this.reactorProjects) {
MavenProject parent = p.getParent();
if (parent != null && IsSnapshotProject.INSTANCE.apply(parent)) {
Map<ReleasePhase, ArtifactCoordinates> coordinatesByPhase = this.metadata.getArtifactCoordinatesByPhase(parent.getGroupId(), parent.getArtifactId());
ArtifactCoordinates coordinates = coordinatesByPhase.get(ReleasePhase.PRE_RELEASE);
if (coordinates != null && Objects.equal(parent.getVersion(), coordinates.getVersion())) {
this.log.debug("\tModule '" + ProjectToString.INSTANCE.apply(p) + "' references SNAPSHOT parent '" + ProjectToString.INSTANCE.apply(parent) + "' which is also scheduled for release.");
} else {
snapshotParentReferences.put(ProjectToString.INSTANCE.apply(p), ProjectToString.INSTANCE.apply(parent));
}
}
}
if (!snapshotParentReferences.isEmpty()) {
this.log.error("\tThe following modules have references to SNAPSHOT parents that are not scheduled for release:");
for (String projectCoordinates : snapshotParentReferences.keySet()) {
this.log.error("\t\t" + projectCoordinates + " => " + snapshotParentReferences.get(projectCoordinates));
}
throw new MojoFailureException("There are modules that reference SNAPSHOT parents which are not scheduled for release!");
}
}
use of com.itemis.maven.plugins.unleash.ReleasePhase in project unleash-maven-plugin by shillner.
the class DetectReleaseArtifacts method wasFixedVersion.
private boolean wasFixedVersion(MavenProject p) {
Map<ReleasePhase, ArtifactCoordinates> coordinatesByPhase = this.metadata.getArtifactCoordinatesByPhase(p.getGroupId(), p.getArtifactId());
String preReleaseVersion = coordinatesByPhase.get(ReleasePhase.PRE_RELEASE).getVersion();
String releaseVersion = coordinatesByPhase.get(ReleasePhase.RELEASE).getVersion();
if (Objects.equal(preReleaseVersion, releaseVersion)) {
return true;
}
return false;
}
use of com.itemis.maven.plugins.unleash.ReleasePhase in project unleash-maven-plugin by shillner.
the class SetNextDevVersion method setProjectVersion.
private void setProjectVersion(MavenProject project, Document document) {
Map<ReleasePhase, ArtifactCoordinates> coordinatesByPhase = this.metadata.getArtifactCoordinatesByPhase(project.getGroupId(), project.getArtifactId());
String oldVerion = coordinatesByPhase.get(ReleasePhase.RELEASE).getVersion();
String newVersion = coordinatesByPhase.get(ReleasePhase.POST_RELEASE).getVersion();
this.log.debug("\t\tUpdate of module version '" + project.getGroupId() + ":" + project.getArtifact() + "' [" + oldVerion + " => " + newVersion + "] Version Upgrade Strategy: " + this.versionUpgradeStrategy.name());
PomUtil.setProjectVersion(project.getModel(), document, newVersion);
}
Aggregations