use of org.apache.maven.model.PluginExecution in project custom-war-packager by jenkinsci.
the class MavenHPICustomWARPOMGenerator method generatePOM.
public Model generatePOM(Map<String, String> versionOverrides) throws IOException {
Model model = new Model();
model.setModelVersion("4.0.0");
model.setGroupId(config.bundle.groupId);
model.setArtifactId(config.bundle.artifactId);
if (config.bundle.description != null) {
model.setDescription(config.bundle.description);
}
model.setVersion(config.buildSettings.getVersion());
// WAR Dependency
Dependency dep = config.war.toDependency(versionOverrides);
dep.setScope("test");
dep.setType("war");
model.addDependency(dep);
// Plugins
if (config.plugins != null) {
for (DependencyInfo plugin : config.plugins) {
Dependency pluginDep = plugin.toDependency(versionOverrides);
pluginDep.setScope("runtime");
model.addDependency(pluginDep);
}
}
// Maven HPI Plugin
/* Sample:
<plugin>
<groupId>≈/groupId>
<artifactId>maven-hpi-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>package-war</id>
<goals>
<goal>custom-war</goal>
</goals>
<configuration>
<outputFile>${build.directory}/tools-modified.war</outputFile>
</configuration>
</execution>
</executions>
</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.jenkins-ci.tools");
mavenHPIPlugin.setArtifactId("maven-hpi-plugin");
// TODO: make configurable
mavenHPIPlugin.setVersion("2.2");
PluginExecution execution = new PluginExecution();
execution.setId("package-war");
execution.addGoal("custom-war");
execution.setConfiguration(generateCustomWarGoalConfiguration());
mavenHPIPlugin.addExecution(execution);
Build build = new Build();
build.addPlugin(mavenHPIPlugin);
model.setBuild(build);
return model;
}
use of org.apache.maven.model.PluginExecution in project maven-archetype by apache.
the class MavenJDOMWriter method iteratePluginExecution.
// -- void iteratePlugin(Counter, Element, java.util.Collection, java.lang.String,
// java.lang.String)
/**
* Method iteratePluginExecution.
*
* @param counter
* @param childTag
* @param parentTag
* @param list
* @param parent
*/
protected void iteratePluginExecution(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) {
boolean shouldExist = (list != null) && (list.size() > 0);
Element element = updateElement(counter, parent, parentTag, shouldExist);
if (shouldExist) {
Iterator it = list.iterator();
Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator();
if (!elIt.hasNext()) {
elIt = null;
}
Counter innerCount = new Counter(counter.getDepth() + 1);
while (it.hasNext()) {
PluginExecution value = (PluginExecution) it.next();
Element el;
if ((elIt != null) && elIt.hasNext()) {
el = (Element) elIt.next();
if (!elIt.hasNext()) {
elIt = null;
}
} else {
el = factory.element(childTag, element.getNamespace());
insertAtPreferredLocation(element, el, innerCount);
}
updatePluginExecution(value, childTag, innerCount, el);
innerCount.increaseCount();
}
if (elIt != null) {
while (elIt.hasNext()) {
elIt.next();
elIt.remove();
}
}
}
}
use of org.apache.maven.model.PluginExecution in project maven-plugins by apache.
the class MavenJDOMWriter method iteratePluginExecution.
// -- void iteratePlugin(Counter, Element, java.util.Collection, java.lang.String, java.lang.String)
/**
* Method iteratePluginExecution
*
* @param counter
* @param childTag
* @param parentTag
* @param list
* @param parent
*/
protected void iteratePluginExecution(Counter counter, Element parent, Collection<PluginExecution> list, java.lang.String parentTag, java.lang.String childTag) {
boolean shouldExist = list != null && list.size() > 0;
Element element = updateElement(counter, parent, parentTag, shouldExist);
if (shouldExist) {
Iterator<?> elIt = element.getChildren(childTag, element.getNamespace()).iterator();
if (!elIt.hasNext()) {
elIt = null;
}
Counter innerCount = new Counter(counter.getDepth() + 1);
for (PluginExecution value : list) {
Element el;
if (elIt != null && elIt.hasNext()) {
el = (Element) elIt.next();
if (!elIt.hasNext()) {
elIt = null;
}
} else {
el = factory.element(childTag, element.getNamespace());
insertAtPreferredLocation(element, el, innerCount);
}
updatePluginExecution(value, childTag, innerCount, el);
innerCount.increaseCount();
}
if (elIt != null) {
while (elIt.hasNext()) {
elIt.next();
elIt.remove();
}
}
}
}
use of org.apache.maven.model.PluginExecution in project tesb-studio-se by Talend.
the class CreateMavenDataServicePom method addFeaturesMavenPlugin.
private Plugin addFeaturesMavenPlugin() {
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 resourcesDir = new Xpp3Dom("resourcesDir");
resourcesDir.setValue("${project.build.directory}/bin");
Xpp3Dom featuresFile = new Xpp3Dom("featuresFile");
featuresFile.setValue("${basedir}/src/main/resources/feature/feature.xml");
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;
}
use of org.apache.maven.model.PluginExecution in project gradle by gradle.
the class Maven2Gradle method globalExclusions.
private void globalExclusions(MavenProject project, BuildScriptBuilder builder) {
Plugin enforcerPlugin = plugin("maven-enforcer-plugin", project);
PluginExecution enforceGoal = pluginGoal("enforce", enforcerPlugin);
if (enforceGoal != null) {
Xpp3Dom configuration = (Xpp3Dom) enforceGoal.getConfiguration();
Xpp3Dom bannedDependencies = configuration.getChild("rules").getChild("bannedDependencies");
if (bannedDependencies != null) {
Xpp3Dom[] children = bannedDependencies.getChild("excludes").getChildren();
ScriptBlockBuilder block = builder.block(null, "configurations.all");
if (children != null) {
for (Xpp3Dom exclude : children) {
String[] tokens = exclude.getValue().split(":");
Map<String, String> params = new LinkedHashMap<>();
params.put("group", tokens[0]);
if (tokens.length > 1 && !tokens[1].equals("*")) {
params.put("module", tokens[1]);
}
block.methodInvocation(null, "exclude", params);
}
}
}
}
}
Aggregations