Search in sources :

Example 26 with ArtifactCoordinates

use of com.itemis.maven.aether.ArtifactCoordinates in project unleash-maven-plugin by shillner.

the class CheckPluginVersions method failIfSnapshotsAreReferenced.

private void failIfSnapshotsAreReferenced(Multimap<MavenProject, ArtifactCoordinates> snapshotsByProject, Map<MavenProject, PomPropertyResolver> propertyResolvers) throws MojoFailureException {
    if (!snapshotsByProject.values().isEmpty()) {
        this.log.error("\tThere are references to SNAPSHOT plugins! The following list contains all SNAPSHOT plugins grouped by module:");
        for (MavenProject project : snapshotsByProject.keySet()) {
            PomPropertyResolver propertyResolver = propertyResolvers.get(project);
            Collection<ArtifactCoordinates> snapshots = snapshotsByProject.get(project);
            if (!snapshots.isEmpty()) {
                this.log.error("\t\t[PROJECT] " + ProjectToString.INSTANCE.apply(project));
                for (ArtifactCoordinates plugin : snapshots) {
                    String resolvedVersion = propertyResolver.expandPropertyReferences(plugin.getVersion());
                    String coordinates = plugin.toString();
                    if (!Objects.equal(resolvedVersion, plugin.getVersion())) {
                        coordinates = coordinates + " (resolves to " + resolvedVersion + ")";
                    }
                    this.log.error("\t\t\t[PLUGIN] " + coordinates);
                }
            }
        }
        throw new MojoFailureException("The project cannot be released due to one or more SNAPSHOT plugins!");
    }
}
Also used : PomPropertyResolver(com.itemis.maven.plugins.unleash.util.PomPropertyResolver) MavenProject(org.apache.maven.project.MavenProject) MojoFailureException(org.apache.maven.plugin.MojoFailureException) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) ProjectToString(com.itemis.maven.plugins.unleash.util.functions.ProjectToString)

Example 27 with ArtifactCoordinates

use of com.itemis.maven.aether.ArtifactCoordinates in project unleash-maven-plugin by shillner.

the class CheckPluginVersions method execute.

@Override
public void execute(ExecutionContext context) throws MojoExecutionException, MojoFailureException {
    this.log.info("Checking that none of the reactor projects contains SNAPSHOT plugins.");
    Map<MavenProject, PomPropertyResolver> propertyResolvers = Maps.newHashMapWithExpectedSize(this.reactorProjects.size());
    Multimap<MavenProject, ArtifactCoordinates> snapshotsByProject = HashMultimap.create();
    for (MavenProject project : this.reactorProjects) {
        this.log.debug("\tChecking plugins of reactor project '" + ProjectToString.INSTANCE.apply(project) + "':");
        PomPropertyResolver propertyResolver = new PomPropertyResolver(project, this.settings, this.profiles, this.releaseArgs);
        propertyResolvers.put(project, propertyResolver);
        snapshotsByProject.putAll(project, getSnapshotsFromManagement(project, propertyResolver));
        snapshotsByProject.putAll(project, getSnapshots(project, propertyResolver));
        snapshotsByProject.putAll(project, getSnapshotsFromAllProfiles(project, propertyResolver));
        removePluginForIntegrationTests(snapshotsByProject);
    }
    failIfSnapshotsAreReferenced(snapshotsByProject, propertyResolvers);
}
Also used : PomPropertyResolver(com.itemis.maven.plugins.unleash.util.PomPropertyResolver) MavenProject(org.apache.maven.project.MavenProject) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates)

Example 28 with ArtifactCoordinates

use of com.itemis.maven.aether.ArtifactCoordinates in project unleash-maven-plugin by shillner.

the class ReleaseMetadata method addVersionInfo.

private void addVersionInfo(Properties p) {
    Map<ReleasePhase, ArtifactCoordinates> reactorCoordinates = getArtifactCoordinatesByPhase(this.project.getGroupId(), this.project.getArtifactId());
    if (reactorCoordinates != null) {
        ArtifactCoordinates preReleaseCoordinates = reactorCoordinates.get(ReleasePhase.PRE_RELEASE);
        ArtifactCoordinates releaseCoordinates = reactorCoordinates.get(ReleasePhase.RELEASE);
        ArtifactCoordinates postReleaseCoordinates = reactorCoordinates.get(ReleasePhase.POST_RELEASE);
        if (preReleaseCoordinates != null) {
            p.setProperty(PROPERTIES_KEY_VERSION_REACTOR_PRE_RELEASE, preReleaseCoordinates.getVersion());
        }
        if (releaseCoordinates != null) {
            p.setProperty(PROPERTIES_KEY_VERSION_REACTOR_RELEASE, releaseCoordinates.getVersion());
        }
        if (postReleaseCoordinates != null) {
            p.setProperty(PROPERTIES_KEY_VERSION_REACTOR_POST_RELEASE, postReleaseCoordinates.getVersion());
        }
    }
}
Also used : ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates)

Example 29 with ArtifactCoordinates

use of com.itemis.maven.aether.ArtifactCoordinates in project unleash-maven-plugin by shillner.

the class CalculateVersions method execute.

@Override
public void execute(ExecutionContext context) throws MojoExecutionException, MojoFailureException {
    this.log.info("Calculating required versions for all modules.");
    for (MavenProject project : this.reactorProjects) {
        this.log.info("\tVersions of module " + ProjectToString.EXCLUDE_VERSION.apply(project) + ":");
        ArtifactCoordinates preReleaseCoordinates = this.metadata.getArtifactCoordinatesByPhase(project.getGroupId(), project.getArtifactId()).get(ReleasePhase.PRE_RELEASE);
        this.log.info("\t\t" + ReleasePhase.PRE_RELEASE + " = " + preReleaseCoordinates.getVersion());
        Optional<Prompter> prompterToUse = this.settings.isInteractiveMode() ? Optional.of(this.prompter) : Optional.<Prompter>absent();
        String releaseVersion = calculateReleaseVersion(project.getVersion(), prompterToUse);
        ArtifactCoordinates releaseCoordinates = new ArtifactCoordinates(project.getGroupId(), project.getArtifactId(), releaseVersion, PomUtil.ARTIFACT_TYPE_POM);
        this.metadata.addArtifactCoordinates(releaseCoordinates, ReleasePhase.RELEASE);
        this.log.info("\t\t" + ReleasePhase.RELEASE + " = " + releaseVersion);
        String nextDevVersion = calculateDevelopmentVersion(project.getVersion(), prompterToUse);
        ArtifactCoordinates postReleaseCoordinates = new ArtifactCoordinates(project.getGroupId(), project.getArtifactId(), nextDevVersion, PomUtil.ARTIFACT_TYPE_POM);
        this.metadata.addArtifactCoordinates(postReleaseCoordinates, ReleasePhase.POST_RELEASE);
        this.log.info("\t\t" + ReleasePhase.POST_RELEASE + " = " + nextDevVersion);
    }
}
Also used : Prompter(org.codehaus.plexus.components.interactivity.Prompter) MavenProject(org.apache.maven.project.MavenProject) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) ProjectToString(com.itemis.maven.plugins.unleash.util.functions.ProjectToString)

Aggregations

ArtifactCoordinates (com.itemis.maven.aether.ArtifactCoordinates)29 ProjectToString (com.itemis.maven.plugins.unleash.util.functions.ProjectToString)12 MavenProject (org.apache.maven.project.MavenProject)11 ReleasePhase (com.itemis.maven.plugins.unleash.ReleasePhase)9 PomPropertyResolver (com.itemis.maven.plugins.unleash.util.PomPropertyResolver)6 IsSnapshotDependency (com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotDependency)6 Dependency (org.apache.maven.model.Dependency)6 Plugin (org.apache.maven.model.Plugin)4 MojoFailureException (org.apache.maven.plugin.MojoFailureException)4 Profile (org.apache.maven.model.Profile)3 ResolutionResult (com.itemis.maven.aether.ArtifactResolver.ResolutionResult)2 IOException (java.io.IOException)2 Build (org.apache.maven.model.Build)2 BuildBase (org.apache.maven.model.BuildBase)2 Parent (org.apache.maven.model.Parent)2 PluginManagement (org.apache.maven.model.PluginManagement)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 VersionsEngine (org.eclipse.tycho.versions.engine.VersionsEngine)2 Document (org.w3c.dom.Document)2 HashMultimap (com.google.common.collect.HashMultimap)1