Search in sources :

Example 1 with PluginManagement

use of org.apache.maven.model.PluginManagement in project unleash-maven-plugin by shillner.

the class CheckPluginVersions method getSnapshotsFromManagement.

private Set<ArtifactCoordinates> getSnapshotsFromManagement(MavenProject project, PomPropertyResolver propertyResolver) {
    this.log.debug("\t\tChecking managed plugins");
    Build build = project.getBuild();
    if (build != null) {
        PluginManagement pluginManagement = build.getPluginManagement();
        if (pluginManagement != null) {
            Collection<Plugin> snapshots = Collections2.filter(pluginManagement.getPlugins(), new IsSnapshotPlugin(propertyResolver));
            return Sets.newHashSet(Collections2.transform(snapshots, PluginToCoordinates.INSTANCE));
        }
    }
    return Collections.emptySet();
}
Also used : PluginManagement(org.apache.maven.model.PluginManagement) Build(org.apache.maven.model.Build) IsSnapshotPlugin(com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotPlugin) IsSnapshotPlugin(com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotPlugin) Plugin(org.apache.maven.model.Plugin)

Example 2 with PluginManagement

use of org.apache.maven.model.PluginManagement in project unleash-maven-plugin by shillner.

the class CheckPluginVersions method getSnapshotsFromManagement.

private Set<ArtifactCoordinates> getSnapshotsFromManagement(Profile profile, PomPropertyResolver propertyResolver) {
    this.log.debug("\t\tChecking managed plugins of profile '" + profile.getId() + "'");
    BuildBase build = profile.getBuild();
    if (build != null) {
        PluginManagement pluginManagement = build.getPluginManagement();
        if (pluginManagement != null) {
            Collection<Plugin> snapshots = Collections2.filter(pluginManagement.getPlugins(), new IsSnapshotPlugin(propertyResolver));
            return Sets.newHashSet(Collections2.transform(snapshots, PluginToCoordinates.INSTANCE));
        }
    }
    return Collections.emptySet();
}
Also used : PluginManagement(org.apache.maven.model.PluginManagement) BuildBase(org.apache.maven.model.BuildBase) IsSnapshotPlugin(com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotPlugin) IsSnapshotPlugin(com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotPlugin) Plugin(org.apache.maven.model.Plugin)

Example 3 with PluginManagement

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

the class DistributionEnforcingManipulator method getManagedPluginMap.

private Map<String, Plugin> getManagedPluginMap(final ModelBase base) {
    if (base instanceof Model) {
        final Build build = ((Model) base).getBuild();
        if (build == null) {
            return Collections.emptyMap();
        }
        final PluginManagement pm = build.getPluginManagement();
        if (pm == null) {
            return Collections.emptyMap();
        }
        final Map<String, Plugin> result = pm.getPluginsAsMap();
        if (result == null) {
            return Collections.emptyMap();
        }
        return result;
    }
    return Collections.emptyMap();
}
Also used : PluginManagement(org.apache.maven.model.PluginManagement) Build(org.apache.maven.model.Build) Model(org.apache.maven.model.Model) Plugin(org.apache.maven.model.Plugin)

Example 4 with PluginManagement

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

the class PluginManipulator method apply.

private void apply(final Project project, final Model model, PluginType type, final Set<Plugin> override) throws ManipulationException {
    logger.info("Applying plugin changes for {} to: {} ", type, ga(project));
    if (project.isInheritanceRoot()) {
        // If the model doesn't have any plugin management set by default, create one for it
        Build build = model.getBuild();
        if (build == null) {
            build = new Build();
            model.setBuild(build);
            logger.debug("Created new Build for model " + model.getId());
        }
        PluginManagement pluginManagement = model.getBuild().getPluginManagement();
        if (pluginManagement == null) {
            pluginManagement = new PluginManagement();
            model.getBuild().setPluginManagement(pluginManagement);
            logger.debug("Created new Plugin Management for model " + model.getId());
        }
        // Override plugin management versions
        applyOverrides(project, type, PluginType.LocalPM, project.getResolvedManagedPlugins(session), override);
    }
    applyOverrides(project, type, PluginType.LocalP, project.getResolvedPlugins(session), override);
    final HashMap<Profile, HashMap<ProjectVersionRef, Plugin>> pd = project.getResolvedProfilePlugins(session);
    final HashMap<Profile, HashMap<ProjectVersionRef, Plugin>> pmd = project.getResolvedProfileManagedPlugins(session);
    logger.debug("Processing profiles with plugin management");
    for (Profile p : pmd.keySet()) {
        applyOverrides(project, type, PluginType.LocalPM, pmd.get(p), override);
    }
    logger.debug("Processing profiles with plugins");
    for (Profile p : pd.keySet()) {
        applyOverrides(project, type, PluginType.LocalP, pd.get(p), override);
    }
}
Also used : PluginManagement(org.apache.maven.model.PluginManagement) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Build(org.apache.maven.model.Build) Profile(org.apache.maven.model.Profile)

Example 5 with PluginManagement

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

the class ProjectInfoProjectStub method getPluginManagement.

@Override
public PluginManagement getPluginManagement() {
    PluginManagement pluginMgmt = null;
    Build build = model.getBuild();
    if (build != null) {
        pluginMgmt = build.getPluginManagement();
    }
    return pluginMgmt;
}
Also used : PluginManagement(org.apache.maven.model.PluginManagement) Build(org.apache.maven.model.Build)

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