Search in sources :

Example 26 with PluginExecution

use of org.apache.maven.model.PluginExecution in project custom-war-packager by jenkinsci.

the class MavenWARPackagePOMGenerator method generatePOM.

public Model generatePOM(Map<String, String> injectedManifestEntries) throws IOException {
    Model model = new Model();
    model.setModelVersion("4.0.0");
    model.setGroupId(config.bundle.groupId);
    model.setArtifactId(config.bundle.artifactId);
    model.setDescription(config.bundle.description);
    model.setVersion(config.buildSettings.getVersion());
    HashMap<String, String> manifestEntries = new HashMap<>(injectedManifestEntries);
    manifestEntries.put("Build-Time", "${maven.build.timestamp}");
    manifestEntries.put("Built-By", "${user.name}");
    addIfNotNull(manifestEntries, "Implementation-Title", config.bundle.title);
    addIfNotNull(manifestEntries, "Implementation-Vendor", config.bundle.vendor);
    addIfNotNull(manifestEntries, "Implementation-Version", config.buildSettings.getVersion());
    // Maven HPI Plugin
    /* Sample:
            <build>
              <plugins>
                <plugin>
                  <artifactId>maven-war-plugin</artifactId>
                  <version>2.6</version>
                  <goals>
                    <goal>war</goal>
                  </goals>
                  <configuration>
                      <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
                      <webResources>
                          <resource>
                              <directory>war-tmp</directory>
                          </resource>
                      </webResources>
                      <archive>
                          <manifest>
                              <mainClass>Main</mainClass>
                          </manifest>
                          <manifestEntries>
                            <Implementation-Title>Test</Implementation-Title>
                            <Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
                            <Implementation-Version>${project.version}</Implementation-Version>
                            <Hudson-Version>1.395</Hudson-Version>
                            <Jenkins-Version>1.2.3</Jenkins-Version>
                            <Build-Time>${maven.build.timestamp}</Build-Time>
                            <Remoting-Minimum-Supported-Version>2.60</Remoting-Minimum-Supported-Version>
                            <Remoting-Embedded-Version>3.17</Remoting-Embedded-Version>
                          </manifestEntries>
                      </archive>
                  </configuration>
                </plugin>
              </plugin
         */
    Repository jenkinsRepository = new Repository();
    jenkinsRepository.setId("repo.jenkins-ci.org");
    jenkinsRepository.setUrl("https://repo.jenkins-ci.org/public/");
    model.addPluginRepository(jenkinsRepository);
    model.addRepository(jenkinsRepository);
    Plugin mavenHPIPlugin = new Plugin();
    mavenHPIPlugin.setGroupId("org.apache.maven.plugins");
    mavenHPIPlugin.setArtifactId("maven-war-plugin");
    // TODO: make configurable
    mavenHPIPlugin.setVersion("2.6");
    PluginExecution execution = new PluginExecution();
    execution.setId("package-war");
    execution.addGoal("war");
    execution.setConfiguration(generateCustomWarGoalConfiguration(manifestEntries));
    mavenHPIPlugin.addExecution(execution);
    Build build = new Build();
    build.addPlugin(mavenHPIPlugin);
    model.setBuild(build);
    return model;
}
Also used : PluginExecution(org.apache.maven.model.PluginExecution) Repository(org.apache.maven.model.Repository) HashMap(java.util.HashMap) Build(org.apache.maven.model.Build) Model(org.apache.maven.model.Model) Plugin(org.apache.maven.model.Plugin)

Example 27 with PluginExecution

use of org.apache.maven.model.PluginExecution in project wildfly-swarm by wildfly-swarm.

the class MultiStartMojo method getConfiguration.

protected Xpp3Dom getConfiguration(MavenProject project, String executionId) {
    Plugin plugin = project.getPlugin("org.wildfly.swarm:wildfly-swarm-plugin");
    PluginExecution execution = null;
    for (PluginExecution each : plugin.getExecutions()) {
        if (executionId != null) {
            if (each.getId().equals(executionId)) {
                execution = each;
                break;
            }
        } else if (each.getGoals().contains("start")) {
            execution = each;
            break;
        }
    }
    Xpp3Dom config;
    if (execution == null) {
        config = new Xpp3Dom("configuration");
    } else {
        config = (Xpp3Dom) execution.getConfiguration();
    }
    Xpp3Dom pdom = new Xpp3Dom("project");
    pdom.setValue("${project}");
    config.addChild(pdom);
    pdom = new Xpp3Dom("repositorySystemSession");
    pdom.setValue("${repositorySystemSession}");
    config.addChild(pdom);
    pdom = new Xpp3Dom("remoteRepositories");
    pdom.setValue("${project.remoteArtifactRepositories}");
    config.addChild(pdom);
    return config;
}
Also used : PluginExecution(org.apache.maven.model.PluginExecution) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) Plugin(org.apache.maven.model.Plugin)

Example 28 with PluginExecution

use of org.apache.maven.model.PluginExecution in project tesb-studio-se by Talend.

the class CreateMavenBundlePom method addFeaturesMavenPlugin.

private Plugin addFeaturesMavenPlugin(String finalNameValue) {
    Plugin plugin = new Plugin();
    plugin.setGroupId("org.apache.karaf.tooling");
    plugin.setArtifactId("karaf-maven-plugin");
    plugin.setVersion("4.2.10");
    Xpp3Dom configuration = new Xpp3Dom("configuration");
    Xpp3Dom finalName = new Xpp3Dom("finalName");
    // "${talend.job.finalName}"
    finalName.setValue(finalNameValue);
    Xpp3Dom resourcesDir = new Xpp3Dom("resourcesDir");
    resourcesDir.setValue("${project.build.directory}/bin");
    Xpp3Dom featuresFile = new Xpp3Dom("featuresFile");
    featuresFile.setValue(PATH_FEATURE);
    configuration.addChild(finalName);
    configuration.addChild(resourcesDir);
    configuration.addChild(featuresFile);
    List<PluginExecution> pluginExecutions = new ArrayList<PluginExecution>();
    PluginExecution pluginExecution = new PluginExecution();
    pluginExecution.setId("create-kar");
    pluginExecution.addGoal("kar");
    pluginExecution.setConfiguration(configuration);
    pluginExecutions.add(pluginExecution);
    plugin.setExecutions(pluginExecutions);
    List<Dependency> dependencies = new ArrayList<Dependency>();
    Dependency mavensharedDep = new Dependency();
    mavensharedDep.setGroupId("org.apache.maven.shared");
    mavensharedDep.setArtifactId("maven-shared-utils");
    mavensharedDep.setVersion("3.3.3");
    Dependency commonsioDep = new Dependency();
    commonsioDep.setGroupId("commons-io");
    commonsioDep.setArtifactId("commons-io");
    commonsioDep.setVersion("2.8.0");
    Dependency httpclientDep = new Dependency();
    httpclientDep.setGroupId("org.apache.httpcomponents");
    httpclientDep.setArtifactId("httpclient");
    httpclientDep.setVersion("4.5.13");
    Dependency httpcoreDep = new Dependency();
    httpcoreDep.setGroupId("org.apache.httpcomponents");
    httpcoreDep.setArtifactId("httpcore");
    httpcoreDep.setVersion("4.4.13");
    Dependency istackDep = new Dependency();
    istackDep.setGroupId("com.sun.istack");
    istackDep.setArtifactId("istack-commons-runtime");
    istackDep.setVersion("3.0.10");
    Dependency xzDep = new Dependency();
    xzDep.setGroupId("org.tukaani");
    xzDep.setArtifactId("xz");
    xzDep.setVersion("1.8");
    Dependency junitDep = new Dependency();
    junitDep.setGroupId("junit");
    junitDep.setArtifactId("junit");
    junitDep.setVersion("4.13.2");
    Dependency mavenCoreDep = new Dependency();
    mavenCoreDep.setGroupId("org.apache.maven");
    mavenCoreDep.setArtifactId("maven-core");
    mavenCoreDep.setVersion("3.8.3");
    Dependency mavenCompatDep = new Dependency();
    mavenCompatDep.setGroupId("org.apache.maven");
    mavenCompatDep.setArtifactId("maven-compat");
    mavenCompatDep.setVersion("3.8.3");
    Dependency mavenSettingsDep = new Dependency();
    mavenSettingsDep.setGroupId("org.apache.maven");
    mavenSettingsDep.setArtifactId("maven-settings");
    mavenSettingsDep.setVersion("3.8.3");
    Dependency mavenSettingsBdDep = new Dependency();
    mavenSettingsBdDep.setGroupId("org.apache.maven");
    mavenSettingsBdDep.setArtifactId("maven-settings-builder");
    mavenSettingsBdDep.setVersion("3.8.3");
    Dependency plexusArchiverDep = new Dependency();
    plexusArchiverDep.setGroupId("org.codehaus.plexus");
    plexusArchiverDep.setArtifactId("plexus-archiver");
    plexusArchiverDep.setVersion("3.6.0");
    Dependency commonsCompressDep = new Dependency();
    commonsCompressDep.setGroupId("org.apache.commons");
    commonsCompressDep.setArtifactId("commons-compress");
    commonsCompressDep.setVersion("1.21");
    Dependency jsoupDep = new Dependency();
    jsoupDep.setGroupId("org.jsoup");
    jsoupDep.setArtifactId("jsoup");
    jsoupDep.setVersion("1.14.2");
    Dependency mavenModelDep = new Dependency();
    mavenModelDep.setGroupId("org.apache.maven");
    mavenModelDep.setArtifactId("maven-model");
    mavenModelDep.setVersion("3.8.3");
    Dependency commonsCodecDep = new Dependency();
    commonsCodecDep.setGroupId("commons-codec");
    commonsCodecDep.setArtifactId("commons-codec");
    commonsCodecDep.setVersion("1.15");
    dependencies.add(mavensharedDep);
    dependencies.add(commonsioDep);
    dependencies.add(httpclientDep);
    dependencies.add(httpcoreDep);
    dependencies.add(istackDep);
    dependencies.add(xzDep);
    dependencies.add(junitDep);
    dependencies.add(mavenCoreDep);
    dependencies.add(mavenCompatDep);
    dependencies.add(mavenSettingsDep);
    dependencies.add(mavenSettingsBdDep);
    dependencies.add(plexusArchiverDep);
    dependencies.add(commonsCompressDep);
    dependencies.add(jsoupDep);
    dependencies.add(mavenModelDep);
    dependencies.add(commonsCodecDep);
    plugin.setDependencies(dependencies);
    return plugin;
}
Also used : PluginExecution(org.apache.maven.model.PluginExecution) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) ArrayList(java.util.ArrayList) Dependency(org.apache.maven.model.Dependency) Plugin(org.apache.maven.model.Plugin) CorePlugin(org.talend.core.CorePlugin)

Example 29 with PluginExecution

use of org.apache.maven.model.PluginExecution in project tesb-studio-se by Talend.

the class CreateMavenBundlePom method addOsgiHelperMavenPlugin.

private Plugin addOsgiHelperMavenPlugin() {
    Plugin plugin = new Plugin();
    plugin.setGroupId(TalendMavenConstants.DEFAULT_CI_GROUP_ID);
    plugin.setArtifactId(MojoType.OSGI_HELPER.getArtifactId());
    plugin.setVersion(VersionUtils.getMojoVersion(MojoType.OSGI_HELPER));
    Xpp3Dom configuration = new Xpp3Dom("configuration");
    Xpp3Dom featuresFile = new Xpp3Dom("featuresFile");
    featuresFile.setValue(PATH_FEATURE);
    configuration.addChild(featuresFile);
    List<PluginExecution> pluginExecutions = new ArrayList<PluginExecution>();
    PluginExecution pluginExecution = new PluginExecution();
    pluginExecution.setId("feature-helper");
    pluginExecution.setPhase("generate-sources");
    pluginExecution.addGoal("generate");
    pluginExecution.setConfiguration(configuration);
    pluginExecutions.add(pluginExecution);
    plugin.setExecutions(pluginExecutions);
    return plugin;
}
Also used : PluginExecution(org.apache.maven.model.PluginExecution) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) ArrayList(java.util.ArrayList) Plugin(org.apache.maven.model.Plugin) CorePlugin(org.talend.core.CorePlugin)

Example 30 with PluginExecution

use of org.apache.maven.model.PluginExecution in project tesb-studio-se by Talend.

the class CreateMavenDataServicePom method addOsgiHelperMavenPlugin.

private Plugin addOsgiHelperMavenPlugin() {
    Plugin plugin = new Plugin();
    plugin.setGroupId(TalendMavenConstants.DEFAULT_CI_GROUP_ID);
    plugin.setArtifactId(MojoType.OSGI_HELPER.getArtifactId());
    plugin.setVersion(VersionUtils.getMojoVersion(MojoType.OSGI_HELPER));
    Xpp3Dom configuration = new Xpp3Dom("configuration");
    Xpp3Dom featuresFile = new Xpp3Dom("featuresFile");
    featuresFile.setValue("${basedir}/src/main/resources/feature/feature.xml");
    configuration.addChild(featuresFile);
    List<PluginExecution> pluginExecutions = new ArrayList<PluginExecution>();
    PluginExecution pluginExecution = new PluginExecution();
    pluginExecution.setId("feature-helper");
    pluginExecution.setPhase("generate-sources");
    pluginExecution.addGoal("generate");
    pluginExecution.setConfiguration(configuration);
    pluginExecutions.add(pluginExecution);
    plugin.setExecutions(pluginExecutions);
    return plugin;
}
Also used : PluginExecution(org.apache.maven.model.PluginExecution) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) ArrayList(java.util.ArrayList) 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