Java Code Examples for org.apache.maven.model.PluginExecution#setConfiguration()

The following examples show how to use org.apache.maven.model.PluginExecution#setConfiguration() . 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: RequirePropertyDivergesTest.java    From extra-enforcer-rules with Apache License 2.0 6 votes vote down vote up
/**
 * 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 2
Source File: CreateMavenBundlePom.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
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: CreateMavenDataServicePom.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
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 4
Source File: CreateMavenBundlePom.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
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 5
Source File: CreateMavenDataServicePom.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
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 6
Source File: MavenUtils.java    From developer-studio with Apache License 2.0 5 votes vote down vote up
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);
       }
	
}