Java 类org.apache.maven.plugin.descriptor.MojoDescriptor 实例源码

项目: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));
        }
    }
}
项目:FitNesseLauncher    文件:SetupsMojoTestHelper.java   
@SuppressWarnings( "unchecked" )
void setupArtifact( String groupId, String artifactId, String goal, String type )
      throws DuplicateMojoDescriptorException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException {

   DefaultArtifact artifact = new DefaultArtifact( groupId, artifactId, "DUMMY", "compile", type, "", null );
   MojoDescriptor mojoDescriptor = new MojoDescriptor();
   mojoDescriptor.setGoal( goal );
   PluginDescriptor pluginDescriptor = new PluginDescriptor();
   pluginDescriptor.addMojo( mojoDescriptor );

   Plugin plugin = new Plugin();
   plugin.setGroupId( groupId );
   plugin.setArtifactId( artifactId );

   when( this.mojo.pluginManager.loadPlugin( eq( plugin ), anyList(), any( RepositorySystemSession.class ) ) ).thenReturn( pluginDescriptor );

   this.mojo.pluginDescriptor.getArtifactMap().put( String.format( "%s:%s", groupId, artifactId ), artifact );
}
项目:FitNesseLauncher    文件:SetupsMojoTestHelper.java   
@SuppressWarnings( "unchecked" )
void setupArtifact( String groupId, String artifactId, String goal, String type )
      throws DuplicateMojoDescriptorException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException {

   DefaultArtifact artifact = new DefaultArtifact( groupId, artifactId, "DUMMY", "compile", type, "", null );
   MojoDescriptor mojoDescriptor = new MojoDescriptor();
   mojoDescriptor.setGoal( goal );
   PluginDescriptor pluginDescriptor = new PluginDescriptor();
   pluginDescriptor.addMojo( mojoDescriptor );

   Plugin plugin = new Plugin();
   plugin.setGroupId( groupId );
   plugin.setArtifactId( artifactId );

   when( this.mojo.pluginManager.loadPlugin( eq( plugin ), anyList(), any( RepositorySystemSession.class ) ) ).thenReturn( pluginDescriptor );

   this.mojo.pluginDescriptor.getArtifactMap().put( String.format( "%s:%s", groupId, artifactId ), artifact );
}
项目:takari-lifecycle    文件:MojoConfigurationMergerTest.java   
@Test
public void extractionOfMojoSpecificConfigurationAndMergingwithDefaultMojoConfiguration() throws Exception {
  InputStream is = getClass().getResourceAsStream("/META-INF/maven/plugin.xml");
  assertNotNull(is);
  PluginDescriptor pluginDescriptor = pluginDescriptorBuilder.build(new InputStreamReader(is, "UTF-8"));
  String goal = merger.determineGoal("io.takari.maven.plugins.jar.Jar", pluginDescriptor);
  assertEquals("We expect the goal name to be 'jar'", "jar", goal);
  MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal);
  PlexusConfiguration defaultMojoConfiguration = mojoDescriptor.getMojoConfiguration();
  System.out.println(defaultMojoConfiguration);

  PlexusConfiguration configurationFromMaven = builder("configuration") //
      .es("jar") //
      .es("sourceJar").v("true").ee() //
      .ee() //
      .buildPlexusConfiguration();

  PlexusConfiguration mojoConfiguration = merger.extractAndMerge(goal, configurationFromMaven, defaultMojoConfiguration);

  String xml = mojoConfiguration.toString();
  assertXpathEvaluatesTo("java.io.File", "/configuration/classesDirectory/@implementation", xml);
  assertXpathEvaluatesTo("${project.build.outputDirectory}", "/configuration/classesDirectory/@default-value", xml);
  assertXpathEvaluatesTo("java.util.List", "/configuration/reactorProjects/@implementation", xml);
  assertXpathEvaluatesTo("${reactorProjects}", "/configuration/reactorProjects/@default-value", xml);
  assertXpathEvaluatesTo("true", "/configuration/sourceJar", xml);
}
项目:iterator-maven-plugin    文件:IteratorMojo.java   
/**
 * Taken from MojoExecutor of Don Brown. Make it working with Maven 3.1.
 * 
 * @param plugin
 * @param goal
 * @param configuration
 * @param env
 * @throws MojoExecutionException
 * @throws PluginResolutionException
 * @throws PluginDescriptorParsingException
 * @throws InvalidPluginDescriptorException
 * @throws PluginManagerException
 * @throws PluginConfigurationException
 * @throws MojoFailureException
 */
private void executeMojo( Plugin plugin, String goal, Xpp3Dom configuration )
    throws MojoExecutionException, PluginResolutionException, PluginDescriptorParsingException,
    InvalidPluginDescriptorException, MojoFailureException, PluginConfigurationException, PluginManagerException
{

    if ( configuration == null )
    {
        throw new NullPointerException( "configuration may not be null" );
    }

    PluginDescriptor pluginDescriptor = getPluginDescriptor( plugin );

    MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
    if ( mojoDescriptor == null )
    {
        throw new MojoExecutionException( "Could not find goal '" + goal + "' in plugin " + plugin.getGroupId()
            + ":" + plugin.getArtifactId() + ":" + plugin.getVersion() );
    }

    MojoExecution exec = mojoExecution( mojoDescriptor, configuration );
    pluginManager.executeMojo( getMavenSession(), exec );
}
项目:eosgi-maven-plugin    文件:AbstractEOSGiMojo.java   
@Override
public final void execute() throws MojoExecutionException, MojoFailureException {
  artifactResolver = new PredefinedRepoArtifactResolver(repoSystem, repoSession,
      project.getRemoteProjectRepositories(), getLog());

  MojoDescriptor mojoDescriptor = mojo.getMojoDescriptor();
  String goalName = mojoDescriptor.getGoal();

  long eventId = GoogleAnalyticsTrackingService.DEFAULT_EVENT_ID;

  String pluginVersion = this.getClass().getPackage().getImplementationVersion();
  GoogleAnalyticsTrackingService googleAnalyticsTrackingService =
      new GoogleAnalyticsTrackingServiceImpl(analyticsWaitingTimeInMs, skipAnalytics(),
          pluginVersion, getLog());

  try {
    eventId = googleAnalyticsTrackingService.sendEvent(analyticsReferer, goalName);
    doExecute();
  } finally {
    googleAnalyticsTrackingService.waitForEventSending(eventId);
  }
}
项目:oceano    文件:MojoExecutor.java   
private ArtifactFilter getArtifactFilter( MojoDescriptor mojoDescriptor )
{
    String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired();
    String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired();

    List<String> scopes = new ArrayList<String>( 2 );
    if ( StringUtils.isNotEmpty( scopeToCollect ) )
    {
        scopes.add( scopeToCollect );
    }
    if ( StringUtils.isNotEmpty( scopeToResolve ) )
    {
        scopes.add( scopeToResolve );
    }

    if ( scopes.isEmpty() )
    {
        return null;
    }
    else
    {
        return new CumulativeScopeArtifactFilter( scopes );
    }
}
项目: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>() );
}
项目:oceano    文件:LifecycleDebugLogger.java   
private void debugDependencyRequirements( List<MojoExecution> mojoExecutions )
{
    Set<String> scopesToCollect = new TreeSet<String>();
    Set<String> scopesToResolve = new TreeSet<String>();

    for ( MojoExecution mojoExecution : mojoExecutions )
    {
        MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();

        String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired();
        if ( StringUtils.isNotEmpty( scopeToCollect ) )
        {
            scopesToCollect.add( scopeToCollect );
        }

        String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired();
        if ( StringUtils.isNotEmpty( scopeToResolve ) )
        {
            scopesToResolve.add( scopeToResolve );
        }
    }

    logger.debug( "Dependencies (collect): " + scopesToCollect );
    logger.debug( "Dependencies (resolve): " + scopesToResolve );
}
项目:oceano    文件:PluginParameterException.java   
public String buildDiagnosticMessage()
{
    StringBuilder messageBuffer = new StringBuilder( 256 );

    List<Parameter> params = getParameters();
    MojoDescriptor mojo = getMojoDescriptor();

    messageBuffer.append( "One or more required plugin parameters are invalid/missing for \'" )
        .append( mojo.getPluginDescriptor().getGoalPrefix() ).append( ":" ).append( mojo.getGoal() )
        .append( "\'\n" );

    int idx = 0;
    for ( Iterator<Parameter> it = params.iterator(); it.hasNext(); idx++ )
    {
        Parameter param = it.next();

        messageBuffer.append( "\n[" ).append( idx ).append( "] " );

        decomposeParameterIntoUserInstructions( mojo, param, messageBuffer );

        messageBuffer.append( "\n" );
    }

    return messageBuffer.toString();
}
项目:oceano    文件:DefaultMavenPluginManager.java   
public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List<RemoteRepository> repositories,
                                         RepositorySystemSession session )
    throws MojoNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
    InvalidPluginDescriptorException
{
    PluginDescriptor pluginDescriptor = getPluginDescriptor( plugin, repositories, session );

    MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );

    if ( mojoDescriptor == null )
    {
        throw new MojoNotFoundException( goal, pluginDescriptor );
    }

    return mojoDescriptor;
}
项目:oceano    文件:ValidatingConfigurationListener.java   
public ValidatingConfigurationListener( Object mojo, MojoDescriptor mojoDescriptor, ConfigurationListener delegate )
{
    this.mojo = mojo;
    this.delegate = delegate;
    this.missingParameters = new HashMap<String, Parameter>();

    if ( mojoDescriptor.getParameters() != null )
    {
        for ( Parameter param : mojoDescriptor.getParameters() )
        {
            if ( param.isRequired() )
            {
                missingParameters.put( param.getName(), param );
            }
        }
    }
}
项目:oceano    文件:PluginManagerTest.java   
public void testMojoDescriptorRetrieval()
    throws Exception
{
    MavenSession session = createMavenSession( null );       
    String goal = "it";
    Plugin plugin = new Plugin();
    plugin.setGroupId( "org.apache.maven.its.plugins" );
    plugin.setArtifactId( "maven-it-plugin" );
    plugin.setVersion( "0.1" );

    MojoDescriptor mojoDescriptor =
        pluginManager.getMojoDescriptor( plugin, goal, session.getCurrentProject().getRemotePluginRepositories(),
                                         session.getRepositorySession() );
    assertNotNull( mojoDescriptor );
    assertEquals( goal, mojoDescriptor.getGoal() );
    // igorf: plugin realm comes later
    // assertNotNull( mojoDescriptor.getRealm() );

    PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
    assertNotNull( pluginDescriptor );
    assertEquals( "org.apache.maven.its.plugins", pluginDescriptor.getGroupId() );
    assertEquals( "maven-it-plugin", pluginDescriptor.getArtifactId() );
    assertEquals( "0.1", pluginDescriptor.getVersion() );
}
项目:oceano    文件:PluginParameterExpressionEvaluatorTest.java   
private ExpressionEvaluator createExpressionEvaluator( MavenProject project, PluginDescriptor pluginDescriptor, Properties executionProperties )
    throws Exception
{
    ArtifactRepository repo = factory.createDefaultLocalRepository();

    MutablePlexusContainer container = (MutablePlexusContainer) getContainer();
    MavenSession session = createSession( container, repo, executionProperties );
    session.setCurrentProject( project );

    MojoDescriptor mojo = new MojoDescriptor();
    mojo.setPluginDescriptor( pluginDescriptor );
    mojo.setGoal( "goal" );

    MojoExecution mojoExecution = new MojoExecution( mojo );

    return new PluginParameterExpressionEvaluator( session, mojoExecution );
}
项目:wisdom    文件:PluginExtractor.java   
/**
 * Extracts the subset of the given configuration containing only the values accepted by the plugin/goal. The
 * configuration is modified in-place. The the extraction fail the configuration stays unchanged.
 *
 * @param mojo          the Wisdom mojo
 * @param plugin        the plugin object
 * @param goal          the goal / mojo
 * @param configuration the global configuration
 */
public static void extractEligibleConfigurationForGoal(AbstractWisdomMojo mojo,
                                                       Plugin plugin, String goal, Xpp3Dom configuration) {
    try {
        MojoDescriptor descriptor = mojo.pluginManager.getMojoDescriptor(plugin, goal,
                mojo.remoteRepos, mojo.repoSession);
        final List<Parameter> parameters = descriptor.getParameters();
        Xpp3Dom[] children = configuration.getChildren();
        if (children != null) {
            for (int i = children.length - 1; i >= 0; i--) {
                Xpp3Dom child = children[i];
                if (!contains(parameters, child.getName())) {
                    configuration.removeChild(i);
                }
            }
        }
    } catch (Exception e) {
        mojo.getLog().warn("Cannot extract the eligible configuration for goal " + goal + " from the " +
                "configuration");
        mojo.getLog().debug(e);
        // The configuration is not changed.
    }

}
项目:mule-tooling-incubator    文件:LaunchView.java   
private void getMojosAndGoals(Model model, Plugin plugin) throws IOException, PlexusConfigurationException, Exception {
    String version = plugin.getVersion();
    if (version != null && version.startsWith("$")) {
        version = model.getProperties().getProperty(plugin.getVersion().substring(2, plugin.getVersion().length() - 1));
        plugin.setVersion(version);
    }
    Set<MojoDescriptor> mojoList = new HashSet<MojoDescriptor>();
    try {
        PluginDescriptor pluginDesc = ProjectModelCache.getInstance().getPluginDescriptor(plugin);
        if (pluginDesc != null) {
            for (Object exec : pluginDesc.getMojos()) {
                MojoDescriptor mojoDesc = (MojoDescriptor) exec;
                mojoList.add(mojoDesc);
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    config.addMojos(plugin.getKey(), mojoList);
}
项目:mule-tooling-incubator    文件:ConfigLabelProvider.java   
@Override
public String getText(Object element) {
    if (element instanceof Profile) {
        return ((Profile) element).getName();
    }
    if (element instanceof Plugin) {
        return ((Plugin) element).getKey();
    }
    if (element instanceof ProjectLabel) {
        return ((ProjectLabel) element).label;
    }
    if (element instanceof MojoDescriptor) {
        MojoDescriptor mojo = ((MojoDescriptor) element);
        return mojo.getPluginDescriptor().getGoalPrefix() + ":" + mojo.getGoal();
    }
    return element.toString();
}
项目:mule-tooling-incubator    文件:ConfigLabelProvider.java   
@Override
public Image getImage(Object element) {
    if (element instanceof LifeCycle) {
        return MavenImages.LIFE_CYCLE_GOAL;
    }
    if (element.equals("Projects")) {
        return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_HOME_NAV);
    }
    if (element.equals("Profiles")) {
        return MavenImages.PROFILES;
    }
    if ("Lifecycle".equals(element)) {
        return MavenImages.MID_LABEL;
    }
    if (element instanceof ProjectLabel) {
        return MavenImages.MID_LABEL;
    }
    if (element instanceof MojoDescriptor) {
        return MavenImages.LIFE_CYCLE_GOAL;
    }
    if (element instanceof Plugin) {
        return MavenImages.PLUGIN;
    }
    return PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT);
}
项目:maven-cdi-plugin-utils    文件:AbstractCDIMojo.java   
private String getGoalName() {
  PluginDescriptor pluginDescriptor = getPluginDescriptor();
  for (MojoDescriptor mojoDescriptor : pluginDescriptor.getMojos()) {
    if (mojoDescriptor.getImplementation().equals(getClass().getName())) {
      return mojoDescriptor.getGoal();
    }
  }
  return null;
}
项目:karaf-boot    文件:GenerateMojo.java   
private MojoDescriptor getMavenBundleMojo() throws Exception {
    Plugin plugin = new Plugin();
    plugin.setGroupId("org.apache.felix");
    plugin.setArtifactId("maven-bundle-plugin");
    plugin.setVersion("3.0.0");
    plugin.setInherited(true);
    plugin.setExtensions(true);
    PluginDescriptor desc = pluginManager.loadPlugin(plugin, mavenProject.getRemotePluginRepositories(), mavenSession.getRepositorySession());
    return desc.getMojo("bundle");
}
项目: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);
}
项目:diffusion-maven-plugin    文件:DiffusionExecutionStub.java   
@Override
public MojoDescriptor getMojoDescriptor() {
    return new MojoDescriptor() {
        @Override
        public String getGoal() {
            return "start";
        }
    };
}
项目:ARCHIVE-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);
}
项目:takari-lifecycle    文件:MojoConfigurationProcessor.java   
String determineGoal(String className, PluginDescriptor pluginDescriptor) throws ComponentConfigurationException {
  List<MojoDescriptor> mojos = pluginDescriptor.getMojos();
  for (MojoDescriptor mojo : mojos) {
    if (className.equals(mojo.getImplementation())) {
      return mojo.getGoal();
    }
  }
  throw new ComponentConfigurationException("Cannot find the goal implementation with " + className);
}
项目:oceano    文件:MavenExecutionPlan.java   
/**
 * Get set of mojos used but not marked @threadSafe
 *
 * @return the set of mojo descriptors
 */
public Set<MojoDescriptor> getNonThreadSafeMojos()
{
    Set<MojoDescriptor> mojos = new HashSet<MojoDescriptor>();
    for ( ExecutionPlanItem executionPlanItem : planItem )
    {
        final MojoExecution mojoExecution = executionPlanItem.getMojoExecution();
        if ( !mojoExecution.getMojoDescriptor().isThreadSafe() )
        {
            mojos.add( mojoExecution.getMojoDescriptor() );
        }
    }
    return mojos;
}
项目:oceano    文件:MojoExecutor.java   
private void collectDependencyRequirements( Set<String> scopesToResolve, Set<String> scopesToCollect,
                                            Collection<MojoExecution> mojoExecutions )
{
    for ( MojoExecution mojoExecution : mojoExecutions )
    {
        MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();

        scopesToResolve.addAll( toScopes( mojoDescriptor.getDependencyResolutionRequired() ) );

        scopesToCollect.addAll( toScopes( mojoDescriptor.getDependencyCollectionRequired() ) );
    }
}
项目:oceano    文件:DefaultLifecycleExecutionPlanCalculator.java   
public List<MojoExecution> calculateMojoExecutions( MavenSession session, MavenProject project,
                                                     List<Object> tasks )
    throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
    MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
    PluginVersionResolutionException, LifecyclePhaseNotFoundException
{
    final List<MojoExecution> mojoExecutions = new ArrayList<MojoExecution>();

    for ( Object task : tasks )
    {
        if ( task instanceof GoalTask )
        {
            String pluginGoal = ( (GoalTask) task ).pluginGoal;

            MojoDescriptor mojoDescriptor = mojoDescriptorCreator.getMojoDescriptor( pluginGoal, session, project );

            MojoExecution mojoExecution =
                new MojoExecution( mojoDescriptor, "default-cli", MojoExecution.Source.CLI );

            mojoExecutions.add( mojoExecution );
        }
        else if ( task instanceof LifecycleTask )
        {
            String lifecyclePhase = ( (LifecycleTask) task ).getLifecyclePhase();

            Map<String, List<MojoExecution>> phaseToMojoMapping =
                calculateLifecycleMappings( session, project, lifecyclePhase );

            for ( List<MojoExecution> mojoExecutionsFromLifecycle : phaseToMojoMapping.values() )
            {
                mojoExecutions.addAll( mojoExecutionsFromLifecycle );
            }
        }
        else
        {
            throw new IllegalStateException( "unexpected task " + task );
        }
    }
    return mojoExecutions;
}
项目:oceano    文件:DefaultLifecycleExecutionPlanCalculator.java   
public void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session )
    throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException,
    PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
    LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException
{
    calculateForkedExecutions( mojoExecution, session, session.getCurrentProject(), new HashSet<MojoDescriptor>() );
}
项目:oceano    文件:DefaultLifecycleExecutionPlanCalculator.java   
private List<MojoExecution> calculateForkedGoal( MojoExecution mojoExecution, MavenSession session,
                                                 MavenProject project,
                                                 Collection<MojoDescriptor> alreadyForkedExecutions )
    throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException,
    PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
    LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException
{
    MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();

    PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();

    String forkedGoal = mojoDescriptor.getExecuteGoal();

    MojoDescriptor forkedMojoDescriptor = pluginDescriptor.getMojo( forkedGoal );
    if ( forkedMojoDescriptor == null )
    {
        throw new MojoNotFoundException( forkedGoal, pluginDescriptor );
    }

    if ( alreadyForkedExecutions.contains( forkedMojoDescriptor ) )
    {
        return Collections.emptyList();
    }

    MojoExecution forkedExecution = new MojoExecution( forkedMojoDescriptor, forkedGoal );

    populateMojoExecutionConfiguration( project, forkedExecution, true );

    finalizeMojoConfiguration( forkedExecution );

    calculateForkedExecutions( forkedExecution, session, project, alreadyForkedExecutions );

    return Collections.singletonList( forkedExecution );
}
项目:oceano    文件:MojoDescriptorCreator.java   
public static Xpp3Dom convert( MojoDescriptor mojoDescriptor )
{
    Xpp3Dom dom = new Xpp3Dom( "configuration" );

    PlexusConfiguration c = mojoDescriptor.getMojoConfiguration();

    PlexusConfiguration[] ces = c.getChildren();

    if ( ces != null )
    {
        for ( PlexusConfiguration ce : ces )
        {
            String value = ce.getValue( null );
            String defaultValue = ce.getAttribute( "default-value", null );
            if ( value != null || defaultValue != null )
            {
                Xpp3Dom e = new Xpp3Dom( ce.getName() );
                e.setValue( value );
                if ( defaultValue != null )
                {
                    e.setAttribute( "default-value", defaultValue );
                }
                dom.addChild( e );
            }
        }
    }

    return dom;
}
项目:oceano    文件:DefaultLifecycleExecutor.java   
@SuppressWarnings( { "UnusedDeclaration" } )
MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProject project, String invokedVia,
                                  boolean canUsePrefix, boolean isOptionalMojo )
    throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
    MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
    PluginVersionResolutionException
{
    return mojoDescriptorCreator.getMojoDescriptor( task, session, project );
}
项目:oceano    文件:PluginParameterException.java   
public PluginParameterException( MojoDescriptor mojo, List<Parameter> parameters )
{
    super( mojo.getPluginDescriptor(), "The parameters " + format( parameters ) + " for goal "
        + mojo.getRoleHint() + " are missing or invalid" );

    this.mojo = mojo;

    this.parameters = parameters;
}
项目:oceano    文件:PluginParameterException.java   
private static void decomposeParameterIntoUserInstructions( MojoDescriptor mojo, Parameter param,
                                                            StringBuilder messageBuffer )
{
    String expression = param.getExpression();

    if ( param.isEditable() )
    {
        messageBuffer.append( "Inside the definition for plugin \'" + mojo.getPluginDescriptor().getArtifactId()
            + "\', specify the following:\n\n<configuration>\n  ...\n  <" + param.getName() + ">VALUE</"
            + param.getName() + ">\n</configuration>" );

        String alias = param.getAlias();
        if ( StringUtils.isNotEmpty( alias ) && !alias.equals( param.getName() ) )
        {
            messageBuffer.append(
                "\n\n-OR-\n\n<configuration>\n  ...\n  <" + alias + ">VALUE</" + alias + ">\n</configuration>\n" );
        }
    }

    if ( StringUtils.isEmpty( expression ) )
    {
        messageBuffer.append( "." );
    }
    else
    {
        if ( param.isEditable() )
        {
            messageBuffer.append( "\n\n-OR-\n\n" );
        }

        //addParameterUsageInfo( expression, messageBuffer );
    }
}
项目:oceano    文件:DefaultBuildPluginManager.java   
public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List<RemoteRepository> repositories,
                                         RepositorySystemSession session )
    throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
    MojoNotFoundException, InvalidPluginDescriptorException
{
    return mavenPluginManager.getMojoDescriptor( plugin, goal, repositories, session );
}
项目:oceano    文件:MojoExecution.java   
public MojoExecution( MojoDescriptor mojoDescriptor, String executionId, Source source )
{
    this.mojoDescriptor = mojoDescriptor;
    this.executionId = executionId;
    this.configuration = null;
    this.source = source;
}
项目:oceano    文件:PluginContainerException.java   
public PluginContainerException( MojoDescriptor mojoDescriptor, ClassRealm pluginRealm, String message,
                                 ComponentLookupException e )
{
    super( mojoDescriptor, message, e );

    this.pluginRealm = pluginRealm;
}
项目:oceano    文件:PluginManagerException.java   
protected PluginManagerException( MojoDescriptor mojoDescriptor, String message, Throwable cause )
{
    super( message, cause );
    pluginGroupId = mojoDescriptor.getPluginDescriptor().getGroupId();
    pluginArtifactId = mojoDescriptor.getPluginDescriptor().getArtifactId();
    pluginVersion = mojoDescriptor.getPluginDescriptor().getVersion();
    goal = mojoDescriptor.getGoal();
}
项目:oceano    文件:PluginManagerException.java   
protected PluginManagerException( MojoDescriptor mojoDescriptor, MavenProject project, String message )
{
    super( message );
    this.project = project;
    pluginGroupId = mojoDescriptor.getPluginDescriptor().getGroupId();
    pluginArtifactId = mojoDescriptor.getPluginDescriptor().getArtifactId();
    pluginVersion = mojoDescriptor.getPluginDescriptor().getVersion();
    goal = mojoDescriptor.getGoal();
}
项目:oceano    文件:PluginManagerException.java   
protected PluginManagerException( MojoDescriptor mojoDescriptor, MavenProject project, String message,
                                  Throwable cause )
{
    super( message, cause );
    this.project = project;
    pluginGroupId = mojoDescriptor.getPluginDescriptor().getGroupId();
    pluginArtifactId = mojoDescriptor.getPluginDescriptor().getArtifactId();
    pluginVersion = mojoDescriptor.getPluginDescriptor().getVersion();
    goal = mojoDescriptor.getGoal();
}
项目:oceano    文件:PluginManagerException.java   
public PluginManagerException( MojoDescriptor mojoDescriptor, MavenProject project, String message,
                               NoSuchRealmException cause )
{
    super( message, cause );

    this.project = project;
    pluginGroupId = mojoDescriptor.getPluginDescriptor().getGroupId();
    pluginArtifactId = mojoDescriptor.getPluginDescriptor().getArtifactId();
    pluginVersion = mojoDescriptor.getPluginDescriptor().getVersion();
    goal = mojoDescriptor.getGoal();
}