Java Code Examples for org.apache.maven.project.MavenProject#getBuildPlugins()
The following examples show how to use
org.apache.maven.project.MavenProject#getBuildPlugins() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MavenUtil.java From jkube with Eclipse Public License 2.0 | 6 votes |
/** * Returns a list of {@link Plugin} * * @param project Maven project * @return list of plugins */ public static List<Plugin> getPlugins(MavenProject project) { List<Plugin> projectPlugins = new ArrayList<>(); for (org.apache.maven.model.Plugin plugin : project.getBuildPlugins()) { Plugin.PluginBuilder jkubeProjectPluginBuilder = Plugin.builder(); jkubeProjectPluginBuilder.groupId(plugin.getGroupId()) .artifactId(plugin.getArtifactId()) .version(plugin.getVersion()); if (plugin.getExecutions() != null && !plugin.getExecutions().isEmpty()) { jkubeProjectPluginBuilder.executions(getPluginExecutionsAsList(plugin)); } jkubeProjectPluginBuilder.configuration(MavenConfigurationExtractor.extract((Xpp3Dom)plugin.getConfiguration())); projectPlugins.add(jkubeProjectPluginBuilder.build()); } return projectPlugins; }
Example 2
Source File: MavenUtil.java From jkube with Eclipse Public License 2.0 | 6 votes |
/** * Returns the plugin with the given groupId (if present) and artifactId. * * @param project MavenProject of project * @param groupId group id * @param artifactId artifact id * @return return Plugin object for the specific plugin */ public static org.apache.maven.model.Plugin getPlugin(MavenProject project, String groupId, String artifactId) { if (artifactId == null) { throw new IllegalArgumentException("artifactId cannot be null"); } List<org.apache.maven.model.Plugin> plugins = project.getBuildPlugins(); if (plugins != null) { for (org.apache.maven.model.Plugin plugin : plugins) { boolean matchesArtifactId = artifactId.equals(plugin.getArtifactId()); boolean matchesGroupId = groupId == null || groupId.equals(plugin.getGroupId()); if (matchesGroupId && matchesArtifactId) { return plugin; } } } return null; }
Example 3
Source File: DeployMojo.java From ci.maven with Apache License 2.0 | 6 votes |
private boolean mavenWarPluginExists(MavenProject proj) { MavenProject currentProject = proj; while(currentProject != null) { List<Object> plugins = new ArrayList<Object>(currentProject.getBuildPlugins()); plugins.addAll(currentProject.getPluginManagement().getPlugins()); for(Object o : plugins) { if(o instanceof Plugin) { Plugin plugin = (Plugin) o; if(plugin.getGroupId().equals("org.apache.maven.plugins") && plugin.getArtifactId().equals("maven-war-plugin")) { return true; } } } currentProject = currentProject.getParent(); } return false; }
Example 4
Source File: MojoUtils.java From quarkus with Apache License 2.0 | 5 votes |
public static Plugin checkProjectForMavenBuildPlugin(MavenProject project) { for (Plugin plugin : project.getBuildPlugins()) { if (plugin.getGroupId().equals("io.quarkus") && plugin.getArtifactId().equals("quarkus-maven-plugin")) { for (PluginExecution pluginExecution : plugin.getExecutions()) { if (pluginExecution.getGoals().contains("build")) { return plugin; } } } } return null; }
Example 5
Source File: PluginPropertyUtils.java From netbeans with Apache License 2.0 | 5 votes |
/** * Should handle both deprecated 2.x-style report section, and 3.x-style Site Plugin config. * https://jira.codehaus.org/browse/MSITE-484 and https://jira.codehaus.org/browse/MSITE-443 if and when implemented may require updates. */ private static @NonNull Iterable<ReportPlugin> getEffectiveReportPlugins(@NonNull MavenProject prj) { List<ReportPlugin> plugins = new ArrayList<ReportPlugin>(); for (Plugin plug : prj.getBuildPlugins()) { if (Constants.GROUP_APACHE_PLUGINS.equals(plug.getGroupId()) && Constants.PLUGIN_SITE.equals(plug.getArtifactId())) { Xpp3Dom cfg = (Xpp3Dom) plug.getConfiguration(); // MNG-4862 if (cfg == null) { continue; } Xpp3Dom reportPlugins = cfg.getChild("reportPlugins"); if (reportPlugins == null) { continue; } for (Xpp3Dom plugin : reportPlugins.getChildren("plugin")) { ReportPlugin p = new ReportPlugin(); Xpp3Dom groupId = plugin.getChild("groupId"); if (groupId != null) { p.setGroupId(groupId.getValue()); } Xpp3Dom artifactId = plugin.getChild("artifactId"); if (artifactId != null) { p.setArtifactId(artifactId.getValue()); } Xpp3Dom version = plugin.getChild("version"); if (version != null) { p.setVersion(version.getValue()); } p.setConfiguration(plugin.getChild("configuration")); // XXX reportSets // maven-site-plugin does not appear to apply defaults from plugin.xml (unlike 2.x?) plugins.add(p); } } } @SuppressWarnings("deprecation") List<ReportPlugin> m2Plugins = prj.getReportPlugins(); plugins.addAll(m2Plugins); return plugins; }
Example 6
Source File: MavenUtils.java From developer-studio with Apache License 2.0 | 5 votes |
/** * Upgrade the plugin versions of the given maven project. * This will change the maven plugin versions of Developer Studio projects * according to the working version of Developer Studio. * @param project * @param mavenProject */ public static void upgradePluginVersions(IProject project, MavenProject mavenProject) { List<Plugin> plugins = mavenProject.getBuildPlugins(); for(Plugin plugin : plugins) { if (GROUP_ID_ORG_WSO2_MAVEN.equals(plugin.getGroupId())) { String newVersion = WSO2MavenPluginVersions.getPluginVersion(plugin.getArtifactId()); if (newVersion != null && !plugin.getVersion().equals(newVersion)) { // Update the plugin version. plugin.setVersion(newVersion); } } } }
Example 7
Source File: ResolveDependenciesMojo.java From go-offline-maven-plugin with Apache License 2.0 | 4 votes |
public void execute() throws MojoExecutionException { dependencyDownloader.init(getBuildingRequest(), getReactorProjects(), getLog()); if (downloadSources) { dependencyDownloader.enableDownloadSources(); } if (downloadJavadoc) { dependencyDownloader.enableDownloadJavadoc(); } Set<Plugin> allPlugins = new HashSet<>(); for (MavenProject mavenProject : getReactorProjects()) { List<Plugin> buildPlugins = mavenProject.getBuildPlugins(); allPlugins.addAll(buildPlugins); } Set<ArtifactWithRepoType> artifactsToDownload = new HashSet<>(); for (Plugin plugin : allPlugins) { artifactsToDownload.addAll(dependencyDownloader.resolvePlugin(plugin)); } for (MavenProject project : getReactorProjects()) { artifactsToDownload.addAll(dependencyDownloader.resolveDependencies(project)); } if (dynamicDependencies != null) { for (DynamicDependency dep : dynamicDependencies) { artifactsToDownload.addAll(dependencyDownloader.resolveDynamicDependency(dep)); } } dependencyDownloader.downloadArtifacts(artifactsToDownload); List<Exception> errors = dependencyDownloader.getErrors(); for (Exception error : errors) { getLog().warn(error.getMessage()); } if (failOnErrors && !errors.isEmpty()) { throw new MojoExecutionException("Unable to download dependencies, consult the errors and warnings printed above."); } }