Java 类org.apache.maven.plugin.MojoExecution 实例源码

项目:mavensonarsputnik    文件:MavenEnvironment.java   
public MavenEnvironment(MavenSession aMavenSession, BuildPluginManager aBuildPluginManager, Log aLog,
        DependencyTreeBuilder aDependencyTreeBuilder, ArtifactRepository aLocalRepository,
        SecDispatcher aSecurityDispatcher, MavenProjectBuilder aProjectBuilder,
        LifecycleExecutor aLifecycleExecutor, ArtifactFactory aArtifactFactory,
        ArtifactMetadataSource aArtifactMetadataSource, ArtifactCollector aArtifactCollector, RuntimeInformation aRuntimeInformation,
        MojoExecution aExecution) {
    mavenSession = aMavenSession;
    buildPluginManager = aBuildPluginManager;
    log = aLog;
    dependencyTreeBuilder = aDependencyTreeBuilder;
    localRepository = aLocalRepository;
    securityDispatcher = aSecurityDispatcher;
    projectBuilder = aProjectBuilder;
    lifecycleExecutor = aLifecycleExecutor;
    artifactFactory = aArtifactFactory;
    artifactMetadataSource = aArtifactMetadataSource;
    artifactCollector = aArtifactCollector;
    runtimeInformation = aRuntimeInformation;
    mojoExecution = aExecution;
}
项目:karaf-boot    文件:GenerateMojo.java   
private void executePluginDef(InputStream is) throws Exception {
    Xpp3Dom pluginDef = Xpp3DomBuilder.build(is, "utf-8");
    Plugin plugin = loadPlugin(pluginDef);
    Xpp3Dom config = pluginDef.getChild("configuration");
    PluginDescriptor pluginDesc = pluginManager.loadPlugin(plugin, 
                                                           mavenProject.getRemotePluginRepositories(), 
                                                           mavenSession.getRepositorySession());
    Xpp3Dom executions = pluginDef.getChild("executions");

    for ( Xpp3Dom execution : executions.getChildren()) {
        Xpp3Dom goals = execution.getChild("goals");
        for (Xpp3Dom goal : goals.getChildren()) {
            MojoDescriptor desc = pluginDesc.getMojo(goal.getValue());
            pluginManager.executeMojo(mavenSession, new MojoExecution(desc, config));
        }
    }
}
项目:sonar-scanner-maven    文件:ScannerFactoryTest.java   
@Before
public void setUp() {
  logOutput = mock(LogOutput.class);
  runtimeInformation = mock(RuntimeInformation.class, Mockito.RETURNS_DEEP_STUBS);
  mavenSession = mock(MavenSession.class);
  rootProject = mock(MavenProject.class);
  mojoExecution = mock(MojoExecution.class);
  envProps = new Properties();

  Properties system = new Properties();
  system.put("system", "value");
  system.put("user", "value");
  Properties root = new Properties();
  root.put("root", "value");
  envProps.put("env", "value");

  when(mojoExecution.getVersion()).thenReturn("2.0");
  when(runtimeInformation.getMavenVersion()).thenReturn("1.0");
  when(mavenSession.getSystemProperties()).thenReturn(system);
  when(mavenSession.getUserProperties()).thenReturn(new Properties());
  when(mavenSession.getSettings()).thenReturn(new Settings());
  when(rootProject.getProperties()).thenReturn(root);
  when(mavenSession.getCurrentProject()).thenReturn(rootProject);
  propertyDecryptor = new PropertyDecryptor(mock(Log.class), mock(SecDispatcher.class));
}
项目:FitNesseLauncher    文件:SetUpMojoTest.java   
@Test
public void testClean() throws Exception {

   final Xpp3Dom cleanConfig = Xpp3DomBuilder.build( SetUpMojoTest.class.getResourceAsStream( "setup-clean-mojo-config.xml" ), "UTF-8" );
   cleanConfig.getChild( "filesets" ).getChild( 0 ).getChild( "directory" ).setValue( helper.workingDir.getCanonicalPath() );

   doAnswer( new Answer<Void>() {
      @Override
      public Void answer( InvocationOnMock invocation ) throws Throwable {
         assertEquals( cleanConfig, ((MojoExecution) invocation.getArguments()[1]).getConfiguration() );
         return null;
      }
   } ).when( mojo.pluginManager ).executeMojo( eq( mojo.session ), any( MojoExecution.class ) );

   mojo.clean();
}
项目:FitNesseLauncher    文件:SetUpMojoTest.java   
@Test
public void testUnpack() throws Exception {
   final Xpp3Dom unpackConfig = Xpp3DomBuilder.build( SetUpMojoTest.class.getResourceAsStream( "unpack-mojo-config.xml" ), "UTF-8" );
   unpackConfig.getChild( "artifactItems" ).getChild( 0 ).getChild( "outputDirectory" ).setValue( helper.workingDir.getCanonicalPath() );
   unpackConfig.getChild( "artifactItems" ).getChild( 1 ).getChild( "outputDirectory" ).setValue( helper.workingDir.getCanonicalPath() + "/FitNesseRoot/files" );

   doAnswer( new Answer<Void>() {
      @Override
      public Void answer( InvocationOnMock invocation ) throws Throwable {
         assertEquals( unpackConfig, ((MojoExecution) invocation.getArguments()[1]).getConfiguration() );
         return null;
      }
   } ).when( mojo.pluginManager ).executeMojo( eq( mojo.session ), any( MojoExecution.class ) );

   mojo.unpack();
}
项目:FitNesseLauncher    文件:SetUpMojoTest.java   
@Test
public void testMove() throws Exception {

   final Xpp3Dom antrunConfig = Xpp3DomBuilder.build( SetUpMojoTest.class.getResourceAsStream( "antrun-mojo-config.xml" ), "UTF-8" );
   // Because the tmp directory differs by OS
   antrunConfig.getChild( "target" ).getChild( 0 ).setAttribute( "todir", helper.workingDir.getCanonicalPath() );
   antrunConfig.getChild( "target" ).getChild( 0 ).setAttribute( "file", helper.workingDir.getCanonicalPath() + "/" + SetUpMojo.FIT_ROOT );
   antrunConfig.getChild( "target" ).getChild( 1 ).setAttribute( "todir", helper.workingDir.getCanonicalPath() + "/" + FitNesseHelper.DEFAULT_ROOT + "/files" );
   antrunConfig.getChild( "target" ).getChild( 1 ).getChild( "fileset" ).setAttribute( "dir",
         helper.workingDir.getCanonicalPath() + "/" + FitNesseHelper.DEFAULT_ROOT + "/files/" + SetUpMojo.FIT_FILES );

   doAnswer( new Answer<Void>() {
      @Override
      public Void answer( InvocationOnMock invocation ) throws Throwable {
         assertEquals( antrunConfig, ((MojoExecution) invocation.getArguments()[1]).getConfiguration() );
         return null;
      }
   } ).when( mojo.pluginManager ).executeMojo( eq( mojo.session ), any( MojoExecution.class ) );

   mojo.move();
}
项目:FitNesseLauncher    文件:TearDownMojoTest.java   
@Test
public void testExecute() throws Exception {
   final Xpp3Dom cleanConfig = Xpp3DomBuilder.build( TearDownMojoTest.class.getResourceAsStream( "teardown-clean-mojo-config.xml" ), "UTF-8" );

   doAnswer( new Answer<Void>() {
      @Override
      public Void answer( InvocationOnMock invocation ) throws Throwable {
         assertEquals( cleanConfig, ((MojoExecution) invocation.getArguments()[1]).getConfiguration() );
         return null;
      }
   } ).when( helper.mojo.pluginManager ).executeMojo( eq( helper.mojo.session ), any( MojoExecution.class ) );

   helper.mojo.execute();

   verify( helper.mojo.pluginManager, times( 1 ) ).executeMojo( eq( helper.mojo.session ), any( MojoExecution.class ) );
}
项目:xmvn    文件:XMvnMojoExecutionListener.java   
private Object dispatchBuildPluginManagerMethodCall( Object proxy, Method method, Object[] args )
    throws Throwable
{
    Object ret = method.invoke( mavenPluginManager, args );

    if ( method.getName().equals( "getConfiguredMojo" ) )
    {
        beforeMojoExecution( ret, (MojoExecution) args[2] );
    }
    else if ( method.getName().equals( "releaseMojo" ) )
    {
        afterMojoExecution( args[0], (MojoExecution) args[1], legacySupport.getSession().getCurrentProject() );
    }

    return ret;
}
项目:pipeline-maven-plugin    文件:CatchAllExecutionHandler.java   
@Nonnull
@Override
protected List<String> getConfigurationParametersToReport(ExecutionEvent executionEvent) {

    MojoExecution mojoExecution = executionEvent.getMojoExecution();
    if (mojoExecution == null) {
        return Collections.emptyList();
    }

    Xpp3Dom configuration = mojoExecution.getConfiguration();
    List<String> parameters = new ArrayList<String>();
    for (Xpp3Dom configurationParameter : configuration.getChildren()) {
        parameters.add(configurationParameter.getName());
    }
    return parameters;
}
项目:FitNesseLauncher    文件:SetUpMojoTest.java   
@Test
public void testClean() throws Exception {

   final Xpp3Dom cleanConfig = Xpp3DomBuilder.build( SetUpMojoTest.class.getResourceAsStream( "setup-clean-mojo-config.xml" ), "UTF-8" );
   cleanConfig.getChild( "filesets" ).getChild( 0 ).getChild( "directory" ).setValue( helper.workingDir.getCanonicalPath() );

   doAnswer( new Answer<Void>() {
      @Override
      public Void answer( InvocationOnMock invocation ) throws Throwable {
         assertEquals( cleanConfig, ((MojoExecution) invocation.getArguments()[1]).getConfiguration() );
         return null;
      }
   } ).when( mojo.pluginManager ).executeMojo( eq( mojo.session ), any( MojoExecution.class ) );

   mojo.clean();
}
项目:FitNesseLauncher    文件:SetUpMojoTest.java   
@Test
public void testUnpack() throws Exception {
   final Xpp3Dom unpackConfig = Xpp3DomBuilder.build( SetUpMojoTest.class.getResourceAsStream( "unpack-mojo-config.xml" ), "UTF-8" );
   unpackConfig.getChild( "artifactItems" ).getChild( 0 ).getChild( "outputDirectory" ).setValue( helper.workingDir.getCanonicalPath() );
   unpackConfig.getChild( "artifactItems" ).getChild( 1 ).getChild( "outputDirectory" ).setValue( helper.workingDir.getCanonicalPath() + "/FitNesseRoot/files" );

   doAnswer( new Answer<Void>() {
      @Override
      public Void answer( InvocationOnMock invocation ) throws Throwable {
         assertEquals( unpackConfig, ((MojoExecution) invocation.getArguments()[1]).getConfiguration() );
         return null;
      }
   } ).when( mojo.pluginManager ).executeMojo( eq( mojo.session ), any( MojoExecution.class ) );

   mojo.unpack();
}
项目:FitNesseLauncher    文件:SetUpMojoTest.java   
@Test
public void testMove() throws Exception {

   final Xpp3Dom antrunConfig = Xpp3DomBuilder.build( SetUpMojoTest.class.getResourceAsStream( "antrun-mojo-config.xml" ), "UTF-8" );
   // Because the tmp directory differs by OS
   antrunConfig.getChild( "target" ).getChild( 0 ).setAttribute( "todir", helper.workingDir.getCanonicalPath() );
   antrunConfig.getChild( "target" ).getChild( 0 ).setAttribute( "file", helper.workingDir.getCanonicalPath() + "/" + SetUpMojo.FIT_ROOT );
   antrunConfig.getChild( "target" ).getChild( 1 ).setAttribute( "todir", helper.workingDir.getCanonicalPath() + "/" + FitNesseHelper.DEFAULT_ROOT + "/files" );
   antrunConfig.getChild( "target" ).getChild( 1 ).getChild( "fileset" ).setAttribute( "dir",
         helper.workingDir.getCanonicalPath() + "/" + FitNesseHelper.DEFAULT_ROOT + "/files/" + SetUpMojo.FIT_FILES );

   doAnswer( new Answer<Void>() {
      @Override
      public Void answer( InvocationOnMock invocation ) throws Throwable {
         assertEquals( antrunConfig, ((MojoExecution) invocation.getArguments()[1]).getConfiguration() );
         return null;
      }
   } ).when( mojo.pluginManager ).executeMojo( eq( mojo.session ), any( MojoExecution.class ) );

   mojo.move();
}
项目:FitNesseLauncher    文件:TearDownMojoTest.java   
@Test
public void testExecute() throws Exception {
   final Xpp3Dom cleanConfig = Xpp3DomBuilder.build( TearDownMojoTest.class.getResourceAsStream( "teardown-clean-mojo-config.xml" ), "UTF-8" );

   doAnswer( new Answer<Void>() {
      @Override
      public Void answer( InvocationOnMock invocation ) throws Throwable {
         assertEquals( cleanConfig, ((MojoExecution) invocation.getArguments()[1]).getConfiguration() );
         return null;
      }
   } ).when( helper.mojo.pluginManager ).executeMojo( eq( helper.mojo.session ), any( MojoExecution.class ) );

   helper.mojo.execute();

   verify( helper.mojo.pluginManager, times( 1 ) ).executeMojo( eq( helper.mojo.session ), any( MojoExecution.class ) );
}
项目:m2e-nar    文件:NarTestCompileBuildParticipant.java   
public NarTestCompileBuildParticipant(MojoExecution execution, boolean runOnIncremental, boolean runOnConfiguration) {
    super(new MojoExecution(execution.getMojoDescriptor(), execution.getExecutionId(), execution.getSource()), runOnIncremental, runOnConfiguration);
    // Some versions of nar-maven-plugin don't have a nar-test-unpack goal
    // this means the test artifacts won't be available to us.
    // What we need to do is run the nar-testCompile goal without any tests
    // its configuration in order to just unpack.
    Xpp3Dom configuration = new Xpp3Dom(execution.getConfiguration());
    logger.debug("Configuration before: " + configuration);
    for (int i = 0; i < configuration.getChildCount(); ++i) {
        if ("tests".equals(configuration.getChild(i).getName())) {
            configuration.removeChild(i);
            break;
        }
    }
    logger.debug("Configuration after: " + configuration);
    getMojoExecution().setConfiguration(configuration);
}
项目:m2e-nar    文件:MavenUtils.java   
public static List<MojoExecution> getExecutions(final String goal, final ConfiguratorContext context, final IMavenProjectFacade facade,
        final IProgressMonitor monitor) throws CoreException {
    final List<MojoExecution> compileExecutions = new ArrayList<MojoExecution>();

    final Map<String, Set<MojoExecutionKey>> configuratorExecutions = AbstractProjectConfigurator.getConfiguratorExecutions(facade);

    final Set<MojoExecutionKey> executionKeys = configuratorExecutions.get(CProjectConfigurator.CONFIGURATOR_ID);
    if (executionKeys != null) {
        for (MojoExecutionKey key : executionKeys) {
            final MojoExecution mojoExecution = facade.getMojoExecution(key, monitor);
            if (goal.equals(mojoExecution.getGoal())) {
                compileExecutions.add(mojoExecution);
            }
        }
    }

    return compileExecutions;
}
项目:takari-lifecycle    文件:CompileTest.java   
@Test
public void testBasic_skip() throws Exception {
  File basedir = compile("compile/basic");
  File testClasses = new File(basedir, "target/test-classes");

  MavenProject project = mojos.readMavenProject(basedir);
  MavenSession session = mojos.newMavenSession(project);
  MojoExecution execution = mojos.newMojoExecution("testCompile");
  execution.getConfiguration().addChild(newParameter("compilerId", compilerId));
  execution.getConfiguration().addChild(newParameter("skip", "true"));
  mojos.executeMojo(session, project, execution);
  mojos.assertBuildOutputs(testClasses, new String[0]);

  execution = mojos.newMojoExecution("testCompile");
  execution.getConfiguration().addChild(newParameter("compilerId", compilerId));
  mojos.executeMojo(session, project, execution);
  mojos.assertBuildOutputs(testClasses, "basic/BasicTest.class");

  execution = mojos.newMojoExecution("testCompile");
  execution.getConfiguration().addChild(newParameter("compilerId", compilerId));
  execution.getConfiguration().addChild(newParameter("skip", "true"));
  mojos.executeMojo(session, project, execution);
  mojos.assertBuildOutputs(testClasses, new String[0]);
  mojos.assertDeletedOutputs(testClasses, new String[0]);
}
项目:takari-lifecycle    文件:CompileTest.java   
@Test
public void testImplicitClassfileGeneration() throws Exception {
  // javac automatically generates class files from sources found on classpath in some cases
  // the point of this test is to make sure this behaviour is disabled

  File dependency = compile("compile/basic");
  cp(dependency, "src/main/java/basic/Basic.java", "target/classes/basic/Basic.java");
  touch(dependency, "target/classes/basic/Basic.java"); // must be newer than .class file

  File basedir = resources.getBasedir("compile/implicit-classfile");
  MavenProject project = mojos.readMavenProject(basedir);
  MavenSession session = mojos.newMavenSession(project);
  MojoExecution execution = mojos.newMojoExecution();

  addDependency(project, "dependency", new File(dependency, "target/classes"));

  mojos.executeMojo(session, project, execution);

  mojos.assertBuildOutputs(new File(basedir, "target/classes"), "implicit/Implicit.class");
}
项目:takari-lifecycle    文件:AnnotationProcessingTest.java   
protected void processAnnotations(MavenSession session, MavenProject project, String goal, File processor, Proc proc, Xpp3Dom... parameters) throws Exception {
  MojoExecution execution = mojos.newMojoExecution(goal);

  addDependency(project, "processor", new File(processor, "target/classes"));

  Xpp3Dom configuration = execution.getConfiguration();

  if (proc != null) {
    configuration.addChild(newParameter("proc", proc.name()));
  }
  if (parameters != null) {
    for (Xpp3Dom parameter : parameters) {
      configuration.addChild(parameter);
    }
  }

  mojos.executeMojo(session, project, execution);
}
项目:takari-lifecycle    文件:ResourcesTest.java   
@Test
public void resources_skip() throws Exception {
  File basedir = resources.getBasedir("resources/project-with-resources");
  File resource = new File(basedir, "target/classes/resource.txt");

  MavenProject project = mojos.readMavenProject(basedir);
  MavenSession session = mojos.newMavenSession(project);

  MojoExecution execution = mojos.newMojoExecution("process-resources");
  execution.getConfiguration().addChild(newParameter("skip", "true"));
  mojos.executeMojo(session, project, execution);
  Assert.assertFalse(resource.exists());

  mojos.executeMojo(basedir, "process-resources");
  Assert.assertTrue(resource.exists());

  execution = mojos.newMojoExecution("process-resources");
  execution.getConfiguration().addChild(newParameter("skip", "true"));
  mojos.executeMojo(session, project, execution);
  Assert.assertTrue(resource.exists());
}
项目:m2e-plugins    文件:BuildParticipant.java   
@Override
public Set<IProject> build(int kind, IProgressMonitor monitor) throws Exception {

    final MojoExecution mojoExecution = getMojoExecution();
    log.debug("execution: {}", mojoExecution);

    if (mojoExecution == null) {
        return null;
    }

    final String phase = mojoExecution.getLifecyclePhase();
    log.debug("phase: {}", phase);

    final String goal = mojoExecution.getGoal();
    log.debug("goal: {}", goal);

    if ("bundle".equalsIgnoreCase(goal)) {
        return buildBundle(kind, monitor);
    } else if ("process".equalsIgnoreCase(goal)) {
        return buildProcess(kind, monitor);
    } else {
        return super.build(kind, monitor);
    }
}
项目:oceano    文件:DefaultLifecycleExecutionPlanCalculator.java   
public void setupMojoExecution( MavenSession session, MavenProject project, MojoExecution mojoExecution )
    throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
    MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException,
    LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException
{
    MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();

    if ( mojoDescriptor == null )
    {
        mojoDescriptor =
            pluginManager.getMojoDescriptor( mojoExecution.getPlugin(), mojoExecution.getGoal(),
                                             project.getRemotePluginRepositories(),
                                             session.getRepositorySession() );

        mojoExecution.setMojoDescriptor( mojoDescriptor );
    }

    populateMojoExecutionConfiguration( project, mojoExecution,
                                        MojoExecution.Source.CLI.equals( mojoExecution.getSource() ) );

    finalizeMojoConfiguration( mojoExecution );

    calculateForkedExecutions( mojoExecution, session, project, new HashSet<MojoDescriptor>() );
}
项目:m2e-plugins    文件:Configurator.java   
/**
 * 
 * @param mavenProjectFacade
 * @return
 */
private Set<String> getResourceBundles(IMavenProjectFacade mavenProjectFacade, IProgressMonitor monitor) throws CoreException {
    Set<String> bundles = new HashSet<String>();
    List<MojoExecution> executions = mavenProjectFacade.getMojoExecutions(Activator.MAVEN_GROUP_ID, Activator.MAVEN_ARTIFACT_ID, monitor, "process");
    for (MojoExecution execution : executions) {
        Xpp3Dom node = execution.getConfiguration();
        if (node != null) {
            node = node.getChild("resourceBundles");
            if (node != null) {
                Xpp3Dom[] nodes = node.getChildren("resourceBundle");
                if (nodes != null) {
                    for (Xpp3Dom n : nodes) {
                        String bundle = n.getValue();
                        bundles.add(bundle);
                    }
                }
            }
        }
    }
    return bundles;
}
项目:oceano    文件:PhaseRecorder.java   
public void observeExecution( MojoExecution mojoExecution )
{
    String lifecyclePhase = mojoExecution.getLifecyclePhase();

    if ( lifecyclePhase != null )
    {
        if ( lastLifecyclePhase == null )
        {
            lastLifecyclePhase = lifecyclePhase;
        }
        else if ( !lifecyclePhase.equals( lastLifecyclePhase ) )
        {
            project.addLifecyclePhase( lastLifecyclePhase );
            lastLifecyclePhase = lifecyclePhase;
        }
    }

    if ( lastLifecyclePhase != null )
    {
        project.addLifecyclePhase( lastLifecyclePhase );
    }
}
项目:oceano    文件:DefaultSchedules.java   
public List<ExecutionPlanItem> createExecutionPlanItem( MavenProject mavenProject, List<MojoExecution> executions )
{
    BuilderCommon.attachToThread( mavenProject );

    List<ExecutionPlanItem> result = new ArrayList<ExecutionPlanItem>();
    for ( MojoExecution mojoExecution : executions )
    {
        String lifeCyclePhase = mojoExecution.getLifecyclePhase();
        final Scheduling scheduling = getScheduling( "default" );

        Schedule schedule = null;
        if ( scheduling != null )
        {
            schedule = scheduling.getSchedule( mojoExecution );
            if ( schedule == null )
            {
                schedule = scheduling.getSchedule( lifeCyclePhase );
            }
        }

        result.add( new ExecutionPlanItem( mojoExecution, schedule ) );
    }
    return result;
}
项目:oceano    文件:DefaultMavenPluginManager.java   
public void releaseMojo( Object mojo, MojoExecution mojoExecution )
{
    if ( mojo != null )
    {
        try
        {
            container.release( mojo );
        }
        catch ( ComponentLifecycleException e )
        {
            String goalExecId = mojoExecution.getGoal();

            if ( mojoExecution.getExecutionId() != null )
            {
                goalExecId += " {execution: " + mojoExecution.getExecutionId() + "}";
            }

            logger.debug( "Error releasing mojo for " + goalExecId, e );
        }
    }
}
项目:oceano    文件:LifecycleExecutorTest.java   
public void testCalculationOfBuildPlanWithIndividualTaskWherePluginIsSpecifiedInThePom()
    throws Exception
{
    // We are doing something like "mvn resources:resources" where no version is specified but this
    // project we are working on has the version specified in the POM so the version should come from there.
    File pom = getProject( "project-basic" );
    MavenSession session = createMavenSession( pom );
    assertEquals( "project-basic", session.getCurrentProject().getArtifactId() );
    assertEquals( "1.0", session.getCurrentProject().getVersion() );
    List<MojoExecution> executionPlan = getExecutions( calculateExecutionPlan( session, "resources:resources" ) );
    assertEquals( 1, executionPlan.size() );
    MojoExecution mojoExecution = executionPlan.get( 0 );
    assertNotNull( mojoExecution );
    assertEquals( "org.apache.maven.plugins",
                  mojoExecution.getMojoDescriptor().getPluginDescriptor().getGroupId() );
    assertEquals( "maven-resources-plugin",
                  mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifactId() );
    assertEquals( "0.1", mojoExecution.getMojoDescriptor().getPluginDescriptor().getVersion() );
}
项目:oceano    文件:LifecycleExecutorTest.java   
public void testCalculationOfBuildPlanWithIndividualTaskOfTheCleanLifecycle()
    throws Exception
{
    // We are doing something like "mvn clean:clean" where no version is specified but this
    // project we are working on has the version specified in the POM so the version should come from there.
    File pom = getProject( "project-basic" );
    MavenSession session = createMavenSession( pom );
    assertEquals( "project-basic", session.getCurrentProject().getArtifactId() );
    assertEquals( "1.0", session.getCurrentProject().getVersion() );
    List<MojoExecution> executionPlan = getExecutions( calculateExecutionPlan( session, "clean" ) );
    assertEquals( 1, executionPlan.size() );
    MojoExecution mojoExecution = executionPlan.get( 0 );
    assertNotNull( mojoExecution );
    assertEquals( "org.apache.maven.plugins",
                  mojoExecution.getMojoDescriptor().getPluginDescriptor().getGroupId() );
    assertEquals( "maven-clean-plugin", mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifactId() );
    assertEquals( "0.1", mojoExecution.getMojoDescriptor().getPluginDescriptor().getVersion() );
}
项目:oceano    文件:LifecycleExecutionPlanCalculatorStub.java   
public MavenExecutionPlan calculateExecutionPlan( MavenSession session, MavenProject project, List<Object> tasks,
                                                  boolean setup )
    throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException,
    PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException,
    NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException
{
    if ( project.equals( ProjectDependencyGraphStub.A ) )
    {
        return getProjectAExceutionPlan();
    }
    if ( project.equals( ProjectDependencyGraphStub.B ) )
    {
        return getProjectBExecutionPlan();
    }
    // The remaining are basically "for future expansion"
    List<MojoExecution> me = new ArrayList<MojoExecution>();
    me.add( createMojoExecution( "resources", "default-resources", PROCESS_RESOURCES ) );
    me.add( createMojoExecution( "compile", "default-compile", COMPILE ) );
    return createExecutionPlan( project, me );
}
项目:oceano    文件:LifecycleExecutionPlanCalculatorStub.java   
public static MavenExecutionPlan getProjectAExceutionPlan()
    throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException,
    PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException,
    NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException
{
    List<MojoExecution> me = new ArrayList<MojoExecution>();
    me.add( createMojoExecution( "initialize", "default-initialize", INITIALIZE ) );
    me.add( createMojoExecution( "resources", "default-resources", PROCESS_RESOURCES ) );
    me.add( createMojoExecution( "compile", "default-compile", COMPILE ) );
    me.add( createMojoExecution( "testResources", "default-testResources", PROCESS_TEST_RESOURCES ) );
    me.add( createMojoExecution( "testCompile", "default-testCompile", TEST_COMPILE ) );
    me.add( createMojoExecution( "test", "default-test", TEST ) );
    me.add( createMojoExecution( "war", "default-war", PACKAGE ) );
    me.add( createMojoExecution( "install", "default-install", INSTALL ) );
    return createExecutionPlan( ProjectDependencyGraphStub.A.getExecutionProject(), me );
}
项目:m2e-plugins    文件:Configurator.java   
@Override
public AbstractBuildParticipant getBuildParticipant(
        IMavenProjectFacade projectFacade, MojoExecution execution,
        IPluginExecutionMetadata executionMetadata) {

    String artifactId = execution.getArtifactId();
    if (log.isDebugEnabled()) {
        log.debug("getBuildParticipant: artifactId={}", artifactId);
    }

    String inputPathParam;
    String outputPathParam;

    if ("libsass-maven-plugin".equals(artifactId)) {
        inputPathParam = "inputPath";
        outputPathParam = "outputPath";
    } else if ("sass-maven-plugin".equals(artifactId)) {
        inputPathParam = "sassSourceDirectory";
        outputPathParam = "destination";
    } else {
        throw new IllegalStateException("Unsupported artifactId <"
                + artifactId + ">");
    }

    return new BuildParticipant(execution, inputPathParam, outputPathParam);
}
项目:neoscada    文件:QualifierNameProvider.java   
public Configuration ( final MavenSession session, final MojoExecution execution, final MavenProject project, final Map<String, String> properties )
{
    this.session = session;
    this.execution = execution;
    this.project = project;
    this.properties = properties;
}
项目:mavensonarsputnik    文件:MavenEnvironment.java   
public static void initialize(MavenSession aMavenSession, BuildPluginManager aBuildPluginManager, Log aLog,
        DependencyTreeBuilder aDependencyTreeBuilder, ArtifactRepository aLocalRepository,
        SecDispatcher aSecurityDispatcher, MavenProjectBuilder aProjectBuilder,
        LifecycleExecutor aLifecycleExecutor, ArtifactFactory aArtifactFactory,
        ArtifactMetadataSource aArtifactMetadataSource, ArtifactCollector aArtifactCollector, RuntimeInformation aRuntimeInformation, MojoExecution aExecution) {
    ENVIRONMENT.set(new MavenEnvironment(aMavenSession, aBuildPluginManager, aLog,
            aDependencyTreeBuilder, aLocalRepository,
            aSecurityDispatcher, aProjectBuilder,
            aLifecycleExecutor, aArtifactFactory,
            aArtifactMetadataSource, aArtifactCollector, aRuntimeInformation, aExecution));
}
项目:sonar-scanner-maven    文件:ScannerFactory.java   
public ScannerFactory(LogOutput logOutput, Log log, RuntimeInformation runtimeInformation, MojoExecution mojoExecution, MavenSession session,
  Properties envProps, PropertyDecryptor propertyDecryptor) {
  this.logOutput = logOutput;
  this.log = log;
  this.runtimeInformation = runtimeInformation;
  this.mojoExecution = mojoExecution;
  this.session = session;
  this.debugEnabled = log.isDebugEnabled();
  this.envProps = envProps;
  this.propertyDecryptor = propertyDecryptor;
}
项目:sonar-scanner-maven    文件:JavaVersionResolver.java   
@CheckForNull
private String getString(MavenProject pom, String parameter) {
  MavenProject oldProject = session.getCurrentProject();
  try {
    // Switch to the project for which we try to resolve the property.
    session.setCurrentProject(pom);
    for (MojoExecution exec : mojoExecutions) {
      Xpp3Dom configuration = exec.getConfiguration();
      PlexusConfiguration pomConfiguration = new XmlPlexusConfiguration(configuration);
      PlexusConfiguration config = pomConfiguration.getChild(parameter);

      ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(session, exec);
      BasicStringConverter converter = new BasicStringConverter();

      String value = converter.fromExpression(config, expressionEvaluator);
      if (value != null) {
        return value;
      }
    }
  } catch (Exception e) {
    log.warn(String.format("Failed to get parameter '%s' for goal '%s': %s", parameter, COMPILE_GOAL, e.getMessage()));
  } finally {
    session.setCurrentProject(oldProject);
  }

  return null;
}
项目:wildfly-swarm    文件:MultiStartMojo.java   
@SuppressWarnings("unchecked")
protected void startProject(MavenProject project, String executionId, XmlPlexusConfiguration process) throws InvalidPluginDescriptorException, PluginResolutionException, PluginDescriptorParsingException, PluginNotFoundException, PluginConfigurationException, MojoFailureException, MojoExecutionException, PluginManagerException {
    Plugin plugin = this.project.getPlugin("org.wildfly.swarm:wildfly-swarm-plugin");

    Xpp3Dom config = getConfiguration(project, executionId);
    Xpp3Dom processConfig = getProcessConfiguration(process);

    Xpp3Dom globalConfig = getGlobalConfig();
    Xpp3Dom mergedConfig = Xpp3DomUtils.mergeXpp3Dom(processConfig, config);
    mergedConfig = Xpp3DomUtils.mergeXpp3Dom(mergedConfig, globalConfig);

    PluginDescriptor pluginDescriptor = this.pluginManager.loadPlugin(plugin, project.getRemotePluginRepositories(), this.repositorySystemSession);
    MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo("start");
    MojoExecution mojoExecution = new MojoExecution(mojoDescriptor, mergedConfig);
    mavenSession.setCurrentProject(project);
    this.pluginManager.executeMojo(mavenSession, mojoExecution);

    List<SwarmProcess> launched = (List<SwarmProcess>) mavenSession.getPluginContext(pluginDescriptor, project).get(SWARM_PROCESS);

    List<SwarmProcess> procs = (List<SwarmProcess>) getPluginContext().get(SWARM_PROCESS);

    if (procs == null) {
        procs = new ArrayList<>();
        getPluginContext().put(SWARM_PROCESS, procs);
    }

    procs.addAll(launched);

    mavenSession.setCurrentProject(this.project);
}
项目:xmvn    文件:XMvnMojoExecutionListener.java   
void beforeMojoExecution( Object mojo, MojoExecution execution )
{
    // Disable doclint
    if ( JAVADOC_AGGREGATE.equals( execution ) )
    {
        // maven-javadoc-plugin < 3.0.0
        trySetBeanProperty( mojo, "additionalparam", "-Xdoclint:none" );
        // maven-javadoc-plugin >= 3.0.0
        trySetBeanProperty( mojo, "additionalOptions", new String[] { "-Xdoclint:none" } );
    }
    else if ( XMVN_BUILDDEP.equals( execution ) )
    {
        trySetBeanProperty( mojo, "resolutions", Collections.unmodifiableList( new ArrayList<>( resolutions ) ) );
    }
}
项目:xmvn    文件:MojoExecutionListenerTest.java   
@Before
public void setUp()
    throws Exception
{
    listener = new XMvnMojoExecutionListener();

    listener.setXmvnStateDir( tempDir.getRoot().toPath() );

    // MojoBeanProperty interface extends Mojo interface, so this is ok (and required).
    mojo = EasyMock.createMock( MojoBeanProperty.class );
    exec = EasyMock.createMock( MojoExecution.class );
    project = EasyMock.createMock( MavenProject.class );

    EasyMock.replay( mojo, exec, project );
}
项目:pipeline-maven-plugin    文件:AbstractExecutionHandler.java   
public boolean handle(@Nonnull Object event) {
    if (!(event instanceof ExecutionEvent)) {
        return false;
    }
    ExecutionEvent executionEvent = (ExecutionEvent) event;
    ExecutionEvent.Type supportedType = getSupportedType();

    if (supportedType != null && !(supportedType.equals(executionEvent.getType()))) {
        return false;
    }

    String supportedGoal = getSupportedPluginGoal();
    if (supportedGoal == null) {
        return _handle(executionEvent);
    } else {
        String[] gag = supportedGoal.split(":");
        if (gag.length == 3) {
            MojoExecution execution = executionEvent.getMojoExecution();
            if (execution.getGroupId().equals(gag[0]) && execution.getArtifactId().equals(gag[1]) && execution.getGoal().equals(gag[2])) {
                _handle(executionEvent);
                return true;
            } else {
                return false;
            }
        } else {
            reporter.print(toString() + " - unsupported supportedPluginGoal:" + supportedGoal);
            return false;
        }
    }

}
项目:pipeline-maven-plugin    文件:JenkinsMavenEventSpyTest.java   
@Test
public void testExecutionProjectStarted() throws Exception {
    ExecutionEvent executionEvent = new  ExecutionEvent(){
        @Override
        public Type getType() {
            return Type.ProjectStarted;
        }

        @Override
        public MavenSession getSession() {
            return null;
        }

        @Override
        public MavenProject getProject() {
            return project;
        }

        @Override
        public MojoExecution getMojoExecution() {
            return null;
        }

        @Override
        public Exception getException() {
            return null;
        }
    };

    spy.onEvent(executionEvent);

    String actual = writer.toString();
    System.out.println(actual);
    Assert.assertThat(actual, CoreMatchers.containsString("ProjectStarted"));
    Assert.assertThat(actual, CoreMatchers.containsString("petclinic"));
}
项目:release-maven-plugin-parent    文件:FailureRollbackListener.java   
@Override
public void beforeMojoExecution(final MojoExecutionEvent event) throws MojoExecutionException {
    final MojoExecution execution = event.getExecution();
    if (DEPLOY_PLUGINS.contains(execution.getPlugin().getKey())) {

    }
}