org.apache.maven.model.PluginExecution Java Examples
The following examples show how to use
org.apache.maven.model.PluginExecution.
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: MavenUtils.java From developer-studio with Apache License 2.0 | 6 votes |
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"); }
Example #2
Source File: CreateMavenBundlePom.java From tesb-studio-se with Apache License 2.0 | 6 votes |
private Plugin addOsgiHelperMavenPlugin() { Plugin plugin = new Plugin(); plugin.setGroupId("org.talend.ci"); plugin.setArtifactId("osgihelper-maven-plugin"); plugin.setVersion(VersionUtils.getMojoVersion("osgihelper.version")); Xpp3Dom configuration = new Xpp3Dom("configuration"); Xpp3Dom featuresFile = new Xpp3Dom("featuresFile"); featuresFile.setValue(PATH_FEATURE); configuration.addChild(featuresFile); List<PluginExecution> pluginExecutions = new ArrayList<PluginExecution>(); PluginExecution pluginExecution = new PluginExecution(); pluginExecution.setId("feature-helper"); pluginExecution.setPhase("generate-sources"); pluginExecution.addGoal("generate"); pluginExecution.setConfiguration(configuration); pluginExecutions.add(pluginExecution); plugin.setExecutions(pluginExecutions); return plugin; }
Example #3
Source File: RequirePropertyDivergesTest.java From extra-enforcer-rules with Apache License 2.0 | 6 votes |
/** * 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 ); }
Example #4
Source File: RequirePropertyDiverges.java From extra-enforcer-rules with Apache License 2.0 | 6 votes |
/** * 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(); } }
Example #5
Source File: GitVersioningModelProcessor.java From maven-git-versioning-extension with MIT License | 6 votes |
private void addBuildPlugin(Model model, boolean updatePomOption) { logger.debug(model.getArtifactId() + " temporary add build plugin"); Plugin plugin = asPlugin(); PluginExecution execution = new PluginExecution(); execution.setId(GOAL); execution.getGoals().add(GOAL); plugin.getExecutions().add(execution); if (model.getBuild() == null) { model.setBuild(new Build()); } model.getBuild().getPlugins().add(plugin); // set plugin properties model.getProperties().setProperty(propertyKeyPrefix + propertyKeyUpdatePom, Boolean.toString(updatePomOption)); }
Example #6
Source File: UnchangedProjectsRemoverTest.java From gitflow-incremental-builder with MIT License | 6 votes |
@Test public void singleChanged_buildUpstream_skipTestsForUpstreamModules_jarGoal() throws GitAPIException, IOException { MavenProject changedModuleMock = addModuleMock(AID_MODULE_B, true); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_UPSTREAM); addGibProperty(Property.skipTestsForUpstreamModules, "true"); Plugin pluginMock = mock(Plugin.class); PluginExecution execMock = mock(PluginExecution.class); when(execMock.getGoals()).thenReturn(Collections.singletonList("test-jar")); when(pluginMock.getExecutions()).thenReturn(Collections.singletonList(execMock)); when(moduleA.getBuildPlugins()).thenReturn(Collections.singletonList(pluginMock)); underTest.act(); verify(mavenSessionMock).setProjects(Arrays.asList(moduleA, changedModuleMock)); assertProjectPropertiesEqual(moduleA, ImmutableMap.of("skipTests", "true")); assertProjectPropertiesEqual(changedModuleMock, Collections.emptyMap()); }
Example #7
Source File: CreateMavenDataServicePom.java From tesb-studio-se with Apache License 2.0 | 6 votes |
private Plugin addOsgiHelperMavenPlugin() { Plugin plugin = new Plugin(); plugin.setGroupId("org.talend.ci"); plugin.setArtifactId("osgihelper-maven-plugin"); plugin.setVersion(VersionUtils.getMojoVersion("osgihelper.version")); Xpp3Dom configuration = new Xpp3Dom("configuration"); Xpp3Dom featuresFile = new Xpp3Dom("featuresFile"); featuresFile.setValue("${basedir}/src/main/resources/feature/feature.xml"); configuration.addChild(featuresFile); List<PluginExecution> pluginExecutions = new ArrayList<PluginExecution>(); PluginExecution pluginExecution = new PluginExecution(); pluginExecution.setId("feature-helper"); pluginExecution.setPhase("generate-sources"); pluginExecution.addGoal("generate"); pluginExecution.setConfiguration(configuration); pluginExecutions.add(pluginExecution); plugin.setExecutions(pluginExecutions); return plugin; }
Example #8
Source File: PluginPropertyUtils.java From netbeans with Apache License 2.0 | 6 votes |
/** @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; }
Example #9
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 #10
Source File: PomChangePluginTest.java From butterfly with MIT License | 6 votes |
@Test public void changeExecutionsTest() throws IOException, XmlPullParserException { final PluginExecution pluginExecution = new PluginExecution(); pluginExecution.setId("test-execution"); pluginExecution.setPhase("build"); pluginExecution.addGoal("clean install"); List<PluginExecution> executions = new ArrayList<PluginExecution>(){{ add(pluginExecution); }}; PomChangePlugin uut = new PomChangePlugin("org.codehaus.mojo", "build-helper-maven-plugin").relative("pom.xml").setExecutions(executions); assertFalse(getPluginBeforeChange(uut).getExecutions().isEmpty()); assertNotEquals(getPluginBeforeChange(uut).getExecutions().size(), executions.size()); assertFalse(getPluginBeforeChange(uut).getExecutionsAsMap().containsKey(pluginExecution.getId())); executeAndAssertSuccess(uut); assertFalse(getPluginAfterChange(uut).getExecutions().isEmpty()); assertNotEquals(getPluginBeforeChange(uut).getExecutions().size(), getPluginAfterChange(uut).getExecutions().size()); assertEquals(getPluginAfterChange(uut).getExecutions().size(), executions.size()); assertTrue(getPluginAfterChange(uut).getExecutionsAsMap().containsKey(pluginExecution.getId())); }
Example #11
Source File: RequiredMavenVersionFinderTest.java From versions-maven-plugin with Apache License 2.0 | 6 votes |
@Test public void findReturnsValueWhenSecondEnforcerExecutionIsValidAndFirstEnforcerExecutionHasNoRulesTag() { String mavenVersionRange = "1.0"; ArrayList<Plugin> buildPlugins = new ArrayList<>(); buildPlugins.add(enforcerPlugin); when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); ArrayList<PluginExecution> pluginExecutions = new ArrayList<>(); pluginExecutions.add(otherPluginExecution); pluginExecutions.add(pluginExecution); ArrayList<String> goals = new ArrayList<>(); ArrayList<String> otherGoals = new ArrayList<>(); goals.add("enforce"); otherGoals.add("enforce"); when(pluginExecution.getGoals()).thenReturn(goals); when(otherPluginExecution.getGoals()).thenReturn(otherGoals); when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); when(pluginExecution.getConfiguration()).thenReturn(configurationTag); when(otherPluginExecution.getConfiguration()).thenReturn(otherConfigurationTag); when(configurationTag.getChild("rules")).thenReturn(rulesTag); when(otherConfigurationTag.getChild("rules")).thenReturn(null); when(rulesTag.getChild("requireMavenVersion")).thenReturn(requireMavenVersionTag); when(requireMavenVersionTag.getChild("version")).thenReturn(versionTag); when(versionTag.getValue()).thenReturn(mavenVersionRange); DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(mavenVersionRange); assertEquals(artifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); }
Example #12
Source File: RequiredMavenVersionFinderTest.java From versions-maven-plugin with Apache License 2.0 | 6 votes |
@Test public void findReturnsValueWhenSecondEnforcerExecutionIsValidAndFirstEnforcerExecutionHasNoConfigurationTag() { String mavenVersionRange = "1.0"; ArrayList<Plugin> buildPlugins = new ArrayList<>(); buildPlugins.add(enforcerPlugin); when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); ArrayList<PluginExecution> pluginExecutions = new ArrayList<>(); pluginExecutions.add(otherPluginExecution); pluginExecutions.add(pluginExecution); ArrayList<String> goals = new ArrayList<>(); ArrayList<String> otherGoals = new ArrayList<>(); goals.add("enforce"); otherGoals.add("enforce"); when(pluginExecution.getGoals()).thenReturn(goals); when(otherPluginExecution.getGoals()).thenReturn(otherGoals); when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); when(pluginExecution.getConfiguration()).thenReturn(configurationTag); when(otherPluginExecution.getConfiguration()).thenReturn(null); when(configurationTag.getChild("rules")).thenReturn(rulesTag); when(rulesTag.getChild("requireMavenVersion")).thenReturn(requireMavenVersionTag); when(requireMavenVersionTag.getChild("version")).thenReturn(versionTag); when(versionTag.getValue()).thenReturn(mavenVersionRange); DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(mavenVersionRange); assertEquals(artifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); }
Example #13
Source File: RequiredMavenVersionFinderTest.java From versions-maven-plugin with Apache License 2.0 | 6 votes |
private void findReturnsValueWhenVersionTagValueIsSet(String mavenVersionRange) { ArrayList<Plugin> buildPlugins = new ArrayList<>(); buildPlugins.add(enforcerPlugin); when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); ArrayList<PluginExecution> pluginExecutions = new ArrayList<>(); pluginExecutions.add(pluginExecution); ArrayList<String> goals = new ArrayList<>(); goals.add("enforce"); when(pluginExecution.getGoals()).thenReturn(goals); when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); when(pluginExecution.getConfiguration()).thenReturn(configurationTag); when(configurationTag.getChild("rules")).thenReturn(rulesTag); when(rulesTag.getChild("requireMavenVersion")).thenReturn(requireMavenVersionTag); when(requireMavenVersionTag.getChild("version")).thenReturn(versionTag); when(versionTag.getValue()).thenReturn(mavenVersionRange); }
Example #14
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 #15
Source File: RequiredMavenVersionFinderTest.java From versions-maven-plugin with Apache License 2.0 | 6 votes |
@Test public void findReturnsNullWhenVersionChildIsNull() { ArrayList<Plugin> buildPlugins = new ArrayList<>(); buildPlugins.add(enforcerPlugin); when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); ArrayList<PluginExecution> pluginExecutions = new ArrayList<>(); pluginExecutions.add(pluginExecution); ArrayList<String> goals = new ArrayList<>(); goals.add("enforce"); when(pluginExecution.getGoals()).thenReturn(goals); when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); when(pluginExecution.getConfiguration()).thenReturn(configurationTag); when(configurationTag.getChild("rules")).thenReturn(rulesTag); when(rulesTag.getChild("requireMavenVersion")).thenReturn(requireMavenVersionTag); when(requireMavenVersionTag.getChild("version")).thenReturn(null); assertNull(new RequiredMavenVersionFinder(mavenProject).find()); }
Example #16
Source File: RequiredMavenVersionFinderTest.java From versions-maven-plugin with Apache License 2.0 | 6 votes |
@Test public void findReturnsNullWhenRequiredMavenVersionChildIsNull() { ArrayList<Plugin> buildPlugins = new ArrayList<>(); buildPlugins.add(enforcerPlugin); when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); ArrayList<PluginExecution> pluginExecutions = new ArrayList<>(); pluginExecutions.add(pluginExecution); ArrayList<String> goals = new ArrayList<>(); goals.add("enforce"); when(pluginExecution.getGoals()).thenReturn(goals); when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); when(pluginExecution.getConfiguration()).thenReturn(configurationTag); when(configurationTag.getChild("rules")).thenReturn(rulesTag); when(rulesTag.getChild("requireMavenVersion")).thenReturn(null); assertNull(new RequiredMavenVersionFinder(mavenProject).find()); }
Example #17
Source File: CreateMavenDataServicePom.java From tesb-studio-se with Apache License 2.0 | 5 votes |
private Plugin addFeaturesMavenPlugin() { Plugin plugin = new Plugin(); plugin.setGroupId("org.apache.karaf.tooling"); plugin.setArtifactId("karaf-maven-plugin"); plugin.setVersion("4.2.4"); Xpp3Dom configuration = new Xpp3Dom("configuration"); Xpp3Dom resourcesDir = new Xpp3Dom("resourcesDir"); resourcesDir.setValue("${project.build.directory}/bin"); Xpp3Dom featuresFile = new Xpp3Dom("featuresFile"); featuresFile.setValue("${basedir}/src/main/resources/feature/feature.xml"); configuration.addChild(resourcesDir); configuration.addChild(featuresFile); List<PluginExecution> pluginExecutions = new ArrayList<PluginExecution>(); PluginExecution pluginExecution = new PluginExecution(); pluginExecution.setId("create-kar"); pluginExecution.addGoal("kar"); pluginExecution.setConfiguration(configuration); pluginExecutions.add(pluginExecution); plugin.setExecutions(pluginExecutions); return plugin; }
Example #18
Source File: RequiredMavenVersionFinderTest.java From versions-maven-plugin with Apache License 2.0 | 5 votes |
@Test public void findReturnsValueWhenSecondEnforcerExecutionIsValidAndFirstEnforcerExecutionHasNoRequireMavenVersionTag() { String mavenVersionRange = "1.0"; ArrayList<Plugin> buildPlugins = new ArrayList<>(); buildPlugins.add(enforcerPlugin); when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); ArrayList<PluginExecution> pluginExecutions = new ArrayList<>(); pluginExecutions.add(otherPluginExecution); pluginExecutions.add(pluginExecution); ArrayList<String> goals = new ArrayList<>(); ArrayList<String> otherGoals = new ArrayList<>(); goals.add("enforce"); otherGoals.add("enforce"); when(pluginExecution.getGoals()).thenReturn(goals); when(otherPluginExecution.getGoals()).thenReturn(otherGoals); when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); when(pluginExecution.getConfiguration()).thenReturn(configurationTag); when(otherPluginExecution.getConfiguration()).thenReturn(otherConfigurationTag); when(configurationTag.getChild("rules")).thenReturn(rulesTag); when(otherConfigurationTag.getChild("rules")).thenReturn(otherRulesTag); when(rulesTag.getChild("requireMavenVersion")).thenReturn(requireMavenVersionTag); when(otherRulesTag.getChild("requireMavenVersion")).thenReturn(null); when(requireMavenVersionTag.getChild("version")).thenReturn(versionTag); when(versionTag.getValue()).thenReturn(mavenVersionRange); DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(mavenVersionRange); assertEquals(artifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); }
Example #19
Source File: CreateMavenBundlePom.java From tesb-studio-se with Apache License 2.0 | 5 votes |
private Plugin addFeaturesMavenPlugin(String finalNameValue) { Plugin plugin = new Plugin(); plugin.setGroupId("org.apache.karaf.tooling"); plugin.setArtifactId("karaf-maven-plugin"); plugin.setVersion("4.2.4"); Xpp3Dom configuration = new Xpp3Dom("configuration"); Xpp3Dom finalName = new Xpp3Dom("finalName"); finalName.setValue(finalNameValue);// "${talend.job.finalName}" Xpp3Dom resourcesDir = new Xpp3Dom("resourcesDir"); resourcesDir.setValue("${project.build.directory}/bin"); Xpp3Dom featuresFile = new Xpp3Dom("featuresFile"); featuresFile.setValue(PATH_FEATURE); configuration.addChild(finalName); configuration.addChild(resourcesDir); configuration.addChild(featuresFile); List<PluginExecution> pluginExecutions = new ArrayList<PluginExecution>(); PluginExecution pluginExecution = new PluginExecution(); pluginExecution.setId("create-kar"); pluginExecution.addGoal("kar"); pluginExecution.setConfiguration(configuration); pluginExecutions.add(pluginExecution); plugin.setExecutions(pluginExecutions); return plugin; }
Example #20
Source File: MavenUtil.java From java-specialagent with Apache License 2.0 | 5 votes |
/** * Returns the {@link PluginExecution} in the {@code mojoExecution}, if a * plugin is currently being executed. * * @param execution The {@link MojoExecution}. * @return The {@link PluginExecution} in the {@code mojoExecution}, if a * plugin is currently being executed. * @throws NullPointerException If {@code execution} is null. */ public static PluginExecution getPluginExecution(final MojoExecution execution) { final Plugin plugin = execution.getPlugin(); plugin.flushExecutionMap(); for (final PluginExecution pluginExecution : plugin.getExecutions()) if (pluginExecution.getId().equals(execution.getExecutionId())) return pluginExecution; return null; }
Example #21
Source File: MavenUtils.java From developer-studio with Apache License 2.0 | 5 votes |
private static void updateSourceFolder(IProject project, MavenProject mavenProject, File mavenProjectSaveLocation) throws JavaModelException{ Plugin sourcePluginEntry = createPluginEntry(mavenProject, "org.codehaus.mojo", "build-helper-maven-plugin", "1.8", false); PluginExecution pluginExecution=new PluginExecution(); IPackageFragmentRoot[] sourceFoldersForProject = JavaUtils.getSourceFoldersForProject(project); if (sourceFoldersForProject.length > 0) { String sourceFolder = FileUtils.getRelativePath(mavenProjectSaveLocation.getParentFile(), sourceFoldersForProject[0].getResource() .getLocation() .toFile()).replaceAll(Pattern.quote(File.separator), "/"); mavenProject.getModel().getBuild().setSourceDirectory(sourceFolder); Xpp3Dom configurationNode = createMainConfigurationNode(); pluginExecution.setConfiguration(configurationNode); Xpp3Dom sourcesNode = createXpp3Node(configurationNode, "sources"); for (int i = 1; i < sourceFoldersForProject.length; i++) { IPackageFragmentRoot packageFragmentRoot = sourceFoldersForProject[i]; File sourceDirectory = packageFragmentRoot.getResource().getLocation().toFile(); String relativePath = FileUtils.getRelativePath(mavenProjectSaveLocation.getParentFile(), sourceDirectory).replaceAll(Pattern.quote(File.separator), "/"); Xpp3Dom sourceNode = createXpp3Node(sourcesNode, "source"); sourceNode.setValue(relativePath); } sourcePluginEntry.addExecution(pluginExecution); } }
Example #22
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 #23
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 #24
Source File: TakariMojoExecutionConfigurator.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
private PluginExecution findPluginExecution(String executionId, Collection<PluginExecution> executions) { if (StringUtils.isNotEmpty(executionId)) { for (PluginExecution execution : executions) { if (executionId.equals(execution.getId())) { return execution; } } } return null; }
Example #25
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 #26
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 #27
Source File: MavenProjectUtil.java From ci.maven with Apache License 2.0 | 5 votes |
/** * Get an execution of a plugin * @param plugin * @param goal * @return the execution object * @throws PluginScenarioException */ public static PluginExecution getPluginGoalExecution(Plugin plugin, String goal) throws PluginScenarioException { List<PluginExecution> executions = plugin.getExecutions(); for(Iterator<PluginExecution> iterator = executions.iterator(); iterator.hasNext();) { PluginExecution execution = (PluginExecution) iterator.next(); if(execution.getGoals().contains(goal)) { return execution; } } throw new PluginScenarioException("Could not find goal " + goal + " on plugin " + plugin.getKey()); }
Example #28
Source File: RequiredMavenVersionFinderTest.java From versions-maven-plugin with Apache License 2.0 | 5 votes |
@Test public void findReturnsNullWhenEnforceGoalConfigurationIsNull() { ArrayList<Plugin> buildPlugins = new ArrayList<>(); buildPlugins.add(enforcerPlugin); when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); ArrayList<PluginExecution> pluginExecutions = new ArrayList<>(); pluginExecutions.add(pluginExecution); ArrayList<String> goals = new ArrayList<>(); goals.add("enforce"); when(pluginExecution.getGoals()).thenReturn(goals); when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); when(pluginExecution.getConfiguration()).thenReturn(null); assertNull(new RequiredMavenVersionFinder(mavenProject).find()); }
Example #29
Source File: RequiredMavenVersionFinderTest.java From versions-maven-plugin with Apache License 2.0 | 5 votes |
@Test public void findReturnsNullWhenPopulatedExecutionsListDoNotContainEnforcerExecution() { ArrayList<Plugin> buildPlugins = new ArrayList<>(); buildPlugins.add(enforcerPlugin); when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); ArrayList<PluginExecution> pluginExecutions = new ArrayList<>(); pluginExecutions.add(pluginExecution); ArrayList<String> goals = new ArrayList<>(); when(pluginExecution.getGoals()).thenReturn(goals); when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); assertNull(new RequiredMavenVersionFinder(mavenProject).find()); }
Example #30
Source File: RequiredMavenVersionFinderTest.java From versions-maven-plugin with Apache License 2.0 | 5 votes |
@Test public void findReturnsNullWhenExecutionGoalsListIsNull() { ArrayList<Plugin> buildPlugins = new ArrayList<>(); buildPlugins.add(enforcerPlugin); when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); ArrayList<PluginExecution> pluginExecutions = new ArrayList<>(); pluginExecutions.add(pluginExecution); when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); assertNull(new RequiredMavenVersionFinder(mavenProject).find()); }