Java Code Examples for org.apache.maven.model.PluginExecution#getConfiguration()
The following examples show how to use
org.apache.maven.model.PluginExecution#getConfiguration() .
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: RequiredMavenVersionFinder.java From versions-maven-plugin with Apache License 2.0 | 6 votes |
private Xpp3Dom getRequireMavenVersionTag(List<PluginExecution> executions) { for (PluginExecution pluginExecution : executions) { Xpp3Dom configurationTag = (Xpp3Dom) pluginExecution.getConfiguration(); if (null == configurationTag) { continue; } Xpp3Dom rulesTag = configurationTag.getChild("rules"); if (null == rulesTag) { continue; } Xpp3Dom requireMavenVersionTag = rulesTag.getChild("requireMavenVersion"); if (null == requireMavenVersionTag) { continue; } return requireMavenVersionTag; } return null; }
Example 2
Source File: PluginExtractor.java From wisdom with Apache License 2.0 | 6 votes |
/** * Retrieves the configuration for a specific goal of the given plugin from the Maven Project. * * @param mojo the mojo * @param plugin the artifact id of the plugin * @param goal the goal * @return the configuration, {@code null} if not found */ public static Xpp3Dom getBuildPluginConfigurationForGoal(AbstractWisdomMojo mojo, String plugin, String goal) { List<Plugin> plugins = mojo.project.getBuildPlugins(); for (Plugin plug : plugins) { if (plug.getArtifactId().equals(plugin)) { // Check main execution List<String> globalGoals = (List<String>) plug.getGoals(); if (globalGoals != null && globalGoals.contains(goal)) { return (Xpp3Dom) plug.getConfiguration(); } // Check executions for (PluginExecution execution : plug.getExecutions()) { if (execution.getGoals().contains(goal)) { return (Xpp3Dom) execution.getConfiguration(); } } } } // Not found. return null; }
Example 3
Source File: LocationAwareMavenXpp3Writer.java From netbeans with Apache License 2.0 | 5 votes |
private void writePluginExecution(PluginExecution pluginExecution, String tagName, XmlSerializer serializer) throws java.io.IOException { serializer.startTag(NAMESPACE, tagName); flush(serializer); StringBuffer b = b(serializer); int start = b.length(); if ((pluginExecution.getId() != null) && !pluginExecution.getId().equals("default")) { writeValue(serializer, "id", pluginExecution.getId(), pluginExecution); } if (pluginExecution.getPhase() != null) { writeValue(serializer, "phase", pluginExecution.getPhase(), pluginExecution); } if ((pluginExecution.getGoals() != null) && (pluginExecution.getGoals().size() > 0)) { serializer.startTag(NAMESPACE, "goals"); flush(serializer); int start2 = b.length(); int index = 0; InputLocation tracker = pluginExecution.getLocation("goals"); for (Iterator iter = pluginExecution.getGoals().iterator(); iter.hasNext();) { String goal = (String) iter.next(); writeValue(serializer, "goal", goal, tracker, index); index = index + 1; } serializer.endTag(NAMESPACE, "goals").flush(); logLocation(pluginExecution, "goals", start2, b.length()); } if (pluginExecution.getInherited() != null) { writeValue(serializer, "inherited", pluginExecution.getInherited(), pluginExecution); } if (pluginExecution.getConfiguration() != null) { writeXpp3DOM(serializer, (Xpp3Dom)pluginExecution.getConfiguration(), pluginExecution); } serializer.endTag(NAMESPACE, tagName).flush(); logLocation(pluginExecution, "", start, b.length()); }
Example 4
Source File: RelocationManipulator.java From pom-manipulation-ext with Apache License 2.0 | 5 votes |
private Map<ConfigurationContainer, String> findConfigurations( final Plugin plugin ) { if ( plugin == null ) { return Collections.emptyMap(); } final Map<ConfigurationContainer, String> configs = new LinkedHashMap<>(); final Object pluginConfiguration = plugin.getConfiguration(); if ( pluginConfiguration != null ) { configs.put( plugin, pluginConfiguration.toString() ); } final List<PluginExecution> executions = plugin.getExecutions(); if ( executions != null ) { for ( PluginExecution execution : executions ) { final Object executionConfiguration = execution.getConfiguration(); if ( executionConfiguration != null ) { configs.put( execution, executionConfiguration.toString() ); } } } return configs; }
Example 5
Source File: ProjectHelper.java From furnace with Eclipse Public License 1.0 | 5 votes |
/** * Returns <code>true</code> if this model is a single-project addon */ public boolean isAddon(Model model) { boolean result = false; Build build = model.getBuild(); if (build != null) { PLUGIN_LOOP: for (Plugin plugin : build.getPlugins()) { if ("maven-jar-plugin".equals(plugin.getArtifactId())) { for (PluginExecution execution : plugin.getExecutions()) { Xpp3Dom config = (Xpp3Dom) execution.getConfiguration(); if (config != null) { Xpp3Dom classifierNode = config.getChild("classifier"); if (classifierNode != null && MavenAddonDependencyResolver.FORGE_ADDON_CLASSIFIER.equals(classifierNode.getValue())) { result = true; break PLUGIN_LOOP; } } } } } } return result; }
Example 6
Source File: PluginExtractor.java From wisdom with Apache License 2.0 | 5 votes |
/** * Retrieves the main configuration of the given plugin from the Maven Project. * * @param mojo the mojo * @param artifactId the artifact id of the plugin * @param goal an optional goal. If set if first check for a specific configuration executing this * goal, if not found, it returns the global configuration * @return the configuration, {@code null} if not found */ public static Xpp3Dom getBuildPluginConfiguration(AbstractWisdomMojo mojo, String artifactId, String goal) { List<Plugin> plugins = mojo.project.getBuildPlugins(); Plugin plugin = null; for (Plugin plug : plugins) { if (plug.getArtifactId().equals(artifactId)) { plugin = plug; } } if (plugin == null) { // Not found return null; } if (goal != null) { // Check main execution List<String> globalGoals = (List<String>) plugin.getGoals(); if (globalGoals != null && globalGoals.contains(goal)) { return (Xpp3Dom) plugin.getConfiguration(); } // Check executions for (PluginExecution execution : plugin.getExecutions()) { if (execution.getGoals().contains(goal)) { return (Xpp3Dom) execution.getConfiguration(); } } } // Global configuration. return (Xpp3Dom) plugin.getConfiguration(); }
Example 7
Source File: MavenProjectUtil.java From ci.maven with Apache License 2.0 | 5 votes |
/** * Get a configuration value from a goal from a plugin * @param project * @param pluginKey * @param goal * @param configName * @return the value of the configuration parameter * @throws PluginScenarioException */ public static String getPluginGoalConfigurationString(MavenProject project, String pluginKey, String goal, String configName) throws PluginScenarioException { PluginExecution execution = getPluginGoalExecution(project, pluginKey, goal); final Xpp3Dom config = (Xpp3Dom)execution.getConfiguration(); if(config != null) { Xpp3Dom configElement = config.getChild(configName); if(configElement != null) { String value = configElement.getValue().trim(); return value; } } throw new PluginScenarioException("Could not find configuration string " + configName + " for goal " + goal + " on plugin " + pluginKey); }
Example 8
Source File: DistributionEnforcingManipulator.java From pom-manipulation-ext with Apache License 2.0 | 4 votes |
/** * Go through the plugin / plugin-execution configurations and find references to the <code>skip</code> parameter for the given Maven plugin * instance. */ private List<SkipReference> findSkipRefs( final Plugin plugin, final Project project ) throws ManipulationException { if ( plugin == null ) { return Collections.emptyList(); } final Map<ConfigurationContainer, String> configs = new LinkedHashMap<>(); Object configuration = plugin.getConfiguration(); if ( configuration != null ) { configs.put( plugin, configuration.toString() ); } final List<PluginExecution> executions = plugin.getExecutions(); if ( executions != null ) { for ( final PluginExecution execution : executions ) { configuration = execution.getConfiguration(); if ( configuration != null ) { configs.put( execution, configuration.toString() ); } } } final List<SkipReference> result = new ArrayList<>(); for ( final Map.Entry<ConfigurationContainer, String> entry : configs.entrySet() ) { try { final Document doc = galleyWrapper.parseXml( entry.getValue() ); final NodeList children = doc.getDocumentElement() .getChildNodes(); if ( children != null ) { for ( int i = 0; i < children.getLength(); i++ ) { final Node n = children.item( i ); if ( n.getNodeName() .equals( SKIP_NODE ) ) { result.add( new SkipReference( entry.getKey(), n ) ); } } } } catch ( final GalleyMavenXMLException e ) { throw new ManipulationException( "Unable to parse config for plugin {} in {}", plugin.getId(), project.getKey(), e ); } } return result; }