Search in sources :

Example 86 with Plugin

use of org.apache.maven.model.Plugin in project sling by apache.

the class MavenProjectUtils method getModelDirectoryCandidateLocations.

/**
     * Returns a set of candidate locations for the project's model directory
     * 
     * <p>The heuristics are based on the logic from <tt>org.apache.sling.maven.slingstart.ModelPreprocessor</tt>.
     * The returned values may or may not exist on the filesystem, it is up to the client to check that.
     * The values are ordered from the most likely to the least likely, so clients should iterate
     * the returned candidates in order and pick the first one that exists.</p>
     * 
     * @param mavenProject the project, must not be null
     * @return an ordered set of candidates, never empty
     */
public static Set<String> getModelDirectoryCandidateLocations(MavenProject mavenProject) {
    List<String> candidates = new ArrayList<>();
    candidates.add("src/main/provisioning");
    candidates.add("src/test/provisioning");
    Plugin slingstartPlugin = mavenProject.getPlugin("org.apache.sling:slingstart-maven-plugin");
    if (slingstartPlugin != null && slingstartPlugin.getConfiguration() instanceof Xpp3Dom) {
        Xpp3Dom config = (Xpp3Dom) slingstartPlugin.getConfiguration();
        Xpp3Dom modelDir = config.getChild("modelDirectory");
        if (modelDir != null) {
            candidates.add(0, modelDir.getValue());
        }
    }
    return new LinkedHashSet<>(candidates);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) ArrayList(java.util.ArrayList) Plugin(org.apache.maven.model.Plugin)

Example 87 with Plugin

use of org.apache.maven.model.Plugin in project docker-maven-plugin by fabric8io.

the class MojoExecutionServiceTest method expectNewPlugin.

// ============================================================================================
private Expectations expectNewPlugin() {
    return new Expectations() {

        {
            project.getPlugin(PLUGIN_NAME);
            result = new Plugin();
        }
    };
}
Also used : Plugin(org.apache.maven.model.Plugin)

Example 88 with Plugin

use of org.apache.maven.model.Plugin in project kie-wb-common by kiegroup.

the class DefaultPomEditor method getNewCompilerPlugin.

protected Plugin getNewCompilerPlugin() {
    Plugin newCompilerPlugin = new Plugin();
    newCompilerPlugin.setGroupId(conf.get(ConfigurationKey.ALTERNATIVE_COMPILER_PLUGINS));
    newCompilerPlugin.setArtifactId(conf.get(ConfigurationKey.ALTERNATIVE_COMPILER_PLUGIN));
    newCompilerPlugin.setVersion(conf.get(ConfigurationKey.ALTERNATIVE_COMPILER_PLUGIN_VERSION));
    PluginExecution execution = new PluginExecution();
    execution.setId(MavenCLIArgs.COMPILE);
    execution.setGoals(Arrays.asList(MavenCLIArgs.COMPILE));
    execution.setPhase(MavenCLIArgs.COMPILE);
    Xpp3Dom compilerId = new Xpp3Dom(MavenConfig.MAVEN_COMPILER_ID);
    compilerId.setValue(compiler.name().toLowerCase());
    Xpp3Dom configuration = new Xpp3Dom(MavenConfig.MAVEN_PLUGIN_CONFIGURATION);
    configuration.addChild(compilerId);
    execution.setConfiguration(configuration);
    newCompilerPlugin.setExecutions(Arrays.asList(execution));
    return newCompilerPlugin;
}
Also used : PluginExecution(org.apache.maven.model.PluginExecution) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) Plugin(org.apache.maven.model.Plugin)

Example 89 with Plugin

use of org.apache.maven.model.Plugin in project felix by apache.

the class SCRDescriptorMojo method getBundlePlugin.

/**
 * We need the bundle plugin with a version higher than 2.5.0!
 */
private Plugin getBundlePlugin() {
    Plugin bundlePlugin = null;
    final List<Plugin> plugins = this.project.getBuildPlugins();
    for (final Plugin p : plugins) {
        if (p.getArtifactId().equals(BUNDLE_PLUGIN_ARTIFACT_ID) && p.getGroupId().equals(BUNDLE_PLUGIN_GROUP_ID)) {
            final ArtifactVersion pluginVersion = new DefaultArtifactVersion(p.getVersion());
            final ArtifactVersion requiredMinVersion = new DefaultArtifactVersion("2.5.0");
            if (pluginVersion.compareTo(requiredMinVersion) > 0) {
                bundlePlugin = p;
                break;
            }
        }
    }
    return bundlePlugin;
}
Also used : DefaultArtifactVersion(org.apache.maven.artifact.versioning.DefaultArtifactVersion) ArtifactVersion(org.apache.maven.artifact.versioning.ArtifactVersion) DefaultArtifactVersion(org.apache.maven.artifact.versioning.DefaultArtifactVersion) Plugin(org.apache.maven.model.Plugin)

Example 90 with Plugin

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

the class Project method getResolvedProfilePlugins.

/**
 * This method will scan the plugins 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>> getResolvedProfilePlugins(MavenSessionHandler session) throws ManipulationException {
    if (resolvedProfilePlugins == null) {
        resolvedProfilePlugins = new HashMap<>();
        for (final Profile profile : ProfileUtils.getProfiles(session, model)) {
            HashMap<ProjectVersionRef, Plugin> profileDeps = new HashMap<>();
            if (profile.getBuild() != null) {
                resolvePlugins(session, profile.getBuild().getPlugins(), profileDeps);
            }
            resolvedProfilePlugins.put(profile, profileDeps);
        }
    }
    return resolvedProfilePlugins;
}
Also used : 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)

Aggregations

Plugin (org.apache.maven.model.Plugin)140 Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)39 MavenProject (org.apache.maven.project.MavenProject)26 Build (org.apache.maven.model.Build)22 PluginExecution (org.apache.maven.model.PluginExecution)22 ArrayList (java.util.ArrayList)20 Dependency (org.apache.maven.model.Dependency)17 File (java.io.File)15 Model (org.apache.maven.model.Model)15 HashMap (java.util.HashMap)12 PluginDescriptor (org.apache.maven.plugin.descriptor.PluginDescriptor)12 CoreException (org.eclipse.core.runtime.CoreException)11 IOException (java.io.IOException)9 List (java.util.List)8 PluginManagement (org.apache.maven.model.PluginManagement)8 Map (java.util.Map)7 MavenSession (org.apache.maven.execution.MavenSession)7 ReportPlugin (org.apache.maven.model.ReportPlugin)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)6