public Map getPluginsAsMap() { return build.getPluginsAsMap(); }
public Plugin getPlugin( String pluginKey ) { return getBuild().getPluginsAsMap().get( pluginKey ); }
public void addPlugin( Plugin plugin ) { Build build = getModelBuild(); if ( !build.getPluginsAsMap().containsKey( plugin.getKey() ) ) { injectPluginManagementInfo( plugin ); build.addPlugin( plugin ); build.flushPluginMap(); } }
/** * Taken from eclipse plugin. Search for the configuration Xpp3 dom of an other plugin. * * @param project the current maven project to get the configuration from. * @param pluginId the group id and artifact id of the plugin to search for * @return the value of the plugin configuration */ private static Xpp3Dom getPluginConfigurationDom(MavenProject project, String pluginId) { Plugin plugin = project.getBuild().getPluginsAsMap().get(pluginId); if (plugin != null) { return (Xpp3Dom) plugin.getConfiguration(); } return null; }
/** * Search for the configuration Xpp3 dom of an other plugin. * * @todo there should be a better way to do this * @param project the current maven project to get the configuration from. * @param pluginId the group id and artifact id of the plugin to search for * @return the value of the option configured in the plugin configuration */ public static Xpp3Dom getPluginConfigurationDom( MavenProject project, String pluginId ) { Plugin plugin = (org.apache.maven.model.Plugin) project.getBuild().getPluginsAsMap().get( pluginId ); if ( plugin != null ) { // TODO: This may cause ClassCastExceptions eventually, if the dom impls differ. return (Xpp3Dom) plugin.getConfiguration(); } return null; }
private List<Artifact> collectArtifacts( String hint ) { List<Artifact> artifacts = new ArrayList<>(); PluginManagement pluginManagement = project.getBuild().getPluginManagement(); if ( pluginManagement != null ) { artifacts.addAll( getCheckstylePluginDependenciesAsArtifacts( pluginManagement.getPluginsAsMap(), hint ) ); } artifacts.addAll( getCheckstylePluginDependenciesAsArtifacts( project.getBuild().getPluginsAsMap(), hint ) ); return artifacts; }
@Override public Map<String, Object> getPluginConfiguration(String pluginKey) { Map<String, Plugin> plugins = model.getBuild().getPluginsAsMap(); Plugin plugin = plugins.get(pluginKey); if (plugin == null) { return Collections.emptyMap(); } // get raw configuration Xpp3Dom rawConfiguration = (Xpp3Dom) plugin.getConfiguration(); if (rawConfiguration == null) { return Collections.emptyMap(); } return toMappedConfiguration(rawConfiguration); }
private List<Artifact> collectArtifacts( String hint ) { List<Artifact> artifacts = new ArrayList<>(); PluginManagement pluginManagement = project.getBuild().getPluginManagement(); if ( pluginManagement != null ) { artifacts.addAll( getCheckstylePluginDependenciesAsArtifacts( pluginManagement.getPluginsAsMap(), hint ) ); } artifacts.addAll( getCheckstylePluginDependenciesAsArtifacts( project.getBuild().getPluginsAsMap(), hint ) ); return artifacts; }
@Override public Map<String, Object> getPluginConfiguration(String pluginKey) { Map<String, Plugin> plugins = model.getBuild().getPluginsAsMap(); Plugin plugin = plugins.get(pluginKey); if (plugin == null) { return Collections.emptyMap(); } // get raw configuration Xpp3Dom rawConfiguration = (Xpp3Dom) plugin.getConfiguration(); if (rawConfiguration == null) { return Collections.emptyMap(); } return toMappedConfiguration(rawConfiguration); }
/** * @param p not null * @param pluginId not null key of the plugin defined in {@link org.apache.maven.model.Build#getPluginsAsMap()} * or in {@link org.apache.maven.model.PluginManagement#getPluginsAsMap()} * @return the Maven plugin defined in <code>${project.build.plugins}</code> or in * <code>${project.build.pluginManagement}</code>, or <code>null</code> if not defined. * @since 2.6 */ private static Plugin getPlugin( MavenProject p, String pluginId ) { if ( ( p.getBuild() == null ) || ( p.getBuild().getPluginsAsMap() == null ) ) { return null; } Plugin plugin = p.getBuild().getPluginsAsMap().get( pluginId ); if ( ( plugin == null ) && ( p.getBuild().getPluginManagement() != null ) && ( p.getBuild().getPluginManagement().getPluginsAsMap() != null ) ) { plugin = p.getBuild().getPluginManagement().getPluginsAsMap().get( pluginId ); } return plugin; }
Map<String, Plugin> plugins = project.getBuild().getPluginsAsMap(); Plugin warPlugin = plugins.get( "org.apache.maven.plugins:maven-war-plugin" ); if ( warPlugin == null )
/** * @param pluginId The id of the plugin * @return The information about the plugin. */ protected Plugin getPlugin( String pluginId ) { if ( ( getProject().getBuild() == null ) || ( getProject().getBuild().getPluginsAsMap() == null ) ) { return null; } Plugin plugin = getProject().getBuild().getPluginsAsMap().get( pluginId ); if ( ( plugin == null ) && ( getProject().getBuild().getPluginManagement() != null ) && ( getProject().getBuild().getPluginManagement().getPluginsAsMap() != null ) ) { plugin = getProject().getBuild().getPluginManagement().getPluginsAsMap().get( pluginId ); } return plugin; }
@Override public Collection<Dependency> elements(MavenProjectAdapter project) throws DependencyResolutionRequiredException { Plugin me = (Plugin) project.getBuild().getPluginsAsMap().get("org.scala-tools:maven-scala-plugin"); Set<Dependency> back = new HashSet<Dependency>(); Dependency dep = new Dependency(); dep.setArtifactId(me.getArtifactId()); dep.setGroupId(me.getGroupId()); dep.setVersion(me.getVersion()); back.add(dep); back.addAll((Collection<Dependency>) me.getDependencies()); return back; } };
/** * Returns the rule configurations from the <tt>pluginManagement</tt> as well * as the <tt>plugins</tt> section. * * @param build the build to inspect. * @return configuration of the rules, may be an empty list. */ final List<Xpp3Dom> getRuleConfigurations( final Build build ) { @SuppressWarnings( "unchecked" ) final Map<String, Plugin> plugins = build.getPluginsAsMap(); final List<Xpp3Dom> ruleConfigurationsForPlugins = getRuleConfigurations( plugins ); final PluginManagement pluginManagement = build.getPluginManagement(); if ( pluginManagement != null ) { @SuppressWarnings( "unchecked" ) final Map<String, Plugin> pluginsFromManagementAsMap = pluginManagement.getPluginsAsMap(); List<Xpp3Dom> ruleConfigurationsFromManagement = getRuleConfigurations( pluginsFromManagementAsMap ); ruleConfigurationsForPlugins.addAll( ruleConfigurationsFromManagement ); } return ruleConfigurationsForPlugins; }
/** * Given a plugin, this will retrieve the matching plugin artifact from the model. * * @param plugin plugin to lookup * @param project project to search * @return matching plugin, <code>null</code> if not found. */ protected Plugin findCurrentPlugin( Plugin plugin, MavenProject project ) { Plugin found = null; try { Model model = project.getModel(); Map<String, Plugin> plugins = model.getBuild().getPluginsAsMap(); found = plugins.get( plugin.getKey() ); } catch ( NullPointerException e ) { // nothing to do here } if ( found == null ) { found = resolvePlugin( plugin, project ); } return found; }
/** * Given a plugin, this will retrieve the matching plugin artifact from the model. * * @param plugin plugin to lookup * @param project project to search * @return matching plugin, <code>null</code> if not found. */ protected Plugin findCurrentPlugin( Plugin plugin, MavenProject project ) { Plugin found = null; try { Model model = project.getModel(); @SuppressWarnings( "unchecked" ) Map<String, Plugin> plugins = model.getBuild().getPluginsAsMap(); found = plugins.get( plugin.getKey() ); } catch ( NullPointerException e ) { // nothing to do here } if ( found == null ) { found = resolvePlugin( plugin, project ); } return found; }
public void merge( Model target, Model source, boolean sourceDominant, Map<?, ?> hints ) { Map<Object, Object> context = new HashMap<Object, Object>(); if ( hints != null ) { context.putAll( hints ); } super.merge(target, source, sourceDominant, hints); if (source.getBuild() != null) { super.merge(target, source, sourceDominant,context); for(Plugin sourcePlugin : source.getBuild().getPlugins()) { Plugin targetPlugin = target.getBuild().getPluginsAsMap().get(sourcePlugin.getKey()); super.mergePlugin(targetPlugin, sourcePlugin, sourceDominant, context); Set<Entry<String, PluginExecution>> entrySet = targetPlugin.getExecutionsAsMap().entrySet(); for (Entry<String, PluginExecution> entry : entrySet) { PluginExecution execution = entry.getValue(); if (execution.getConfiguration() == null) { execution.setConfiguration(sourcePlugin.getConfiguration()); } } } } } }
Plugin compiler = getCompilerPlugin( project.getBuild().getPluginsAsMap() ); if ( compiler == null )
Plugin plugin = (Plugin) build.getPluginsAsMap().get( eclipsePlugin ); if ( plugin == null && build.getPluginManagement() != null )
return false; final Plugin plugin = pom.getBuild().getPluginsAsMap().get(getPluginArtifact().toString());