Search in sources :

Example 6 with PluginManagement

use of org.apache.maven.model.PluginManagement in project pom-manipulation-ext by release-engineering.

the class Project method getResolvedProfileManagedPlugins.

/**
 * This method will scan the plugins in the pluginManagement section in the potentially active Profiles
 * in this project and return a fully resolved list. Note that while updating the {@link Plugin}
 * reference returned will be reflected in the Model as it is the same object, if you wish to remove
 * or add items to the Model then you must use {@link #getModel()}
 *
 * @param session MavenSessionHandler, used by {@link PropertyResolver}
 * @return a list of fully resolved {@link ProjectVersionRef} to the original {@link Plugin}
 * @throws ManipulationException if an error occurs
 */
public HashMap<Profile, HashMap<ProjectVersionRef, Plugin>> getResolvedProfileManagedPlugins(MavenSessionHandler session) throws ManipulationException {
    if (resolvedProfileManagedPlugins == null) {
        resolvedProfileManagedPlugins = new HashMap<>();
        for (final Profile profile : ProfileUtils.getProfiles(session, model)) {
            HashMap<ProjectVersionRef, Plugin> profileDeps = new HashMap<>();
            if (profile.getBuild() != null) {
                final PluginManagement pm = profile.getBuild().getPluginManagement();
                if (!(pm == null || pm.getPlugins() == null)) {
                    resolvePlugins(session, pm.getPlugins(), profileDeps);
                }
            }
            resolvedProfileManagedPlugins.put(profile, profileDeps);
        }
    }
    return resolvedProfileManagedPlugins;
}
Also used : PluginManagement(org.apache.maven.model.PluginManagement) HashMap(java.util.HashMap) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) Profile(org.apache.maven.model.Profile) Plugin(org.apache.maven.model.Plugin)

Example 7 with PluginManagement

use of org.apache.maven.model.PluginManagement 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 8 with PluginManagement

use of org.apache.maven.model.PluginManagement 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 9 with PluginManagement

use of org.apache.maven.model.PluginManagement in project maven-plugins by apache.

the class CheckstyleViolationCheckMojo method collectArtifacts.

private List<Artifact> collectArtifacts(String hint) {
    List<Artifact> artifacts = new ArrayList<>();
    PluginManagement pluginManagement = project.getBuild().getPluginManagement();
    if (pluginManagement != null) {
        artifacts.addAll(getCheckstylePluginDependenciesAsArtifacts(pluginManagement.getPluginsAsMap(), hint));
    }
    artifacts.addAll(getCheckstylePluginDependenciesAsArtifacts(project.getBuild().getPluginsAsMap(), hint));
    return artifacts;
}
Also used : PluginManagement(org.apache.maven.model.PluginManagement) ArrayList(java.util.ArrayList) Artifact(org.apache.maven.artifact.Artifact)

Example 10 with PluginManagement

use of org.apache.maven.model.PluginManagement in project maven-plugins by apache.

the class AbstractCheckstyleReport method collectArtifacts.

private List<Artifact> collectArtifacts(String hint) {
    List<Artifact> artifacts = new ArrayList<>();
    PluginManagement pluginManagement = project.getBuild().getPluginManagement();
    if (pluginManagement != null) {
        artifacts.addAll(getCheckstylePluginDependenciesAsArtifacts(pluginManagement.getPluginsAsMap(), hint));
    }
    artifacts.addAll(getCheckstylePluginDependenciesAsArtifacts(project.getBuild().getPluginsAsMap(), hint));
    return artifacts;
}
Also used : PluginManagement(org.apache.maven.model.PluginManagement) ArrayList(java.util.ArrayList) Artifact(org.apache.maven.artifact.Artifact)

Aggregations

PluginManagement (org.apache.maven.model.PluginManagement)12 Plugin (org.apache.maven.model.Plugin)8 Build (org.apache.maven.model.Build)7 ArtifactCoordinates (com.itemis.maven.aether.ArtifactCoordinates)2 IsSnapshotDependency (com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotDependency)2 IsSnapshotPlugin (com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotPlugin)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Artifact (org.apache.maven.artifact.Artifact)2 BuildBase (org.apache.maven.model.BuildBase)2 Dependency (org.apache.maven.model.Dependency)2 Model (org.apache.maven.model.Model)2 Profile (org.apache.maven.model.Profile)2 File (java.io.File)1 LinkedHashMap (java.util.LinkedHashMap)1 Extension (org.apache.maven.model.Extension)1 MavenProject (org.apache.maven.project.MavenProject)1 Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)1 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)1 SimpleProjectVersionRef (org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef)1