Search in sources :

Example 16 with PluginExecution

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

the class MavenAPIUtil method disableMavenCompilerAlreadyPresent.

public static void disableMavenCompilerAlreadyPresent(Plugin plugin) {
    Xpp3Dom skipMain = new Xpp3Dom(MavenConfig.MAVEN_SKIP_MAIN);
    skipMain.setValue(TRUE);
    Xpp3Dom skip = new Xpp3Dom(MavenConfig.MAVEN_SKIP);
    skip.setValue(TRUE);
    Xpp3Dom configuration = new Xpp3Dom(MavenConfig.MAVEN_PLUGIN_CONFIGURATION);
    configuration.addChild(skipMain);
    configuration.addChild(skip);
    plugin.setConfiguration(configuration);
    PluginExecution exec = new PluginExecution();
    exec.setId(MavenConfig.MAVEN_DEFAULT_COMPILE);
    exec.setPhase(MavenConfig.MAVEN_PHASE_NONE);
    List<PluginExecution> executions = new ArrayList<>();
    executions.add(exec);
    plugin.setExecutions(executions);
}
Also used : PluginExecution(org.apache.maven.model.PluginExecution) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) ArrayList(java.util.ArrayList)

Example 17 with PluginExecution

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

the class MavenAPIUtil method getNewCompilerPlugin.

public static Plugin getNewCompilerPlugin(Map<ConfigurationKey, String> conf) {
    Plugin newCompilerPlugin = new Plugin();
    newCompilerPlugin.setGroupId(conf.get(ConfigurationKey.TAKARI_COMPILER_PLUGIN_GROUP));
    newCompilerPlugin.setArtifactId(conf.get(ConfigurationKey.TAKARI_COMPILER_PLUGIN_ARTIFACT));
    newCompilerPlugin.setVersion(conf.get(ConfigurationKey.TAKARI_COMPILER_PLUGIN_VERSION));
    Xpp3Dom compilerId = new Xpp3Dom(MavenConfig.MAVEN_COMPILER_ID);
    compilerId.setValue(conf.get(ConfigurationKey.COMPILER));
    Xpp3Dom sourceVersion = new Xpp3Dom(MavenConfig.MAVEN_SOURCE);
    sourceVersion.setValue(conf.get(ConfigurationKey.SOURCE_VERSION));
    Xpp3Dom targetVersion = new Xpp3Dom(MavenConfig.MAVEN_TARGET);
    targetVersion.setValue(conf.get(ConfigurationKey.TARGET_VERSION));
    Xpp3Dom failOnError = new Xpp3Dom(MavenConfig.FAIL_ON_ERROR);
    failOnError.setValue(conf.get(ConfigurationKey.FAIL_ON_ERROR));
    Xpp3Dom configuration = new Xpp3Dom(MavenConfig.MAVEN_PLUGIN_CONFIGURATION);
    configuration.addChild(compilerId);
    configuration.addChild(sourceVersion);
    configuration.addChild(targetVersion);
    configuration.addChild(failOnError);
    newCompilerPlugin.setConfiguration(configuration);
    PluginExecution execution = new PluginExecution();
    execution.setId(MavenCLIArgs.DEFAULT_COMPILE);
    execution.setGoals(Arrays.asList(MavenCLIArgs.COMPILE));
    execution.setPhase(MavenCLIArgs.COMPILE);
    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 18 with PluginExecution

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

the class MavenBundlePluginProjectConfigurator method isSupportingM2eIncrementalBuild.

@Override
protected boolean isSupportingM2eIncrementalBuild(MavenProject mavenProject, Logger logger) {
    Plugin bundlePlugin = mavenProject.getPlugin(MAVEN_BUNDLE_PLUGIN_KEY);
    if (bundlePlugin == null) {
        logger.warn("maven-bundle-plugin not configured!");
        return false;
    } else {
        // check if m2elipse-tycho is already installed (which supports incremental builds for "bundle" packagings
        if (LifecycleMappingFactory.createProjectConfigurator(M2E_TYCHO_EXTENSION_PROJECT_CONFIGURATOR_ID) != null) {
            logger.trace("Project configurator with id '" + M2E_TYCHO_EXTENSION_PROJECT_CONFIGURATOR_ID + "' found -> m2e-tycho installed.");
            return true;
        }
        String version = bundlePlugin.getVersion();
        if (version == null) {
            logger.warn("Could not retrieve used version of maven-bundle-plugin!");
            return false;
        }
        ComparableVersion comparableVersion = new ComparableVersion(version);
        // with https://issues.apache.org/jira/browse/FELIX-4009 m2e support for incremental builds was added to maven-bundle-plugin in version 3.2.0
        if (comparableVersion.compareTo(new ComparableVersion("3.2.0")) >= 0) {
            // therefore check configuration
            for (PluginExecution pluginExecution : bundlePlugin.getExecutions()) {
                if (!pluginExecution.getGoals().contains("manifest")) {
                    continue;
                }
                Xpp3Dom configuration = (Xpp3Dom) pluginExecution.getConfiguration();
                Xpp3Dom supportIncrementalBuildConfiguration = configuration.getChild("supportIncrementalBuild");
                // https://issues.apache.org/jira/browse/FELIX-3324
                Xpp3Dom exportScrConfiguration = configuration.getChild("exportScr");
                if (supportIncrementalBuildConfiguration == null || !Boolean.parseBoolean(supportIncrementalBuildConfiguration.getValue())) {
                    logger.warn("Although using maven-bundle-plugin in a version >= 3.2.0, the incremental build support was not enabled.");
                } else if (exportScrConfiguration == null || !Boolean.parseBoolean(exportScrConfiguration.getValue())) {
                    logger.warn("Although using maven-bundle-plugin in a version >= 3.2.0 with incremental build support enabled, component descriptors are not exported (exportScr=false) .");
                } else {
                    logger.trace("Using maven-bundle-plugin in a version >= 3.2.0 with the incremental build support correctly enabled.");
                    return true;
                }
            }
        } else {
            logger.warn("maven-bundle-plugin in a version < 3.2.0 does not natively support incremental builds.");
        }
    }
    return false;
}
Also used : PluginExecution(org.apache.maven.model.PluginExecution) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) ComparableVersion(org.apache.maven.artifact.versioning.ComparableVersion) Plugin(org.apache.maven.model.Plugin)

Example 19 with PluginExecution

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

the class DefaultPomEditor method disableMavenCompilerAlreadyPresent.

protected void disableMavenCompilerAlreadyPresent(Plugin plugin) {
    Xpp3Dom skipMain = new Xpp3Dom(MavenConfig.MAVEN_SKIP_MAIN);
    skipMain.setValue(TRUE);
    Xpp3Dom skip = new Xpp3Dom(MavenConfig.MAVEN_SKIP);
    skip.setValue(TRUE);
    Xpp3Dom configuration = new Xpp3Dom(MavenConfig.MAVEN_PLUGIN_CONFIGURATION);
    configuration.addChild(skipMain);
    configuration.addChild(skip);
    plugin.setConfiguration(configuration);
    PluginExecution exec = new PluginExecution();
    exec.setId(MavenConfig.MAVEN_DEFAULT_COMPILE);
    exec.setPhase(MavenConfig.MAVEN_PHASE_NONE);
    List<PluginExecution> executions = new ArrayList<>();
    executions.add(exec);
    plugin.setExecutions(executions);
}
Also used : PluginExecution(org.apache.maven.model.PluginExecution) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) ArrayList(java.util.ArrayList)

Example 20 with PluginExecution

use of org.apache.maven.model.PluginExecution 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)

Aggregations

PluginExecution (org.apache.maven.model.PluginExecution)32 Plugin (org.apache.maven.model.Plugin)22 Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)18 ArrayList (java.util.ArrayList)8 Build (org.apache.maven.model.Build)6 Dependency (org.apache.maven.model.Dependency)6 Model (org.apache.maven.model.Model)5 HashMap (java.util.HashMap)4 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 Element (org.jdom.Element)4 Iterator (java.util.Iterator)3 MavenProject (org.apache.maven.project.MavenProject)3 ManipulationException (org.commonjava.maven.ext.common.ManipulationException)3 File (java.io.File)2 ConfigurationContainer (org.apache.maven.model.ConfigurationContainer)2 Repository (org.apache.maven.model.Repository)2 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)2 Project (org.commonjava.maven.ext.common.model.Project)2 CorePlugin (org.talend.core.CorePlugin)2