Java 类org.apache.maven.model.PluginExecution 实例源码
项目:EM
文件:DynamicMavenPlugin.java
protected Plugin createPlugin(String groupId, String artifactId, String version, String configuration,
String executionId, String goal, String phase) throws MavenExecutionException {
Plugin plugin = new Plugin();
plugin.setGroupId(groupId);
plugin.setArtifactId(artifactId);
plugin.setVersion(version);
PluginExecution execution = new PluginExecution();
execution.setId(executionId);
execution.addGoal(goal);
if (phase != null) {
execution.setPhase(phase);
}
if (configuration != null) {
execution.setConfiguration(mavenConfig.asXpp3Dom(configuration));
}
plugin.addExecution(execution);
return plugin;
}
项目:incubator-netbeans
文件:PluginPropertyUtils.java
/** @see org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator */
private static @NonNull List<PluginExecution> getPluginExecutions(@NonNull Plugin plug, @NullAllowed String goal) {
if (goal == null) {
return Collections.emptyList();
}
List<PluginExecution> exes = new ArrayList<PluginExecution>();
for (PluginExecution exe : plug.getExecutions()) {
if (exe.getGoals().contains(goal) || /* #179328: Maven 2.2.0+ */ ("default-" + goal).equals(exe.getId())) {
exes.add(exe);
}
}
Collections.sort(exes, new Comparator<PluginExecution>() {
@Override public int compare(PluginExecution e1, PluginExecution e2) {
return e2.getPriority() - e1.getPriority();
}
});
return exes;
}
项目:cdversion-maven-extension
文件:Plugins.java
public Plugin getEnforcerPlugin(MavenProject project)
throws MavenExecutionException {
StringBuilder configString = new StringBuilder()
.append("<configuration><rules>")
.append("<requireReleaseDeps><message>No Snapshots Allowed!</message><excludes><exclude>"+project.getGroupId()+":*</exclude></excludes></requireReleaseDeps>")
.append("</rules></configuration>");
Xpp3Dom config = null;
try {
config = Xpp3DomBuilder.build(new StringReader(configString.toString()));
} catch (XmlPullParserException | IOException ex) {
throw new MavenExecutionException("Issue creating cofig for enforcer plugin", ex);
}
PluginExecution execution = new PluginExecution();
execution.setId("no-snapshot-deps");
execution.addGoal("enforce");
execution.setConfiguration(config);
Plugin result = new Plugin();
result.setArtifactId("maven-enforcer-plugin");
result.setVersion("1.4.1");
result.addExecution(execution);
return result;
}
项目:cdversion-maven-extension
文件:PluginMergerTest.java
@Test
public void testMerge_pluginFoundWithNoExecutions() {
Plugin buildPlugin = new Plugin();
buildPlugin.setArtifactId("merge-artifact");
List<Plugin> plugins = project.getBuild().getPlugins();
plugins.addAll(dummyPlugins);
plugins.add(buildPlugin);
PluginExecution exec = new PluginExecution();
exec.setId("merge-execution-id");
exec.setGoals(Arrays.asList("some-goal"));
exec.setPhase("random-phase");
exec.setPriority(1);
Plugin mergePlugin = new Plugin();
mergePlugin.setArtifactId("merge-artifact");
mergePlugin.getExecutions().add(exec);
item.merge(project, mergePlugin);
Assert.assertEquals("Plugins.Size", dummyPlugins.size() + 1, project.getBuildPlugins().size());
for (int i = 0; i < dummyPlugins.size(); i++) {
Assert.assertThat("Plugins["+i+"]", project.getBuildPlugins().get(i), Matchers.sameBeanAs(dummyPlugins.get(i)));
}
Assert.assertThat("Plugins["+dummyPlugins.size()+"]", project.getBuildPlugins().get(dummyPlugins.size()), Matchers.sameBeanAs(mergePlugin));
}
项目:cdversion-maven-extension
文件:PluginsTest.java
@Test
public void testGetEnforcerPlugin()
throws MavenExecutionException,
XmlPullParserException,
IOException {
Plugin result = item.getEnforcerPlugin();
Assert.assertEquals("GroupId", "org.apache.maven.plugins", result.getGroupId());
Assert.assertEquals("ArtifactId", "maven-enforcer-plugin", result.getArtifactId());
Assert.assertEquals("Version", "1.4.1", result.getVersion());
Assert.assertEquals("Executions.Size", 1, result.getExecutions().size());
PluginExecution execution = result.getExecutions().get(0);
Assert.assertEquals("Executions[0].Id", "no-snapshot-deps", execution.getId());
Assert.assertEquals("Executions[0].Goals.Size", 1, execution.getGoals().size());
Assert.assertEquals("Executions[0].Goals[0]", "enforce", execution.getGoals().get(0));
Assert.assertEquals("Executions[0].Configuration",
Xpp3DomBuilder.build(new StringReader("<configuration><rules><requireReleaseDeps><message>No Snapshots Allowed!</message></requireReleaseDeps></rules></configuration>")),
execution.getConfiguration());
}
项目:cdversion-maven-extension
文件:PluginsTest.java
@Test
public void testGetVersionFixPlugin()
throws MavenExecutionException,
XmlPullParserException,
IOException {
Plugin result = item.getVersionFixPlugin();
Assert.assertEquals("GroupId", "com.iggroup.maven.cdversion", result.getGroupId());
Assert.assertEquals("ArtifactId", "versionfix-maven-plugin", result.getArtifactId());
Assert.assertEquals("Version", "1.0.0-SNAPSHOT", result.getVersion());
Assert.assertEquals("Executions.Size", 1, result.getExecutions().size());
PluginExecution execution = result.getExecutions().get(0);
Assert.assertEquals("Executions[0].Id", "versionfix", execution.getId());
Assert.assertEquals("Executions[0].Goals.Size", 1, execution.getGoals().size());
Assert.assertEquals("Executions[0].Goals[0]", "versionfix", execution.getGoals().get(0));
}
项目:spring-cloud-stream-app-maven-plugin
文件:MavenModelUtils.java
private static Plugin getJavadocPlugin() {
final Plugin javadocPlugin = new Plugin();
javadocPlugin.setGroupId("org.apache.maven.plugins");
javadocPlugin.setArtifactId("maven-javadoc-plugin");
//javadocPlugin.setVersion("2.10.4");
PluginExecution pluginExecution = new PluginExecution();
pluginExecution.setId("javadoc");
List<String> goals = new ArrayList<>();
goals.add("jar");
pluginExecution.setGoals(goals);
pluginExecution.setPhase("package");
List<PluginExecution> pluginExecutions = new ArrayList<>();
pluginExecutions.add(pluginExecution);
javadocPlugin.setExecutions(pluginExecutions);
final Xpp3Dom javadocConfig = new Xpp3Dom("configuration");
final Xpp3Dom quiet = new Xpp3Dom("quiet");
quiet.setValue("true");
javadocConfig.addChild(quiet);
javadocPlugin.setConfiguration(javadocConfig);
return javadocPlugin;
}
项目:spring-cloud-stream-app-maven-plugin
文件:MavenModelUtils.java
private static Plugin getSourcePlugin() {
final Plugin sourcePlugin = new Plugin();
sourcePlugin.setGroupId("org.apache.maven.plugins");
sourcePlugin.setArtifactId("maven-source-plugin");
PluginExecution pluginExecution = new PluginExecution();
pluginExecution.setId("attach-sources");
List<String> goals = new ArrayList<>();
goals.add("jar");
pluginExecution.setGoals(goals);
pluginExecution.setPhase("package");
List<PluginExecution> pluginExecutions = new ArrayList<>();
pluginExecutions.add(pluginExecution);
sourcePlugin.setExecutions(pluginExecutions);
return sourcePlugin;
}
项目:xmvn
文件:DefaultModelProcessor.java
private void visitBuildPluginExecution( ModelVisitor visitor, PluginExecution pluginExecution )
{
List<String> goals = pluginExecution.getGoals();
if ( goals != null )
{
ListIterator<String> goalIterator = goals.listIterator();
while ( goalIterator.hasNext() )
{
String goal = goalIterator.next();
visitor.visitBuildPluginExecutionGoal( goal );
goal = visitor.replaceBuildPluginExecutionGoal( goal );
if ( goal == null )
goalIterator.remove();
else
goalIterator.set( goal );
}
}
}
项目:xmvn
文件:DefaultModelProcessor.java
private void visitBuildPluginManagementPluginExecution( ModelVisitor visitor, PluginExecution pluginExecution )
{
List<String> goals = pluginExecution.getGoals();
if ( goals != null )
{
ListIterator<String> goalIterator = goals.listIterator();
while ( goalIterator.hasNext() )
{
String goal = goalIterator.next();
visitor.visitBuildPluginManagementPluginExecutionGoal( goal );
goal = visitor.replaceBuildPluginManagementPluginExecutionGoal( goal );
if ( goal == null )
goalIterator.remove();
else
goalIterator.set( goal );
}
}
}
项目:xmvn
文件:DefaultModelProcessor.java
private void visitProfileBuildPluginExecution( ModelVisitor visitor, PluginExecution pluginExecution )
{
List<String> goals = pluginExecution.getGoals();
if ( goals != null )
{
ListIterator<String> goalIterator = goals.listIterator();
while ( goalIterator.hasNext() )
{
String goal = goalIterator.next();
visitor.visitProfileBuildPluginExecutionGoal( goal );
goal = visitor.replaceProfileBuildPluginExecutionGoal( goal );
if ( goal == null )
goalIterator.remove();
else
goalIterator.set( goal );
}
}
}
项目:xmvn
文件:DefaultModelProcessor.java
private void visitProfileBuildPluginManagementPluginExecution( ModelVisitor visitor,
PluginExecution pluginExecution )
{
List<String> goals = pluginExecution.getGoals();
if ( goals != null )
{
ListIterator<String> goalIterator = goals.listIterator();
while ( goalIterator.hasNext() )
{
String goal = goalIterator.next();
visitor.visitProfileBuildPluginManagementPluginExecutionGoal( goal );
goal = visitor.replaceProfileBuildPluginManagementPluginExecutionGoal( goal );
if ( goal == null )
goalIterator.remove();
else
goalIterator.set( goal );
}
}
}
项目:extra-enforcer-rules
文件:RequirePropertyDiverges.java
/**
* Returns the list of <tt>requirePropertyDiverges</tt> configurations from the map of plugins.
*
* @param plugins
* @return list of requirePropertyDiverges configurations.
*/
List<Xpp3Dom> getRuleConfigurations( final Map<String, Plugin> plugins )
{
if ( plugins.containsKey( MAVEN_ENFORCER_PLUGIN ) )
{
final List<Xpp3Dom> ruleConfigurations = new ArrayList<Xpp3Dom>();
final Plugin enforcer = plugins.get( MAVEN_ENFORCER_PLUGIN );
final Xpp3Dom configuration = ( Xpp3Dom ) enforcer.getConfiguration();
// add rules from plugin configuration
addRules( configuration, ruleConfigurations );
// add rules from all plugin execution configurations
for ( Object execution : enforcer.getExecutions() )
{
addRules( ( Xpp3Dom ) ( ( PluginExecution ) execution ).getConfiguration(), ruleConfigurations );
}
return ruleConfigurations;
}
else
{
return new ArrayList();
}
}
项目:extra-enforcer-rules
文件:RequirePropertyDivergesTest.java
/**
* Test of execute method, of class RequirePropertyDiverges.
*/
@Test
public void testExecuteInParentWithConfigurationInExecution() throws EnforcerRuleException
{
RequirePropertyDiverges mockInstance = createMockRule();
final MavenProject project = createMavenProject( "company", "company-parent-pom" );
final Build build = new Build();
build.setPluginManagement( new PluginManagement() );
final Plugin plugin = newPlugin( "org.apache.maven.plugins", "maven-enforcer-plugin", "1.0" );
final Xpp3Dom configuration = createPluginConfiguration();
PluginExecution pluginExecution = new PluginExecution();
pluginExecution.setConfiguration( configuration );
plugin.addExecution( pluginExecution );
build.addPlugin( plugin );
project.getOriginalModel().setBuild( build );
setUpHelper(project, "parentValue");
mockInstance.execute( helper );
}
项目:developer-studio
文件:MavenUtils.java
public static void addMavenBpelPlugin(MavenProject mavenProject){
Plugin plugin;
PluginExecution pluginExecution;
plugin = MavenUtils.createPluginEntry(mavenProject, GROUP_ID_ORG_WSO2_MAVEN, ARTIFACT_ID_MAVEN_BPEL_PLUGIN,
WSO2MavenPluginVersions.getPluginVersion(ARTIFACT_ID_MAVEN_BPEL_PLUGIN), true);
// FIXME : remove hard-coded version value (cannot use
// org.wso2.developerstudio.eclipse.capp.maven.utils.MavenConstants
// due to cyclic reference)
// pluginExecution=new PluginExecution();
// pluginExecution.addGoal("bpel");
// pluginExecution.setPhase("package");
// pluginExecution.setId("bpel");
// plugin.addExecution(pluginExecution)
mavenProject.getModel().addProperty(PROPERTY_CAPP_TYPE, "bpel/workflow");
}
项目:srclib-java
文件:Antlr4MavenPlugin.java
/**
* @param project Maven project
* @return generated sources directory retrieved from ANTLR plugin's configuration
*/
private String getGeneratedSourceDirectory(MavenProject project) {
Plugin buildHelper = getPlugin(project);
if (buildHelper == null) {
return getDefaultGeneratedSourceDirectory(project);
}
for (PluginExecution pluginExecution : buildHelper.getExecutions()) {
Object configuration = pluginExecution.getConfiguration();
if (configuration == null || !(configuration instanceof Xpp3Dom)) {
continue;
}
Xpp3Dom xmlConfiguration = (Xpp3Dom) configuration;
Xpp3Dom outputDirectory = xmlConfiguration.getChild("outputDirectory");
if (outputDirectory != null) {
return PathUtil.CWD.resolve(outputDirectory.getValue()).toAbsolutePath().toString();
}
}
return getDefaultGeneratedSourceDirectory(project);
}
项目:oceano
文件:EmptyLifecycleExecutor.java
private Plugin newPlugin( String artifactId, String... goals )
{
Plugin plugin = new Plugin();
plugin.setGroupId( "org.apache.maven.plugins" );
plugin.setArtifactId( artifactId );
for ( String goal : goals )
{
PluginExecution pluginExecution = new PluginExecution();
pluginExecution.setId( "default-" + goal );
pluginExecution.addGoal( goal );
plugin.addExecution( pluginExecution );
}
return plugin;
}
项目:oceano
文件:EmptyLifecyclePluginAnalyzer.java
private Plugin newPlugin( String artifactId, String... goals )
{
Plugin plugin = new Plugin();
plugin.setGroupId( "org.apache.maven.plugins" );
plugin.setArtifactId( artifactId );
for ( String goal : goals )
{
PluginExecution pluginExecution = new PluginExecution();
pluginExecution.setId( "default-" + goal );
pluginExecution.addGoal( goal );
plugin.addExecution( pluginExecution );
}
return plugin;
}
项目:oceano
文件:ModelUtilsTest.java
public void testShouldInheritOnePluginWithExecution()
{
Plugin parent = new Plugin();
parent.setArtifactId( "testArtifact" );
parent.setGroupId( "testGroup" );
parent.setVersion( "1.0" );
PluginExecution parentExecution = new PluginExecution();
parentExecution.setId( "testExecution" );
parent.addExecution( parentExecution );
Plugin child = new Plugin();
child.setArtifactId( "testArtifact" );
child.setGroupId( "testGroup" );
child.setVersion( "1.0" );
ModelUtils.mergePluginDefinitions( child, parent, false );
assertEquals( 1, child.getExecutions().size() );
}
项目:oceano
文件:ModelUtilsTest.java
public void testShouldMergeInheritedPluginHavingExecutionWithLocalPlugin()
{
Plugin parent = new Plugin();
parent.setArtifactId( "testArtifact" );
parent.setGroupId( "testGroup" );
parent.setVersion( "1.0" );
PluginExecution parentExecution = new PluginExecution();
parentExecution.setId( "testExecution" );
parent.addExecution( parentExecution );
Plugin child = new Plugin();
child.setArtifactId( "testArtifact" );
child.setGroupId( "testGroup" );
child.setVersion( "1.0" );
PluginExecution childExecution = new PluginExecution();
childExecution.setId( "testExecution2" );
child.addExecution( childExecution );
ModelUtils.mergePluginDefinitions( child, parent, false );
assertEquals( 2, child.getExecutions().size() );
}
项目:oceano
文件:ModelUtilsTest.java
public void testShouldNOTMergeInheritedPluginHavingInheritEqualFalse()
{
Plugin parent = new Plugin();
parent.setArtifactId( "testArtifact" );
parent.setGroupId( "testGroup" );
parent.setVersion( "1.0" );
parent.setInherited( "false" );
PluginExecution parentExecution = new PluginExecution();
parentExecution.setId( "testExecution" );
parent.addExecution( parentExecution );
Plugin child = new Plugin();
child.setArtifactId( "testArtifact" );
child.setGroupId( "testGroup" );
child.setVersion( "1.0" );
ModelUtils.mergePluginDefinitions( child, parent, true );
assertEquals( 0, child.getExecutions().size() );
}
项目:oceano
文件:DefaultLifecyclePluginAnalyzer.java
private String getExecutionId( Plugin plugin, String goal )
{
Set<String> existingIds = new HashSet<String>();
for ( PluginExecution execution : plugin.getExecutions() )
{
existingIds.add( execution.getId() );
}
String base = "default-" + goal;
String id = base;
for ( int index = 1; existingIds.contains( id ); index++ )
{
id = base + '-' + index;
}
return id;
}
项目:oceano
文件:DefaultBeanConfigurationRequest.java
/**
* Sets the configuration to the configuration taken from the specified build plugin in the POM. First, the build
* plugins will be searched for the specified plugin, if that fails, the plugin management section will be searched.
*
* @param model The POM to extract the plugin configuration from, may be {@code null}.
* @param pluginGroupId The group id of the plugin whose configuration should be used, must not be {@code null} or
* empty.
* @param pluginArtifactId The artifact id of the plugin whose configuration should be used, must not be
* {@code null} or empty.
* @param pluginExecutionId The id of a plugin execution whose configuration should be used, may be {@code null} or
* empty to use the general plugin configuration.
* @return This request for chaining, never {@code null}.
*/
public DefaultBeanConfigurationRequest setConfiguration( Model model, String pluginGroupId,
String pluginArtifactId, String pluginExecutionId )
{
Plugin plugin = findPlugin( model, pluginGroupId, pluginArtifactId );
if ( plugin != null )
{
if ( StringUtils.isNotEmpty( pluginExecutionId ) )
{
for ( PluginExecution execution : plugin.getExecutions() )
{
if ( pluginExecutionId.equals( execution.getId() ) )
{
setConfiguration( execution.getConfiguration() );
break;
}
}
}
else
{
setConfiguration( plugin.getConfiguration() );
}
}
return this;
}
项目:oceano
文件:LifeCyclePluginAnalyzerStub.java
private Plugin newPlugin( String artifactId, String... goals )
{
Plugin plugin = new Plugin();
plugin.setGroupId( "org.apache.maven.plugins" );
plugin.setArtifactId( artifactId );
for ( String goal : goals )
{
PluginExecution pluginExecution = new PluginExecution();
pluginExecution.setId( "default-" + goal );
pluginExecution.addGoal( goal );
plugin.addExecution( pluginExecution );
}
return plugin;
}
项目:oceano
文件:EmptyLifecyclePluginAnalyzer.java
private Plugin newPlugin( String artifactId, String... goals )
{
Plugin plugin = new Plugin();
plugin.setGroupId( "org.apache.maven.plugins" );
plugin.setArtifactId( artifactId );
for ( String goal : goals )
{
PluginExecution pluginExecution = new PluginExecution();
pluginExecution.setId( "default-" + goal );
pluginExecution.addGoal( goal );
plugin.addExecution( pluginExecution );
}
return plugin;
}
项目:oceano
文件:EmptyLifecycleExecutor.java
private Plugin newPlugin( String artifactId, String... goals )
{
Plugin plugin = new Plugin();
plugin.setGroupId( "org.apache.maven.plugins" );
plugin.setArtifactId( artifactId );
for ( String goal : goals )
{
PluginExecution pluginExecution = new PluginExecution();
pluginExecution.setId( "default-" + goal );
pluginExecution.addGoal( goal );
plugin.addExecution( pluginExecution );
}
return plugin;
}
项目:oceano
文件:DefaultPluginConfigurationExpander.java
private void expand( List<Plugin> plugins )
{
for ( Plugin plugin : plugins )
{
Xpp3Dom pluginConfiguration = (Xpp3Dom) plugin.getConfiguration();
if ( pluginConfiguration != null )
{
for ( PluginExecution execution : plugin.getExecutions() )
{
Xpp3Dom executionConfiguration = (Xpp3Dom) execution.getConfiguration();
executionConfiguration =
Xpp3Dom.mergeXpp3Dom( executionConfiguration, new Xpp3Dom( pluginConfiguration ) );
execution.setConfiguration( executionConfiguration );
}
}
}
}
项目:oceano
文件:MavenModelMerger.java
@Override
protected void mergePluginExecution_Goals( PluginExecution target, PluginExecution source, boolean sourceDominant,
Map<Object, Object> context )
{
List<String> src = source.getGoals();
if ( !src.isEmpty() )
{
List<String> tgt = target.getGoals();
Set<String> excludes = new LinkedHashSet<String>( tgt );
List<String> merged = new ArrayList<String>( tgt.size() + src.size() );
merged.addAll( tgt );
for ( String s : src )
{
if ( !excludes.contains( s ) )
{
merged.add( s );
}
}
target.setGoals( merged );
}
}
项目:wisdom
文件:PluginExtractor.java
/**
* 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;
}
项目:kie-wb-common
文件:DefaultPomEditor.java
protected Plugin getNewCompilerPlugin() {
Plugin newCompilerPlugin = new Plugin();
newCompilerPlugin.setGroupId(conf.get(ConfigurationKey.ALTERNATIVE_COMPILER_PLUGINS));
newCompilerPlugin.setArtifactId(conf.get(ConfigurationKey.ALTERNATIVE_COMPILER_PLUGIN));
newCompilerPlugin.setVersion(conf.get(ConfigurationKey.ALTERNATIVE_COMPILER_PLUGIN_VERSION));
PluginExecution execution = new PluginExecution();
execution.setId(MavenCLIArgs.COMPILE);
execution.setGoals(Arrays.asList(MavenCLIArgs.COMPILE));
execution.setPhase(MavenCLIArgs.COMPILE);
Xpp3Dom compilerId = new Xpp3Dom(MavenConfig.MAVEN_COMPILER_ID);
compilerId.setValue(compiler.name().toLowerCase());
Xpp3Dom configuration = new Xpp3Dom(MavenConfig.MAVEN_PLUGIN_CONFIGURATION);
configuration.addChild(compilerId);
execution.setConfiguration(configuration);
newCompilerPlugin.setExecutions(Arrays.asList(execution));
return newCompilerPlugin;
}
项目:kie-wb-common
文件:DefaultPomEditor.java
protected void disableMavenCompilerAlreadyPresent(Plugin plugin) {
Xpp3Dom skipMain = new Xpp3Dom(MavenConfig.MAVEN_SKIP_MAIN);
skipMain.setValue(TRUE);
Xpp3Dom skip = new Xpp3Dom(MavenConfig.MAVEN_SKIP);
skip.setValue(TRUE);
Xpp3Dom configuration = new Xpp3Dom(MavenConfig.MAVEN_PLUGIN_CONFIGURATION);
configuration.addChild(skipMain);
configuration.addChild(skip);
plugin.setConfiguration(configuration);
PluginExecution exec = new PluginExecution();
exec.setId(MavenConfig.MAVEN_DEFAULT_COMPILE);
exec.setPhase(MavenConfig.MAVEN_PHASE_NONE);
List<PluginExecution> executions = new ArrayList<>();
executions.add(exec);
plugin.setExecutions(executions);
}
项目:incubator-netbeans
文件:LocationAwareMavenXpp3Writer.java
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());
}
项目:cdversion-maven-extension
文件:PluginMerger.java
private void mergeExecutions(
List<PluginExecution> executions,
List<PluginExecution> mergeExecution) {
Map<String, PluginExecution> executionMap = convertToMap(executions);
Map<String, PluginExecution> mergeExecutionMap = convertToMap(mergeExecution);
for (String mergeKey : mergeExecutionMap.keySet()) {
if (!executionMap.containsKey(mergeKey)) {
executions.add(mergeExecutionMap.get(mergeKey));
}
}
}
项目:cdversion-maven-extension
文件:PluginMerger.java
private Map<String, PluginExecution> convertToMap(List<PluginExecution> executions) {
Map<String, PluginExecution> result = new LinkedHashMap();
for (PluginExecution pluginExecution : executions) {
result.put(pluginExecution.getId(), pluginExecution);
}
return result;
}
项目:cdversion-maven-extension
文件:Plugins.java
public Plugin getVersionFixPlugin() {
PluginExecution execution = new PluginExecution();
execution.setId("versionfix");
execution.addGoal("versionfix");
Plugin result = new Plugin();
result.setGroupId("com.iggroup.maven.cdversion");
result.setArtifactId("versionfix-maven-plugin");
result.setVersion("${project.version}");
result.addExecution(execution);
return result;
}
项目:cdversion-maven-extension
文件:PluginMergerTest.java
@Test
public void testMerge_pluginFoundWithExecutions() {
PluginExecution buildExec = new PluginExecution();
buildExec.setId("random-execution-id");
buildExec.setGoals(Arrays.asList("some-goal"));
buildExec.setPhase("random-phase");
buildExec.setPriority(1);
Plugin buildPlugin = new Plugin();
buildPlugin.setArtifactId("merge-artifact");
buildPlugin.addExecution(buildExec);
List<Plugin> plugins = project.getBuild().getPlugins();
plugins.addAll(dummyPlugins);
plugins.add(buildPlugin);
PluginExecution mergeExec = new PluginExecution();
mergeExec.setId("merge-execution-id");
mergeExec.setGoals(Arrays.asList("some-goal"));
mergeExec.setPhase("random-phase");
mergeExec.setPriority(1);
Plugin mergePlugin = new Plugin();
mergePlugin.setArtifactId("merge-artifact");
mergePlugin.getExecutions().add(mergeExec);
item.merge(project, mergePlugin);
Plugin expectedPlugin = new Plugin();
expectedPlugin.setArtifactId("merge-artifact");
expectedPlugin.getExecutions().add(buildExec);
expectedPlugin.getExecutions().add(mergeExec);
Assert.assertEquals("Plugins.Size", dummyPlugins.size() + 1, project.getBuildPlugins().size());
for (int i = 0; i < dummyPlugins.size(); i++) {
Assert.assertThat("Plugins["+i+"]", project.getBuildPlugins().get(i), Matchers.sameBeanAs(dummyPlugins.get(i)));
}
Assert.assertThat("Plugins["+dummyPlugins.size()+"]", project.getBuildPlugins().get(dummyPlugins.size()), Matchers.sameBeanAs(expectedPlugin));
}
项目:cdversion-maven-extension
文件:PluginMergerTest.java
@Test
public void testMerge_pluginFoundWithConflictingExecutions() {
PluginExecution buildExec = new PluginExecution();
buildExec.setId("merge-execution-id");
buildExec.setGoals(Arrays.asList("original-goal"));
buildExec.setPhase("original-phase");
buildExec.setPriority(1);
Plugin buildPlugin = new Plugin();
buildPlugin.setArtifactId("merge-artifact");
buildPlugin.addExecution(buildExec);
List<Plugin> plugins = project.getBuild().getPlugins();
plugins.addAll(dummyPlugins);
plugins.add(buildPlugin);
PluginExecution mergeExec = new PluginExecution();
mergeExec.setId("merge-execution-id");
mergeExec.setGoals(Arrays.asList("merge-goal"));
mergeExec.setPhase("merge-phase");
mergeExec.setPriority(2);
Plugin mergePlugin = new Plugin();
mergePlugin.setArtifactId("merge-artifact");
mergePlugin.getExecutions().add(mergeExec);
item.merge(project, mergePlugin);
Plugin expectedPlugin = new Plugin();
expectedPlugin.setArtifactId("merge-artifact");
expectedPlugin.getExecutions().add(buildExec);
Assert.assertEquals("Plugins.Size", dummyPlugins.size() + 1, project.getBuildPlugins().size());
for (int i = 0; i < dummyPlugins.size(); i++) {
Assert.assertThat("Plugins["+i+"]", project.getBuildPlugins().get(i), Matchers.sameBeanAs(dummyPlugins.get(i)));
}
Assert.assertThat("Plugins["+dummyPlugins.size()+"]", project.getBuildPlugins().get(dummyPlugins.size()), Matchers.sameBeanAs(expectedPlugin));
}
项目:apache-maven-shade-plugin
文件:MavenJDOMWriter.java
/**
* Method updatePluginExecution
*
* @param value
* @param element
* @param counter
* @param xmlTag
*/
protected void updatePluginExecution( PluginExecution value, String xmlTag, Counter counter, Element element )
{
Element root = element;
Counter innerCount = new Counter( counter.getDepth() + 1 );
findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), "default" );
findAndReplaceSimpleElement( innerCount, root, "phase", value.getPhase(), null );
findAndReplaceSimpleLists( innerCount, root, value.getGoals(), "goals", "goal" );
findAndReplaceSimpleElement( innerCount, root, "inherited", value.getInherited(), null );
findAndReplaceXpp3DOM( innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration() );
}
项目:xmvn
文件:DefaultModelProcessor.java
private void visitBuildPlugin( ModelVisitor visitor, Plugin plugin )
{
List<PluginExecution> executions = plugin.getExecutions();
if ( executions != null )
{
ListIterator<PluginExecution> executionIterator = executions.listIterator();
while ( executionIterator.hasNext() )
{
PluginExecution execution = executionIterator.next();
visitor.visitBuildPluginExecution( execution );
visitBuildPluginExecution( visitor, execution );
execution = visitor.replaceBuildPluginExecution( execution );
if ( execution == null )
executionIterator.remove();
else
executionIterator.set( execution );
}
}
List<Dependency> dependencies = plugin.getDependencies();
if ( dependencies != null )
{
ListIterator<Dependency> dependencyIterator = dependencies.listIterator();
while ( dependencyIterator.hasNext() )
{
Dependency dependency = dependencyIterator.next();
visitor.visitBuildPluginDependency( dependency );
visitBuildPluginDependency( visitor, dependency );
dependency = visitor.replaceBuildPluginDependency( dependency );
if ( dependency == null )
dependencyIterator.remove();
else
dependencyIterator.set( dependency );
}
}
}
项目:xmvn
文件:DefaultModelProcessor.java
private void visitBuildPluginManagementPlugin( ModelVisitor visitor, Plugin plugin )
{
List<PluginExecution> executions = plugin.getExecutions();
if ( executions != null )
{
ListIterator<PluginExecution> executionIterator = executions.listIterator();
while ( executionIterator.hasNext() )
{
PluginExecution execution = executionIterator.next();
visitor.visitBuildPluginManagementPluginExecution( execution );
visitBuildPluginManagementPluginExecution( visitor, execution );
execution = visitor.replaceBuildPluginManagementPluginExecution( execution );
if ( execution == null )
executionIterator.remove();
else
executionIterator.set( execution );
}
}
List<Dependency> dependencies = plugin.getDependencies();
if ( dependencies != null )
{
ListIterator<Dependency> dependencyIterator = dependencies.listIterator();
while ( dependencyIterator.hasNext() )
{
Dependency dependency = dependencyIterator.next();
visitor.visitBuildPluginManagementPluginDependency( dependency );
visitBuildPluginManagementPluginDependency( visitor, dependency );
dependency = visitor.replaceBuildPluginManagementPluginDependency( dependency );
if ( dependency == null )
dependencyIterator.remove();
else
dependencyIterator.set( dependency );
}
}
}