Java Code Examples for org.apache.maven.model.Model#setBuild()

The following examples show how to use org.apache.maven.model.Model#setBuild() . 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: GitVersioningModelProcessor.java    From maven-git-versioning-extension with MIT License 6 votes vote down vote up
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 2
Source File: DistributionEnforcingManipulatorTest.java    From pom-manipulation-ext with Apache License 2.0 6 votes vote down vote up
@Test
public void projectUnchangedWhenModeIsNone()
    throws Exception
{
    final Plugin plugin = new Plugin();
    plugin.setGroupId( MAVEN_PLUGIN_GROUPID );
    plugin.setArtifactId( MAVEN_DEPLOY_ARTIFACTID );
    plugin.setConfiguration( simpleSkipConfig( true ) );

    final Build build = new Build();
    build.addPlugin( plugin );

    final Model model = new Model();
    model.setModelVersion( "4.0.0" );
    model.setGroupId( "org.foo" );
    model.setArtifactId( "bar" );
    model.setVersion( "1" );

    model.setBuild( build );

    applyTest( none, model, null );
}
 
Example 3
Source File: DistributionEnforcingManipulatorTest.java    From pom-manipulation-ext with Apache License 2.0 6 votes vote down vote up
@Test
public void projectDeploySkipTurnedOffWhenModeIsOff()
    throws Exception
{
    final Plugin plugin = new Plugin();
    plugin.setGroupId( MAVEN_PLUGIN_GROUPID );
    plugin.setArtifactId( MAVEN_DEPLOY_ARTIFACTID );
    plugin.setConfiguration( simpleSkipConfig( true ) );

    final Build build = new Build();
    build.addPlugin( plugin );

    final Model model = new Model();
    model.setModelVersion( "4.0.0" );
    model.setGroupId( "org.foo" );
    model.setArtifactId( "bar" );
    model.setVersion( "1" );

    model.setBuild( build );

    applyTest( off, model, model );
    assertSkip( model, null );
}
 
Example 4
Source File: BuildManager.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
private void rewritePOM(File pomFile) throws BuildException {
	try (Reader reader = new FileReader(pomFile)) {
		MavenXpp3Reader pomReader = new MavenXpp3Reader();
		
		Model model = pomReader.read(reader);
		reader.close();
		
		model.addRepository(createRepo("maven_central", "http://repo.maven.apache.org/maven2/", "default"));
		
		for (String id: eclipseRepos.keySet()) {
			model.addRepository(createRepo(id, eclipseRepos.get(id), "p2"));
		}
		
		Build modelBuild = model.getBuild();
		if (modelBuild == null) {
			model.setBuild(new Build());
		}
		
		model.getBuild().addPlugin(createPlugin("org.eclipse.tycho", "tycho-maven-plugin", "0.21.0", true));
		model.getBuild().addPlugin(createPlugin("org.eclipse.tycho", "target-platform-configuration", "0.21.0", false));
		model.getBuild().addPlugin(createPlugin("org.apache.maven.plugins", "maven-dependency-plugin", "2.8", false));
		
		MavenXpp3Writer pomWriter = new MavenXpp3Writer();
		pomWriter.write(new FileWriter(pomFile), model);
	} 
	catch (Exception e) {
		throw new BuildException("POM rewriting (to add plugin dependencies, cause) failed unexpectedly", e);
	}
}
 
Example 5
Source File: PomProperty.java    From flatten-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void set( Model model, PluginManagement value )
{
    if ( model.getBuild() == null )
    {
        model.setBuild( new Build() );
    }
    model.getBuild().setPluginManagement( value );
}
 
Example 6
Source File: MavenCreator.java    From microprofile-starter with Apache License 2.0 4 votes vote down vote up
private Model createSingleModule(JessieModel model) {

        Model pomFile = new Model();
        pomFile.setModelVersion("4.0.0");

        pomFile.setGroupId(model.getMaven().getGroupId());
        pomFile.setArtifactId(model.getMaven().getArtifactId());
        pomFile.setVersion("1.0-SNAPSHOT");

        pomFile.setPackaging("war");

        addDependencies(pomFile, model);

        addJavaSEVersionProperties(pomFile, model);

        pomFile.addProperty("failOnMissingWebXml", "false");

        pomFile.addProperty("final.name", model.getMaven().getArtifactId());

        Build build = new Build();
        build.setFinalName(model.getMaven().getArtifactId());
        pomFile.setBuild(build);

        return pomFile;
    }
 
Example 7
Source File: ModelUtil.java    From smart-testing with Apache License 2.0 4 votes vote down vote up
static Model prepareModelWithSurefirePlugin(String version) {
    Model model = new Model();
    model.setBuild(prepareBuildWithSurefirePlugin(version));

    return model;
}
 
Example 8
Source File: PomProperty.java    From flatten-maven-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public void set( Model model, Build value )
{
    model.setBuild( value );
}
 
Example 9
Source File: MavenUtils.java    From developer-studio with Apache License 2.0 4 votes vote down vote up
private static void initializeBuildModel(MavenProject mavenProject) {
	Model model = mavenProject.getModel();
	if (model.getBuild()!=null) {
		model.setBuild(new Build());
	}
}