本文整理汇总了Java中org.apache.maven.plugin.descriptor.MojoDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java MojoDescriptor类的具体用法?Java MojoDescriptor怎么用?Java MojoDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MojoDescriptor类属于org.apache.maven.plugin.descriptor包,在下文中一共展示了MojoDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executePluginDef
import org.apache.maven.plugin.descriptor.MojoDescriptor; //导入依赖的package包/类
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));
}
}
}
示例2: setupArtifact
import org.apache.maven.plugin.descriptor.MojoDescriptor; //导入依赖的package包/类
@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 );
}
示例3: extractionOfMojoSpecificConfigurationAndMergingwithDefaultMojoConfiguration
import org.apache.maven.plugin.descriptor.MojoDescriptor; //导入依赖的package包/类
@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);
}
示例4: executeMojo
import org.apache.maven.plugin.descriptor.MojoDescriptor; //导入依赖的package包/类
/**
* 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 );
}
示例5: execute
import org.apache.maven.plugin.descriptor.MojoDescriptor; //导入依赖的package包/类
@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);
}
}
示例6: getArtifactFilter
import org.apache.maven.plugin.descriptor.MojoDescriptor; //导入依赖的package包/类
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 );
}
}
示例7: setupMojoExecution
import org.apache.maven.plugin.descriptor.MojoDescriptor; //导入依赖的package包/类
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>() );
}
示例8: debugDependencyRequirements
import org.apache.maven.plugin.descriptor.MojoDescriptor; //导入依赖的package包/类
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 );
}
示例9: buildDiagnosticMessage
import org.apache.maven.plugin.descriptor.MojoDescriptor; //导入依赖的package包/类
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();
}
示例10: getMojoDescriptor
import org.apache.maven.plugin.descriptor.MojoDescriptor; //导入依赖的package包/类
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;
}
示例11: ValidatingConfigurationListener
import org.apache.maven.plugin.descriptor.MojoDescriptor; //导入依赖的package包/类
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 );
}
}
}
}
示例12: testMojoDescriptorRetrieval
import org.apache.maven.plugin.descriptor.MojoDescriptor; //导入依赖的package包/类
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() );
}
示例13: createExpressionEvaluator
import org.apache.maven.plugin.descriptor.MojoDescriptor; //导入依赖的package包/类
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 );
}
示例14: extractEligibleConfigurationForGoal
import org.apache.maven.plugin.descriptor.MojoDescriptor; //导入依赖的package包/类
/**
* 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.
}
}
示例15: getMojosAndGoals
import org.apache.maven.plugin.descriptor.MojoDescriptor; //导入依赖的package包/类
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);
}