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, 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 felix 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 list, String parentTag, 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 intellij-plugins by JetBrains.
the class Maven method createMojoExecution.
public MojoExecution createMojoExecution(Plugin plugin, String goal, MavenProject project) throws Exception {
if (plugin.getVersion() == null) {
plugin.setVersion(plexusContainer.lookup(PluginVersionResolver.class).resolve(new DefaultPluginVersionRequest(plugin, session)).getVersion());
}
MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor(plugin, goal, project.getRemotePluginRepositories(), session.getRepositorySession());
List<PluginExecution> executions = plugin.getExecutions();
MojoExecution mojoExecution = new MojoExecution(mojoDescriptor, executions.isEmpty() ? null : executions.get(executions.size() - 1).getId(), MojoExecution.Source.CLI);
plexusContainer.lookup(LifecycleExecutionPlanCalculator.class).setupMojoExecution(session, project, mojoExecution);
return mojoExecution;
}
use of org.apache.maven.model.PluginExecution in project fabric8 by jboss-fuse.
the class CreateProfileZipMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
if (isIgnoreProject())
return;
generateZip();
if (reactorProjects != null) {
List<MavenProject> pomZipProjects = new ArrayList<>();
List<MavenProject> fabricZipGoalProjects = new ArrayList<>();
List<MavenProject> fabricHasParentZipGoalProject = new ArrayList<MavenProject>();
for (MavenProject reactorProject : reactorProjects) {
if ("pom".equals(reactorProject.getPackaging())) {
pomZipProjects.add(reactorProject);
}
List<Plugin> buildPlugins = reactorProject.getBuildPlugins();
for (Plugin buildPlugin : buildPlugins) {
String artifactId = buildPlugin.getArtifactId();
// TODO I guess we could try find if the "zip" goal is being invoked?
if ("fabric8-maven-plugin".equals(artifactId)) {
// TODO should we only consider reactorProjects which have a fabric8:zip goal?
Object goals = buildPlugin.getGoals();
boolean hasZipGoal = goals != null && goals.toString().contains("zip");
List<PluginExecution> executions = buildPlugin.getExecutions();
for (PluginExecution execution : executions) {
List<String> execGoals = execution.getGoals();
if (execGoals.contains("zip")) {
hasZipGoal = true;
}
}
getLog().debug("project " + reactorProject.getArtifactId() + " has zip goal: " + hasZipGoal);
fabricZipGoalProjects.add(reactorProject);
}
}
}
// as that helps us detect the 'last' project when we do a full build from the entire project
for (MavenProject project : fabricZipGoalProjects) {
if (fabricZipGoalProjects.contains(project.getParent())) {
fabricHasParentZipGoalProject.add(project);
}
}
// are we the last project?
boolean last = reactorProjects.size() > 1 && project == reactorProjects.get(reactorProjects.size() - 1);
if (!last) {
// are we the last project with the zip goal, part of a group as they have a parent?
// TODO: there can be multiple groups, so when we switch to a new group we should aggregate
last = fabricHasParentZipGoalProject.size() > 1 && project == fabricHasParentZipGoalProject.get(fabricHasParentZipGoalProject.size() - 1);
}
if (!last) {
// are we the last project with the zip goal?
last = fabricZipGoalProjects.size() > 1 && project == fabricZipGoalProjects.get(fabricZipGoalProjects.size() - 1);
}
// which we can aggregate
if (last) {
getLog().info("");
getLog().info("Creating aggregated profile zip");
getLog().info("built the last fabric8:zip project so generating a combined zip for all " + fabricZipGoalProjects.size() + " projects with a fabric8:zip goal");
// favor root project as the 1st project with fabric8:zip goal
MavenProject rootProject = fabricZipGoalProjects.size() > 0 ? fabricZipGoalProjects.get(0) : reactorProjects.get(0);
// we got the root project, now filter out pom projects which has the rootProject as one of their parents
List<MavenProject> ourPomZipProjects = new ArrayList<MavenProject>();
// include the root project if its a zip as well
if (pomZipProjects.contains(rootProject)) {
ourPomZipProjects.add(rootProject);
}
ourPomZipProjects.add(rootProject);
for (MavenProject zip : pomZipProjects) {
if (hasParent(zip, rootProject, true)) {
ourPomZipProjects.add(zip);
}
}
getLog().info("Choosing root project " + rootProject.getArtifactId() + " for generation of aggregated zip");
generateAggregatedZip(rootProject, fabricZipGoalProjects, ourPomZipProjects);
}
}
} catch (MojoFailureException e) {
throw e;
} catch (MojoExecutionException e) {
throw e;
} catch (Exception e) {
throw new MojoExecutionException("Error executing", e);
}
}
use of org.apache.maven.model.PluginExecution in project fabric8-maven-plugin by fabric8io.
the class SpringBootGenerator method isSpringBootRepackage.
private boolean isSpringBootRepackage() {
MavenProject project = getProject();
Plugin plugin = project.getPlugin(SPRING_BOOT_MAVEN_PLUGIN_GA);
if (plugin != null) {
Map<String, PluginExecution> executionsAsMap = plugin.getExecutionsAsMap();
if (executionsAsMap != null) {
for (PluginExecution execution : executionsAsMap.values()) {
List<String> goals = execution.getGoals();
if (goals.contains("repackage")) {
log.verbose("Using fat jar packaging as the spring boot plugin is using `repackage` goal execution");
return true;
}
}
}
}
return false;
}
Aggregations