Search in sources :

Example 1 with ReleasePhase

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);
    }
}
Also used : MavenProject(org.apache.maven.project.MavenProject) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ReleasePhase(com.itemis.maven.plugins.unleash.ReleasePhase) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) ProjectToString(com.itemis.maven.plugins.unleash.util.functions.ProjectToString) IOException(java.io.IOException) VersionsEngine(org.eclipse.tycho.versions.engine.VersionsEngine) Document(org.w3c.dom.Document)

Example 2 with ReleasePhase

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);
    });
}
Also used : PomFile(org.eclipse.tycho.versions.pom.PomFile) ReleasePhase(com.itemis.maven.plugins.unleash.ReleasePhase) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) ProjectToString(com.itemis.maven.plugins.unleash.util.functions.ProjectToString)

Example 3 with ReleasePhase

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!");
    }
}
Also used : MavenProject(org.apache.maven.project.MavenProject) MojoFailureException(org.apache.maven.plugin.MojoFailureException) ReleasePhase(com.itemis.maven.plugins.unleash.ReleasePhase) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) ProjectToString(com.itemis.maven.plugins.unleash.util.functions.ProjectToString)

Example 4 with ReleasePhase

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;
}
Also used : ReleasePhase(com.itemis.maven.plugins.unleash.ReleasePhase) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) ProjectToString(com.itemis.maven.plugins.unleash.util.functions.ProjectToString)

Example 5 with ReleasePhase

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);
}
Also used : ReleasePhase(com.itemis.maven.plugins.unleash.ReleasePhase) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) ProjectToString(com.itemis.maven.plugins.unleash.util.functions.ProjectToString)

Aggregations

ArtifactCoordinates (com.itemis.maven.aether.ArtifactCoordinates)9 ReleasePhase (com.itemis.maven.plugins.unleash.ReleasePhase)9 ProjectToString (com.itemis.maven.plugins.unleash.util.functions.ProjectToString)6 Parent (org.apache.maven.model.Parent)2 MavenProject (org.apache.maven.project.MavenProject)2 IOException (java.io.IOException)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1 VersionsEngine (org.eclipse.tycho.versions.engine.VersionsEngine)1 PomFile (org.eclipse.tycho.versions.pom.PomFile)1 Document (org.w3c.dom.Document)1