Search in sources :

Example 6 with PomPropertyResolver

use of com.itemis.maven.plugins.unleash.util.PomPropertyResolver 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 7 with PomPropertyResolver

use of com.itemis.maven.plugins.unleash.util.PomPropertyResolver 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)

Aggregations

PomPropertyResolver (com.itemis.maven.plugins.unleash.util.PomPropertyResolver)7 MavenProject (org.apache.maven.project.MavenProject)7 ArtifactCoordinates (com.itemis.maven.aether.ArtifactCoordinates)6 ProjectToString (com.itemis.maven.plugins.unleash.util.functions.ProjectToString)3 MojoFailureException (org.apache.maven.plugin.MojoFailureException)3 HashMultimap (com.google.common.collect.HashMultimap)1 Multimap (com.google.common.collect.Multimap)1 PostConstruct (javax.annotation.PostConstruct)1 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)1 Document (org.w3c.dom.Document)1