當前位置: 首頁>>代碼示例>>Java>>正文


Java Build.addPlugin方法代碼示例

本文整理匯總了Java中org.apache.maven.model.Build.addPlugin方法的典型用法代碼示例。如果您正苦於以下問題:Java Build.addPlugin方法的具體用法?Java Build.addPlugin怎麽用?Java Build.addPlugin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.maven.model.Build的用法示例。


在下文中一共展示了Build.addPlugin方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testExecuteInParentWithConfigurationInPluginManagement

import org.apache.maven.model.Build; //導入方法依賴的package包/類
/**
 * Test of execute method, of class RequirePropertyDiverges.
 */
@Test
public void testExecuteInParentWithConfigurationInPluginManagement() throws EnforcerRuleException
{
    RequirePropertyDiverges mockInstance = createMockRule();
    final MavenProject project = createMavenProject( "company", "company-parent-pom" );
    final Build build = new Build();
    // create pluginManagement
    final Plugin pluginInManagement = newPlugin( "org.apache.maven.plugins", "maven-enforcer-plugin", "1.0");
    final Xpp3Dom configuration = createPluginConfiguration();
    pluginInManagement.setConfiguration( configuration );
    final PluginManagement pluginManagement = new PluginManagement();
    pluginManagement.addPlugin( pluginInManagement );
    build.setPluginManagement( pluginManagement );
    // create plugins
    final Plugin pluginInPlugins = newPlugin( "org.apache.maven.plugins", "maven-enforcer-plugin", "1.0");
    build.addPlugin( pluginInPlugins );
    // add build
    project.getOriginalModel().setBuild( build );
    //project.getOriginalModel().setBuild( build );
    setUpHelper( project, "parentValue" );
    mockInstance.execute( helper );
}
 
開發者ID:mojohaus,項目名稱:extra-enforcer-rules,代碼行數:26,代碼來源:RequirePropertyDivergesTest.java

示例2: testExecuteInParentWithConfigurationInExecution

import org.apache.maven.model.Build; //導入方法依賴的package包/類
/**
 * 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 );
}
 
開發者ID:mojohaus,項目名稱:extra-enforcer-rules,代碼行數:21,代碼來源:RequirePropertyDivergesTest.java

示例3: projectUnchangedWhenModeIsNone

import org.apache.maven.model.Build; //導入方法依賴的package包/類
@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 );
}
 
開發者ID:release-engineering,項目名稱:pom-manipulation-ext,代碼行數:23,代碼來源:DistributionEnforcingManipulatorTest.java

示例4: projectDeploySkipTurnedOffWhenModeIsOff

import org.apache.maven.model.Build; //導入方法依賴的package包/類
@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, true, Boolean.FALSE );
}
 
開發者ID:release-engineering,項目名稱:pom-manipulation-ext,代碼行數:24,代碼來源:DistributionEnforcingManipulatorTest.java

示例5: shouldIgnoreMissingPlugin

import org.apache.maven.model.Build; //導入方法依賴的package包/類
@Test
public void shouldIgnoreMissingPlugin() {
    Plugin barPlugin = new Plugin();
    barPlugin.setArtifactId("bar-plugin");
    barPlugin.setGroupId("com.acme");
    barPlugin.setVersion("1.0");

    Build fooBuild = new Build();
    fooBuild.addPlugin(barPlugin);

    Model foo = pom().artifactId("foo").model();
    foo.setBuild(fooBuild);

    createArtifact(repoFooDir, foo);

    validationExecutor.execute(ctx);

    assertSuccess();
}
 
開發者ID:release-engineering,項目名稱:redhat-repository-validator,代碼行數:20,代碼來源:TestDependenciesValidator.java

示例6: shouldIgnoreMissingPluginDependency

import org.apache.maven.model.Build; //導入方法依賴的package包/類
@Test
public void shouldIgnoreMissingPluginDependency() {
    Dependency barApi = dependency().artifactId("bar-api").groupId("com.acme").version("1.0").build();

    Plugin barPlugin = new Plugin();
    barPlugin.setArtifactId("bar-plugin");
    barPlugin.setGroupId("com.acme");
    barPlugin.setVersion("1.0");
    barPlugin.addDependency(barApi);

    Build fooBuild = new Build();
    fooBuild.addPlugin(barPlugin);

    Model foo = pom().artifactId("foo").model();
    foo.setBuild(fooBuild);

    createArtifact(repoFooDir, foo);

    validationExecutor.execute(ctx);

    assertSuccess();
}
 
開發者ID:release-engineering,項目名稱:redhat-repository-validator,代碼行數:23,代碼來源:TestDependenciesValidator.java

示例7: prepareBuildWithSurefirePlugin

import org.apache.maven.model.Build; //導入方法依賴的package包/類
static Build prepareBuildWithSurefirePlugin(String version) {
    Plugin surefirePlugin = new Plugin();
    surefirePlugin.setArtifactId(ApplicablePlugins.SUREFIRE.getArtifactId());
    surefirePlugin.setVersion(version);

    Build build = new Build();
    build.addPlugin(surefirePlugin);

    return build;
}
 
開發者ID:arquillian,項目名稱:smart-testing,代碼行數:11,代碼來源:ModelUtil.java

示例8: getBuildWithDockerPluginDefinition

import org.apache.maven.model.Build; //導入方法依賴的package包/類
private static void getBuildWithDockerPluginDefinition(Model model) {
    Build build = new Build();
    model.setBuild(build);
    Plugin plugin = new Plugin();
    plugin.setGroupId("io.fabric8");
    plugin.setArtifactId("docker-maven-plugin");
    plugin.setVersion("0.14.2");
    build.addPlugin(plugin);
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-stream-app-maven-plugin,代碼行數:10,代碼來源:MavenModelUtils.java

示例9: createParentProject

import org.apache.maven.model.Build; //導入方法依賴的package包/類
private MavenProject createParentProject() {
    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();
    plugin.setConfiguration( configuration );
    build.addPlugin( plugin );
    project.getOriginalModel().setBuild( build );
    return project;
}
 
開發者ID:mojohaus,項目名稱:extra-enforcer-rules,代碼行數:12,代碼來源:RequirePropertyDivergesTest.java

示例10: testShouldMergeOnePluginWithInheritExecutionWithoutDuplicatingPluginInList

import org.apache.maven.model.Build; //導入方法依賴的package包/類
public void testShouldMergeOnePluginWithInheritExecutionWithoutDuplicatingPluginInList()
{
    Plugin parent = new Plugin();
    parent.setArtifactId( "testArtifact" );
    parent.setGroupId( "testGroup" );
    parent.setVersion( "1.0" );

    PluginExecution parentExecution = new PluginExecution();
    parentExecution.setId( "testExecution" );

    parent.addExecution( parentExecution );

    Build parentContainer = new Build();
    parentContainer.addPlugin( parent );

    Plugin child = new Plugin();
    child.setArtifactId( "testArtifact" );
    child.setGroupId( "testGroup" );
    child.setVersion( "1.0" );

    Build childContainer = new Build();
    childContainer.addPlugin( child );

    ModelUtils.mergePluginLists( childContainer, parentContainer, true );

    List plugins = childContainer.getPlugins();

    assertEquals( 1, plugins.size() );

    Plugin plugin = (Plugin) plugins.get( 0 );

    assertEquals( 1, plugin.getExecutions().size() );
}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:34,代碼來源:ModelUtilsTest.java

示例11: testPluginDependenciesInfluenceSorting_DeclarationInParent

import org.apache.maven.model.Build; //導入方法依賴的package包/類
public void testPluginDependenciesInfluenceSorting_DeclarationInParent()
    throws Exception
{
    List<MavenProject> projects = new ArrayList<MavenProject>();

    MavenProject parentProject = createProject( "groupId", "parent-declarer", "1.0" );
    projects.add( parentProject );

    MavenProject pluginProject = createProject( "groupId", "plugin", "1.0" );
    pluginProject.setParent( parentProject );
    pluginProject.getModel().setParent( createParent( parentProject ) );
    projects.add( pluginProject );

    MavenProject pluginLevelDepProject = createProject( "groupId", "plugin-level-dep", "1.0" );
    pluginLevelDepProject.setParent( parentProject );
    pluginLevelDepProject.getModel().setParent( createParent( parentProject ) );
    projects.add( pluginLevelDepProject );

    Plugin plugin = createPlugin( pluginProject );

    plugin.addDependency( createDependency( pluginLevelDepProject ) );

    Build build = parentProject.getModel().getBuild();

    build.addPlugin( plugin );

    projects = new ProjectSorter( projects ).getSortedProjects();

    System.out.println( projects );

    assertEquals( parentProject, projects.get( 0 ) );

    // the order of these two is non-deterministic, based on when they're added to the reactor.
    assertTrue( projects.contains( pluginProject ) );
    assertTrue( projects.contains( pluginLevelDepProject ) );
}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:37,代碼來源:ProjectSorterTest.java

示例12: FitNesseMojoTestHelper

import org.apache.maven.model.Build; //導入方法依賴的package包/類
FitNesseMojoTestHelper() {
   this.artifactHandler = mock( ArtifactHandler.class );
   this.artifactResolver = mock( ArtifactResolver.class );
   this.realm = mock( ClassRealm.class );

   this.pluginArtifact = new DefaultArtifact( getClass().getPackage().getName(), getClass().getSimpleName(), "version", "scope", "type", "classifier", this.artifactHandler );

   this.fitnesseArtifact = new DefaultArtifact( "org.fitnesse", "fitnesse", "20151230", "compile", "jar", null, this.artifactHandler );
   this.fitnesseArtifact.setFile( new File( getClass().getResource( "/dummy.jar" ).getPath() ) );

   when( this.artifactResolver.resolve( argThat( new ResolutionRequestForArtifact( this.fitnesseArtifact ) ) ) ).thenReturn( createArtifactResolutionResult( this.fitnesseArtifact ) );

   this.plugin = new Plugin();
   this.plugin.setGroupId( this.pluginArtifact.getGroupId() );
   this.plugin.setArtifactId( this.pluginArtifact.getArtifactId() );

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

   this.mojo = new TestFitNesseMojo();
   this.mojo.project = new MavenProject();
   this.mojo.resolver = this.artifactResolver;
   this.mojo.fitNesseHelper = mock( FitNesseHelper.class );
   this.mojo.useProjectDependencies = new HashSet<String>();

   this.mojo.pluginDescriptor = new PluginDescriptor();
   this.mojo.pluginDescriptor.setGroupId( this.pluginArtifact.getGroupId() );
   this.mojo.pluginDescriptor.setArtifactId( this.pluginArtifact.getArtifactId() );
   this.mojo.pluginDescriptor.setArtifacts( Collections.singletonList( this.fitnesseArtifact ) );
   this.mojo.pluginDescriptor.setClassRealm( this.realm );
   this.mojo.project.setPluginArtifacts( Collections.singleton( this.pluginArtifact ) );
   this.mojo.project.setBuild( build );
   this.mojo.project.setFile( new File( getClass().getResource( "pom.xml" ).getPath() ) );
   this.mojo.project.setArtifactId( "ARTIFACT_ID" );
   this.mojo.project.setVersion( "VERSION" );
   this.mojo.project.getBuild().setTestOutputDirectory( "target/test-classes" );
   this.mojo.project.getBuild().setOutputDirectory( "target/classes" );
   this.mojo.project.setDependencyArtifacts( new HashSet<Artifact>() );

   this.systemProperties = new Properties();
   this.mojo.session = mock( MavenSession.class );
   when( this.mojo.session.getSystemProperties() ).thenReturn( this.systemProperties );

   addDependency( "cg1", "ca1", Artifact.SCOPE_COMPILE );
   addDependency( "cg1", "ca2", Artifact.SCOPE_COMPILE );
   addDependency( "cg2", "ca3", Artifact.SCOPE_COMPILE );

   addDependency( "tg1", "ta1", Artifact.SCOPE_TEST );
   addDependency( "tg1", "ta2", Artifact.SCOPE_TEST );
   addDependency( "tg2", "ta3", Artifact.SCOPE_TEST );

   addDependency( "rg1", "ra1", Artifact.SCOPE_RUNTIME );
   addDependency( "rg1", "ra2", Artifact.SCOPE_RUNTIME );
   addDependency( "rg2", "ra3", Artifact.SCOPE_RUNTIME );

   addDependency( "pg1", "pa1", Artifact.SCOPE_PROVIDED );
   addDependency( "pg1", "pa2", Artifact.SCOPE_PROVIDED );
   addDependency( "pg2", "pa3", Artifact.SCOPE_PROVIDED );

   addDependency( "sg1", "sa1", Artifact.SCOPE_SYSTEM );
   addDependency( "sg1", "sa2", Artifact.SCOPE_SYSTEM );
   addDependency( "sg2", "sa3", Artifact.SCOPE_SYSTEM );

   addDependency( "og1", "oa1", Artifact.SCOPE_COMPILE, true );
   addDependency( "og1", "oa2", Artifact.SCOPE_COMPILE, true );
   addDependency( "og2", "oa3", Artifact.SCOPE_COMPILE, true );

   this.logStream = new ByteArrayOutputStream();
   this.mojo.setLog( new DefaultLog( new PrintStreamLogger( Logger.LEVEL_INFO, "test", new PrintStream( this.logStream ) ) ) );
}
 
開發者ID:ZsZs,項目名稱:FitNesseLauncher,代碼行數:71,代碼來源:FitNesseMojoTestHelper.java

示例13: testShouldNotFailWhenPluginDepReferencesCurrentProject

import org.apache.maven.model.Build; //導入方法依賴的package包/類
public void testShouldNotFailWhenPluginDepReferencesCurrentProject()
    throws CycleDetectedException, DuplicateProjectException
{
    MavenProject project = createProject( "group", "artifact", "1.0" );

    Build build = project.getModel().getBuild();

    Plugin plugin = createPlugin( "other.group", "other-artifact", "1.0" );

    Dependency dep = createDependency( "group", "artifact", "1.0" );

    plugin.addDependency( dep );

    build.addPlugin( plugin );

    new ProjectSorter( Collections.singletonList( project ) );
}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:18,代碼來源:ProjectSorterTest.java

示例14: testPluginDependenciesInfluenceSorting

import org.apache.maven.model.Build; //導入方法依賴的package包/類
public void testPluginDependenciesInfluenceSorting()
    throws Exception
{
    List<MavenProject> projects = new ArrayList<MavenProject>();

    MavenProject parentProject = createProject( "groupId", "parent", "1.0" );
    projects.add( parentProject );

    MavenProject declaringProject = createProject( "groupId", "declarer", "1.0" );
    declaringProject.setParent( parentProject );
    declaringProject.getModel().setParent( createParent( parentProject ) );
    projects.add( declaringProject );

    MavenProject pluginLevelDepProject = createProject( "groupId", "plugin-level-dep", "1.0" );
    pluginLevelDepProject.setParent( parentProject );
    pluginLevelDepProject.getModel().setParent( createParent( parentProject ) );
    projects.add( pluginLevelDepProject );

    MavenProject pluginProject = createProject( "groupId", "plugin", "1.0" );
    pluginProject.setParent( parentProject );
    pluginProject.getModel().setParent( createParent( parentProject ) );
    projects.add( pluginProject );

    Plugin plugin = createPlugin( pluginProject );

    plugin.addDependency( createDependency( pluginLevelDepProject ) );

    Build build = declaringProject.getModel().getBuild();

    build.addPlugin( plugin );

    projects = new ProjectSorter( projects ).getSortedProjects();

    assertEquals( parentProject, projects.get( 0 ) );

    // the order of these two is non-deterministic, based on when they're added to the reactor.
    assertTrue( projects.contains( pluginProject ) );
    assertTrue( projects.contains( pluginLevelDepProject ) );

    // the declaring project MUST be listed after the plugin and its plugin-level dep, though.
    assertEquals( declaringProject, projects.get( 3 ) );
}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:43,代碼來源:ProjectSorterTest.java

示例15: updatePOMModel

import org.apache.maven.model.Build; //導入方法依賴的package包/類
private Boolean updatePOMModel(Build build,
                               Boolean defaultCompilerPluginPresent,
                               Boolean alternativeCompilerPluginPresent,
                               Boolean kiePluginPresent,
                               int defaultMavenCompilerPosition,
                               int alternativeCompilerPosition,
                               int kieMavenPluginPosition) {

    Boolean overwritePOM = Boolean.FALSE;

    if (!alternativeCompilerPluginPresent) {
        //add alternative compiler and disable the default compiler
        build.addPlugin(getNewCompilerPlugin());
        alternativeCompilerPluginPresent = Boolean.TRUE;
        overwritePOM = Boolean.TRUE;
    }

    if (!defaultCompilerPluginPresent) {
        //if default maven compiler is not present we add the skip and phase none  to avoid its use
        Plugin disabledDefaultCompiler = new Plugin();
        disabledDefaultCompiler.setArtifactId(conf.get(ConfigurationKey.MAVEN_COMPILER_PLUGIN));
        disableMavenCompilerAlreadyPresent(disabledDefaultCompiler);
        build.addPlugin(disabledDefaultCompiler);
        defaultCompilerPluginPresent = Boolean.TRUE;
        overwritePOM = Boolean.TRUE;
    }

    if (defaultCompilerPluginPresent && alternativeCompilerPluginPresent) {
        if (defaultMavenCompilerPosition <= alternativeCompilerPosition) {
            //swap the positions
            Plugin defaultMavenCompiler = build.getPlugins().get(defaultMavenCompilerPosition);
            Plugin alternativeCompiler = build.getPlugins().get(alternativeCompilerPosition);
            build.getPlugins().set(defaultMavenCompilerPosition,
                                   alternativeCompiler);
            build.getPlugins().set(alternativeCompilerPosition,
                                   defaultMavenCompiler);
            overwritePOM = Boolean.TRUE;
        }
    }
    return overwritePOM;
}
 
開發者ID:kiegroup,項目名稱:kie-wb-common,代碼行數:42,代碼來源:DefaultPomEditor.java


注:本文中的org.apache.maven.model.Build.addPlugin方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。