Search in sources :

Example 96 with Plugin

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

the class PluginState method setRemoteRESTOverrides.

public void setRemoteRESTOverrides(Map<ArtifactRef, String> overrides) {
    for (ArtifactRef a : overrides.keySet()) {
        Plugin p = new Plugin();
        p.setGroupId(a.getGroupId());
        p.setArtifactId(a.getArtifactId());
        p.setVersion(overrides.get(a));
        remoteRESTplugins.add(p);
    }
}
Also used : ArtifactRef(org.commonjava.maven.atlas.ident.ref.ArtifactRef) Plugin(org.apache.maven.model.Plugin)

Example 97 with Plugin

use of org.apache.maven.model.Plugin in project meghanada-server by mopemope.

the class POMParser method parsePlugins.

private void parsePlugins(POMInfo pomInfo, Build build) {
    for (Plugin plugin : build.getPlugins()) {
        if (plugin.getArtifactId().equals("build-helper-maven-plugin")) {
            for (PluginExecution pluginExecution : plugin.getExecutions()) {
                Object conf = pluginExecution.getConfiguration();
                if (nonNull(conf) && conf instanceof Xpp3Dom) {
                    Xpp3Dom confDom = (Xpp3Dom) conf;
                    Xpp3Dom sources = confDom.getChild("sources");
                    if (nonNull(sources)) {
                        Xpp3Dom[] children = sources.getChildren();
                        if (nonNull(children)) {
                            for (Xpp3Dom s : sources.getChildren()) {
                                String value = s.getValue();
                                if (!Strings.isNullOrEmpty(value)) {
                                    pomInfo.sourceDirectory.add(normalize(pomInfo, value));
                                }
                            }
                        }
                    }
                }
            }
        }
        if (plugin.getArtifactId().equals("maven-compiler-plugin")) {
            Object conf = plugin.getConfiguration();
            if (nonNull(conf) && conf instanceof Xpp3Dom) {
                Xpp3Dom confDom = (Xpp3Dom) conf;
                Xpp3Dom source = confDom.getChild("source");
                if (nonNull(source)) {
                    pomInfo.compileSource = source.getValue();
                }
                Xpp3Dom target = confDom.getChild("target");
                if (nonNull(target)) {
                    pomInfo.compileTarget = target.getValue();
                }
            }
        }
    }
}
Also used : PluginExecution(org.apache.maven.model.PluginExecution) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) Plugin(org.apache.maven.model.Plugin)

Example 98 with Plugin

use of org.apache.maven.model.Plugin in project maven-git-versioning-extension by qoomon.

the class VersioningModelProcessor method addBuildPlugin.

private void addBuildPlugin(Model model) {
    GAV projectGav = GAV.of(model);
    logger.debug(projectGav + " temporary add build plugin");
    if (model.getBuild() == null) {
        model.setBuild(new Build());
    }
    Plugin projectPlugin = VersioningPomReplacementMojo.asPlugin();
    PluginExecution execution = new PluginExecution();
    execution.setId(VersioningPomReplacementMojo.GOAL);
    execution.getGoals().add(VersioningPomReplacementMojo.GOAL);
    projectPlugin.getExecutions().add(execution);
    model.getBuild().getPlugins().add(projectPlugin);
}
Also used : PluginExecution(org.apache.maven.model.PluginExecution) Build(org.apache.maven.model.Build) GAV(com.qoomon.maven.GAV) Plugin(org.apache.maven.model.Plugin)

Example 99 with Plugin

use of org.apache.maven.model.Plugin in project liferay-ide by liferay.

the class MavenUtil method executeMojoGoal.

public static IStatus executeMojoGoal(IMavenProjectFacade facade, IMavenExecutionContext context, String goal, IProgressMonitor monitor) throws CoreException {
    IStatus retval = null;
    IMaven maven = MavenPlugin.getMaven();
    List<String> goals = Collections.singletonList(goal);
    MavenProject mavenProject = facade.getMavenProject(monitor);
    MavenExecutionPlan plan = maven.calculateExecutionPlan(mavenProject, goals, true, monitor);
    Plugin plugin6x = getPlugin(facade, ILiferayMavenConstants.LIFERAY_MAVEN_PLUGIN_KEY, monitor);
    String executionArtifactId = null;
    if (plugin6x != null) {
        executionArtifactId = ILiferayMavenConstants.LIFERAY_MAVEN_PLUGIN_ARTIFACT_ID;
    } else {
        Plugin plugin7x = getPlugin(facade, ILiferayMavenConstants.SERVICE_BUILDER_PLUGIN_KEY, monitor);
        if (plugin7x != null) {
            executionArtifactId = ILiferayMavenConstants.SERVICE_BUILDER_PLUGIN_ARTIFACT_ID;
        }
    }
    MojoExecution liferayMojoExecution = getExecution(plan, executionArtifactId);
    if (liferayMojoExecution != null) {
        ResolverConfiguration configuration = facade.getResolverConfiguration();
        configuration.setResolveWorkspaceProjects(true);
        maven.execute(mavenProject, liferayMojoExecution, monitor);
    }
    MavenSession session = context.getSession();
    List<Throwable> exceptions = session.getResult().getExceptions();
    if (exceptions.size() == 1) {
        retval = LiferayMavenCore.createErrorStatus(exceptions.get(0));
    } else if (exceptions.size() > 1) {
        List<IStatus> statues = new ArrayList<>();
        for (Throwable t : exceptions) {
            statues.add(LiferayMavenCore.createErrorStatus(t));
        }
        IStatus firstStatus = statues.get(0);
        retval = new MultiStatus(LiferayMavenCore.PLUGIN_ID, IStatus.ERROR, statues.toArray(new IStatus[0]), firstStatus.getMessage(), firstStatus.getException());
    }
    if (retval == null) {
        return Status.OK_STATUS;
    }
    return retval;
}
Also used : ResolverConfiguration(org.eclipse.m2e.core.project.ResolverConfiguration) IStatus(org.eclipse.core.runtime.IStatus) MultiStatus(org.eclipse.core.runtime.MultiStatus) MavenSession(org.apache.maven.execution.MavenSession) MavenProject(org.apache.maven.project.MavenProject) MojoExecution(org.apache.maven.plugin.MojoExecution) List(java.util.List) ArrayList(java.util.ArrayList) MavenExecutionPlan(org.apache.maven.lifecycle.MavenExecutionPlan) IMaven(org.eclipse.m2e.core.embedder.IMaven) Plugin(org.apache.maven.model.Plugin) MavenPlugin(org.eclipse.m2e.core.MavenPlugin)

Example 100 with Plugin

use of org.apache.maven.model.Plugin in project liferay-ide by liferay.

the class LiferayMavenProject method getLiferayMavenPluginVersion.

public String getLiferayMavenPluginVersion() {
    String retval = null;
    IMavenProjectFacade projectFacade = MavenPlugin.getMavenProjectRegistry().getProject(getProject());
    if (projectFacade != null) {
        try {
            NullProgressMonitor npm = new NullProgressMonitor();
            MavenProject mavenProject = projectFacade.getMavenProject(npm);
            if (mavenProject != null) {
                Plugin liferayMavenPlugin = MavenUtil.getPlugin(projectFacade, ILiferayMavenConstants.LIFERAY_MAVEN_PLUGIN_KEY, npm);
                retval = liferayMavenPlugin.getVersion();
            }
        } catch (CoreException ce) {
        }
    }
    return retval;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) MavenProject(org.apache.maven.project.MavenProject) CoreException(org.eclipse.core.runtime.CoreException) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) Plugin(org.apache.maven.model.Plugin) MavenPlugin(org.eclipse.m2e.core.MavenPlugin) MavenJdtPlugin(org.eclipse.m2e.jdt.MavenJdtPlugin)

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