List of usage examples for org.apache.maven.project MavenProject getBuildPlugins
public List<Plugin> getBuildPlugins()
From source file:ch.sourcepond.maven.release.substitution.DefaultVersionSubstitution.java
License:Apache License
@Override public String getActualVersionOrNull(final MavenProject project, final Plugin originalPlugin) { return getActualVersionOrNull(project.getBuildPlugins(), originalPlugin, pluginAdapter); }
From source file:com.alibaba.citrus.maven.eclipse.base.eclipse.EclipsePlugin.java
License:Apache License
private boolean enableAjdt(MavenProject project) { boolean enable = false; List buildPlugins = project.getBuildPlugins(); for (Iterator it = buildPlugins.iterator(); it.hasNext();) { Plugin plugin = (Plugin) it.next(); if (plugin.getGroupId().equals(ORG_CODEHAUS_MOJO) && plugin.getArtifactId().equals(ASPECTJ_MAVEN_PLUGIN)) { enable = true;//from w w w .j a v a 2s .co m break; } } return enable; }
From source file:com.alibaba.citrus.maven.eclipse.base.eclipse.EclipsePlugin.java
License:Apache License
private Xpp3Dom getAspectjConfiguration(MavenProject project) { Xpp3Dom configuration = null;/*from w ww . ja va 2s . co m*/ List buildPlugins = project.getBuildPlugins(); for (Iterator it = buildPlugins.iterator(); it.hasNext();) { Plugin plugin = (Plugin) it.next(); if (plugin.getGroupId().equals(ORG_CODEHAUS_MOJO) && plugin.getArtifactId().equals(ASPECTJ_MAVEN_PLUGIN)) { configuration = (Xpp3Dom) plugin.getConfiguration(); break; } } return configuration; }
From source file:com.soebes.maven.extensions.deploy.archiver.DeployArchiver.java
License:Apache License
private boolean containsLifeCyclePluginGoals(ExecutionEvent executionEvent, String groupId, String artifactId, String goal) {/*from www . j a v a 2 s .co m*/ boolean result = false; List<MavenProject> sortedProjects = executionEvent.getSession().getProjectDependencyGraph() .getSortedProjects(); for (MavenProject mavenProject : sortedProjects) { List<Plugin> buildPlugins = mavenProject.getBuildPlugins(); for (Plugin plugin : buildPlugins) { if (groupId.equals(plugin.getGroupId()) && artifactId.equals(plugin.getArtifactId())) { List<PluginExecution> executions = plugin.getExecutions(); for (PluginExecution pluginExecution : executions) { if (pluginExecution.getGoals().contains(goal)) { result = true; } } } } } return result; }
From source file:com.soebes.maven.extensions.deploy.archiver.DeployArchiver.java
License:Apache License
private void removePluginFromLifeCycle(ExecutionEvent executionEvent, String groupId, String artifactId, String goal) {/* ww w. jav a 2 s.com*/ boolean removed = false; List<MavenProject> sortedProjects = executionEvent.getSession().getProjectDependencyGraph() .getSortedProjects(); for (MavenProject mavenProject : sortedProjects) { List<Plugin> buildPlugins = mavenProject.getBuildPlugins(); for (Plugin plugin : buildPlugins) { LOGGER.debug("Plugin: " + plugin.getId()); List<PluginExecution> printExecutions = plugin.getExecutions(); for (PluginExecution pluginExecution : printExecutions) { LOGGER.debug(" -> " + pluginExecution.getGoals()); } if (groupId.equals(plugin.getGroupId()) && artifactId.equals(plugin.getArtifactId())) { if (!removed) { LOGGER.warn(groupId + ":" + artifactId + ":" + goal + " has been deactivated."); } List<PluginExecution> executions = plugin.getExecutions(); for (PluginExecution pluginExecution : executions) { pluginExecution.removeGoal(goal); removed = true; } } } } }
From source file:hudson.gridmaven.PomInfo.java
License:Open Source License
public PomInfo(MavenProject project, PomInfo parent, String relPath) { this.name = new ModuleName(project); this.version = project.getVersion(); this.displayName = project.getName(); this.defaultGoal = project.getDefaultGoal(); this.relativePath = relPath; this.parent = parent; if (parent != null) parent.children.add(name);//from w ww . j a va2 s .c o m for (Dependency dep : (List<Dependency>) project.getDependencies()) dependencies.add(new ModuleDependency(dep)); MavenProject parentProject = project.getParent(); if (parentProject != null) dependencies.add(new ModuleDependency(parentProject)); if (parent != null) dependencies.add(parent.asDependency()); addPluginsAsDependencies(project.getBuildPlugins(), dependencies); addReportPluginsAsDependencies(project.getReportPlugins(), dependencies); List<Extension> extensions = project.getBuildExtensions(); if (extensions != null) for (Extension ext : extensions) dependencies.add(new ModuleDependency(ext)); // when the parent POM uses a plugin and builds a plugin at the same time, // the plugin module ends up depending on itself dependencies.remove(asDependency()); CiManagement ciMgmt = project.getCiManagement(); if ((ciMgmt != null) && (ciMgmt.getSystem() == null || ciMgmt.getSystem().equals("hudson"))) { Notifier mailNotifier = null; for (Notifier n : (List<Notifier>) ciMgmt.getNotifiers()) { if (n.getType().equals("mail")) { mailNotifier = n; break; } } this.mailNotifier = mailNotifier; } else this.mailNotifier = null; this.groupId = project.getGroupId(); this.artifactId = project.getArtifactId(); this.packaging = project.getPackaging(); }
From source file:info.mikaelsvensson.devtools.sitesearch.SiteSearchPlugin.java
License:Apache License
private static boolean isSiteIndexerPluginReferences(final MavenProject proj) { for (Object o : proj.getBuildPlugins()) { Plugin buildPlugin = (Plugin) o; if (PLUGIN_ARTIFACT_ID.equals(buildPlugin.getArtifactId())) { return true; }/*from www . ja v a 2s .c o m*/ } return false; }
From source file:io.fabric8.maven.CreateProfileZipMojo.java
License:Apache License
@Override public void execute() throws MojoExecutionException, MojoFailureException { try {/*from www.j av a2s .c om*/ 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); } } } // we want a list of projects which has a parent that has a zip goal too // 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); } // we need to generate the aggregated zip last, so we have all the generated profiles in the other modules // 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); } }
From source file:io.fabric8.maven.ZipMojo.java
License:Apache License
private List<MavenProject> fabricZipGoalProjects() { List<MavenProject> answer = new ArrayList<>(); if (reactorProjects != null) { List<MavenProject> pomZipProjects = new ArrayList<>(); for (MavenProject reactorProject : reactorProjects) { if (isPom(reactorProject)) { pomZipProjects.add(reactorProject); }//from w w w . j av a 2 s.c om List<Plugin> buildPlugins = reactorProject.getBuildPlugins(); for (Plugin buildPlugin : buildPlugins) { String artifactId = buildPlugin.getArtifactId(); if ("fabric8-maven-plugin".equals(artifactId)) { 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); if (hasZipGoal) { answer.add(reactorProject); } } } } } return answer; }
From source file:io.fabric8.vertx.maven.plugin.utils.MojoUtils.java
License:Apache License
/** * @param project//from w ww.j av a2s . c om * @param pluginKey * @return */ private Optional<Plugin> hasPlugin(MavenProject project, String pluginKey) { Optional<Plugin> jarPlugin = project.getBuildPlugins().stream() .filter(plugin -> pluginKey.equals(plugin.getKey())).findFirst(); return jarPlugin; }