Search in sources :

Example 21 with ArtifactCoordinates

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

the class CheckPluginDependencyVersions method getSnapshotsFromManagement.

private Multimap<ArtifactCoordinates, ArtifactCoordinates> getSnapshotsFromManagement(Profile profile, PomPropertyResolver propertyResolver) {
    this.log.debug("\t\tChecking managed plugins of profile '" + profile.getId() + "'");
    Multimap<ArtifactCoordinates, ArtifactCoordinates> result = HashMultimap.create();
    BuildBase build = profile.getBuild();
    if (build != null) {
        PluginManagement pluginManagement = build.getPluginManagement();
        if (pluginManagement != null) {
            for (Plugin plugin : pluginManagement.getPlugins()) {
                Collection<Dependency> snapshots = Collections2.filter(plugin.getDependencies(), new IsSnapshotDependency(propertyResolver));
                if (!snapshots.isEmpty()) {
                    result.putAll(PluginToCoordinates.INSTANCE.apply(plugin), Collections2.transform(snapshots, DependencyToCoordinates.INSTANCE));
                }
            }
        }
    }
    return result;
}
Also used : PluginManagement(org.apache.maven.model.PluginManagement) BuildBase(org.apache.maven.model.BuildBase) IsSnapshotDependency(com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotDependency) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) Dependency(org.apache.maven.model.Dependency) IsSnapshotDependency(com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotDependency) Plugin(org.apache.maven.model.Plugin)

Example 22 with ArtifactCoordinates

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

the class CheckPluginDependencyVersions method getSnapshotsFromManagement.

private Multimap<ArtifactCoordinates, ArtifactCoordinates> getSnapshotsFromManagement(MavenProject project, PomPropertyResolver propertyResolver) {
    this.log.debug("\t\tChecking managed plugins");
    Multimap<ArtifactCoordinates, ArtifactCoordinates> result = HashMultimap.create();
    Build build = project.getBuild();
    if (build != null) {
        PluginManagement pluginManagement = build.getPluginManagement();
        if (pluginManagement != null) {
            for (Plugin plugin : pluginManagement.getPlugins()) {
                Collection<Dependency> snapshots = Collections2.filter(plugin.getDependencies(), new IsSnapshotDependency(propertyResolver));
                if (!snapshots.isEmpty()) {
                    result.putAll(PluginToCoordinates.INSTANCE.apply(plugin), Collections2.transform(snapshots, DependencyToCoordinates.INSTANCE));
                }
            }
        }
    }
    return result;
}
Also used : PluginManagement(org.apache.maven.model.PluginManagement) Build(org.apache.maven.model.Build) IsSnapshotDependency(com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotDependency) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) Dependency(org.apache.maven.model.Dependency) IsSnapshotDependency(com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotDependency) Plugin(org.apache.maven.model.Plugin)

Example 23 with ArtifactCoordinates

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

the class CheckPluginDependencyVersions method getSnapshots.

private Multimap<ArtifactCoordinates, ArtifactCoordinates> getSnapshots(Profile profile, PomPropertyResolver propertyResolver) {
    this.log.debug("\t\tChecking direct plugin references of profile '" + profile.getId() + "'");
    Multimap<ArtifactCoordinates, ArtifactCoordinates> result = HashMultimap.create();
    BuildBase build = profile.getBuild();
    if (build != null) {
        for (Plugin plugin : build.getPlugins()) {
            Collection<Dependency> snapshots = Collections2.filter(plugin.getDependencies(), new IsSnapshotDependency(propertyResolver));
            if (!snapshots.isEmpty()) {
                result.putAll(PluginToCoordinates.INSTANCE.apply(plugin), Collections2.transform(snapshots, DependencyToCoordinates.INSTANCE));
            }
        }
    }
    return result;
}
Also used : BuildBase(org.apache.maven.model.BuildBase) IsSnapshotDependency(com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotDependency) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) Dependency(org.apache.maven.model.Dependency) IsSnapshotDependency(com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotDependency) Plugin(org.apache.maven.model.Plugin)

Example 24 with ArtifactCoordinates

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

the class CheckPluginDependencyVersions method failIfSnapshotsAreReferenced.

private void failIfSnapshotsAreReferenced(boolean hasSnapshots, Map<MavenProject, Multimap<ArtifactCoordinates, ArtifactCoordinates>> snapshotsByProjectAndPlugin, Map<MavenProject, PomPropertyResolver> propertyResolvers) throws MojoFailureException {
    if (hasSnapshots) {
        this.log.error("\tThere are plugins with SNAPSHOT dependencies! The following list contains all SNAPSHOT dependencies grouped by plugin and module:");
        for (MavenProject p : snapshotsByProjectAndPlugin.keySet()) {
            PomPropertyResolver propertyResolver = propertyResolvers.get(p);
            Multimap<ArtifactCoordinates, ArtifactCoordinates> snapshots = snapshotsByProjectAndPlugin.get(p);
            if (!snapshots.isEmpty()) {
                this.log.error("\t\t[PROJECT] " + ProjectToString.INSTANCE.apply(p));
                for (ArtifactCoordinates plugin : snapshots.keySet()) {
                    this.log.error("\t\t\t[PLUGIN] " + plugin);
                    for (ArtifactCoordinates dependency : snapshots.get(plugin)) {
                        String resolvedVersion = propertyResolver.expandPropertyReferences(dependency.getVersion());
                        String coordinates = dependency.toString();
                        if (!Objects.equal(resolvedVersion, dependency.getVersion())) {
                            coordinates = coordinates + " (resolves to " + resolvedVersion + ")";
                        }
                        this.log.error("\t\t\t\t[DEPENDENCY] " + coordinates);
                    }
                }
            }
        }
        throw new MojoFailureException("The project cannot be released due to one or more SNAPSHOT plugin-dependencies!");
    }
}
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 25 with ArtifactCoordinates

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

the class CheckPluginDependencyVersions method getSnapshotsFromAllProfiles.

// IDEA implement to use active profiles only (maybe create the effective pom using api with the release profiles)
private Multimap<ArtifactCoordinates, ArtifactCoordinates> getSnapshotsFromAllProfiles(MavenProject project, PomPropertyResolver propertyResolver) {
    Multimap<ArtifactCoordinates, ArtifactCoordinates> result = HashMultimap.create();
    List<Profile> profiles = project.getModel().getProfiles();
    if (profiles != null) {
        for (Profile profile : profiles) {
            result.putAll(getSnapshotsFromManagement(profile, propertyResolver));
            result.putAll(getSnapshots(profile, propertyResolver));
        }
    }
    return result;
}
Also used : ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) Profile(org.apache.maven.model.Profile)

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