本文整理汇总了Java中org.apache.maven.plugin.descriptor.PluginDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java PluginDescriptor类的具体用法?Java PluginDescriptor怎么用?Java PluginDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PluginDescriptor类属于org.apache.maven.plugin.descriptor包,在下文中一共展示了PluginDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.apache.maven.plugin.descriptor.PluginDescriptor; //导入依赖的package包/类
static AgentDependencies init(PluginDescriptor pluginDescriptor) throws MojoExecutionException {
String pluginGroupId = pluginDescriptor.getGroupId();
String pluginArtifactId = pluginDescriptor.getArtifactId();
List<ExpectedDependency> expectedDependencies = Arrays.asList(
new ExpectedDependency(pluginGroupId, "promagent-agent"),
new ExpectedDependency(pluginGroupId, "promagent-internal"),
new ExpectedDependency(pluginGroupId, "promagent-api"),
new ExpectedDependency("io.prometheus", "simpleclient_common"),
new ExpectedDependency("io.prometheus", "simpleclient"),
new ExpectedDependency("net.bytebuddy", "byte-buddy"),
new ExpectedDependency("commons-io", "commons-io")
);
List<Artifact> actualDependencies = resolveVersions(pluginDescriptor, pluginArtifactId, expectedDependencies);
failUnlessComplete(actualDependencies, expectedDependencies, pluginArtifactId);
return new AgentDependencies(pluginGroupId, actualDependencies);
}
示例2: getWorkflowDescriptor
import org.apache.maven.plugin.descriptor.PluginDescriptor; //导入依赖的package包/类
public static InputStream getWorkflowDescriptor(String goalName, PluginDescriptor pluginDescriptor,
Optional<File> customWorkflowDescriptor, Logger log) throws MojoExecutionException {
log.info("Constructing workflow for processing");
String goalPrefix = pluginDescriptor.getGoalPrefix();
if (customWorkflowDescriptor.isPresent()) {
File customDescriptor = customWorkflowDescriptor.get();
log.debug("Requested overriding of workflow with file: " + customDescriptor.getAbsolutePath());
if (customDescriptor.exists() && customDescriptor.isFile()) {
try {
log.info("Workflow of goal '" + goalPrefix + ':' + goalName + "' will be overriden by file '"
+ customDescriptor.getAbsolutePath() + "'.");
return new FileInputStream(customDescriptor);
} catch (Exception e) {
throw new MojoExecutionException("Unable to load custom workflow for goal " + goalName, e);
}
} else {
throw new MojoExecutionException("Unable to load custom workflow for goal " + goalPrefix + ':' + goalName
+ ". The workflow file '" + customDescriptor.getAbsolutePath() + "' does not exist!");
}
}
log.info("Goal '" + goalPrefix + ':' + goalName + "' will use default workflow packaged with the plugin.");
return Thread.currentThread().getContextClassLoader().getResourceAsStream(DEFAULT_WORKFLOW_DIR + "/" + goalName);
}
示例3: executePluginDef
import org.apache.maven.plugin.descriptor.PluginDescriptor; //导入依赖的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));
}
}
}
示例4: PlanContext
import org.apache.maven.plugin.descriptor.PluginDescriptor; //导入依赖的package包/类
/** */
public PlanContext(
ProcessRunner processRunner,
PluginDescriptor pluginDescriptor,
BuildContext buildContext,
Log log,
SrcfilesDirs srcfilesDirs,
GenfilesDirs genfilesDirs,
ImmutableList<Artifact> artifacts,
File outputDir,
File projectBuildOutputDirectory,
File closureOutputDirectory,
StableCssSubstitutionMapProvider substitutionMapProvider) {
this.processRunner = processRunner;
this.pluginDescriptor = pluginDescriptor;
this.buildContext = buildContext;
this.log = log;
this.srcfilesDirs = srcfilesDirs;
this.genfilesDirs = genfilesDirs;
this.artifacts = artifacts;
this.outputDir = outputDir;
this.projectBuildOutputDirectory = projectBuildOutputDirectory;
this.closureOutputDirectory = closureOutputDirectory;
this.substitutionMapProvider = substitutionMapProvider;
}
示例5: SetupsMojoTestHelper
import org.apache.maven.plugin.descriptor.PluginDescriptor; //导入依赖的package包/类
public SetupsMojoTestHelper( AbstractSetupsMojo mojo ) throws IOException {
this.workingDir = new File( System.getProperty( "java.io.tmpdir" ), "unit_test_working" );
this.mojo = mojo;
this.mojo.workingDir = this.workingDir.getCanonicalPath();
this.mojo.root = FitNesseHelper.DEFAULT_ROOT;
this.mojo.project = new MavenProject();
this.mojo.project.setFile( new File( getClass().getResource( "pom.xml" ).getPath() ) );
this.mojo.pluginDescriptor = new PluginDescriptor();
this.mojo.pluginManager = mock( BuildPluginManager.class );
this.mojo.session = mock( MavenSession.class );
this.logStream = new ByteArrayOutputStream();
this.mojo.setLog( new DefaultLog( new PrintStreamLogger( Logger.LEVEL_INFO, "test", new PrintStream( this.logStream ) ) ) );
}
示例6: setupArtifact
import org.apache.maven.plugin.descriptor.PluginDescriptor; //导入依赖的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 );
}
示例7: extractionOfMojoSpecificConfigurationAndMergingwithDefaultMojoConfiguration
import org.apache.maven.plugin.descriptor.PluginDescriptor; //导入依赖的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);
}
示例8: executeMojo
import org.apache.maven.plugin.descriptor.PluginDescriptor; //导入依赖的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 );
}
示例9: getMojoDescriptor
import org.apache.maven.plugin.descriptor.PluginDescriptor; //导入依赖的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;
}
示例10: checkRequiredMavenVersion
import org.apache.maven.plugin.descriptor.PluginDescriptor; //导入依赖的package包/类
public void checkRequiredMavenVersion( PluginDescriptor pluginDescriptor )
throws PluginIncompatibleException
{
String requiredMavenVersion = pluginDescriptor.getRequiredMavenVersion();
if ( StringUtils.isNotBlank( requiredMavenVersion ) )
{
try
{
if ( !runtimeInformation.isMavenVersion( requiredMavenVersion ) )
{
throw new PluginIncompatibleException( pluginDescriptor.getPlugin(), "The plugin "
+ pluginDescriptor.getId() + " requires Maven version " + requiredMavenVersion );
}
}
catch ( RuntimeException e )
{
logger.warn( "Could not verify plugin's Maven prerequisite: " + e.getMessage() );
}
}
}
示例11: getPluginDescriptorForPrefix
import org.apache.maven.plugin.descriptor.PluginDescriptor; //导入依赖的package包/类
public PluginDescriptor getPluginDescriptorForPrefix( String prefix )
{
MavenSession session = legacySupport.getSession();
PluginPrefixRequest request = new DefaultPluginPrefixRequest( prefix, session );
try
{
PluginPrefixResult result = pluginPrefixResolver.resolve( request );
Plugin plugin = new Plugin();
plugin.setGroupId( result.getGroupId() );
plugin.setArtifactId( result.getArtifactId() );
return loadPluginDescriptor( plugin, session.getCurrentProject(), session );
}
catch ( Exception e )
{
return null;
}
}
示例12: loadPluginFully
import org.apache.maven.plugin.descriptor.PluginDescriptor; //导入依赖的package包/类
public PluginDescriptor loadPluginFully( Plugin plugin, MavenProject project, MavenSession session )
throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException,
PluginVersionNotFoundException
{
PluginDescriptor pluginDescriptor = loadPluginDescriptor( plugin, project, session );
try
{
pluginManager.setupPluginRealm( pluginDescriptor, session, null, null, null );
}
catch ( PluginResolutionException e )
{
throw new PluginManagerException( plugin, e.getMessage(), e );
}
return pluginDescriptor;
}
示例13: getPluginContext
import org.apache.maven.plugin.descriptor.PluginDescriptor; //导入依赖的package包/类
public Map getPluginContext( PluginDescriptor plugin, MavenProject project )
{
Map pluginContextsByKey = (Map) pluginContextsByProjectAndPluginKey.get( project.getId() );
if ( pluginContextsByKey == null )
{
pluginContextsByKey = new HashMap();
pluginContextsByProjectAndPluginKey.put( project.getId(), pluginContextsByKey );
}
Map pluginContext = (Map) pluginContextsByKey.get( plugin.getPluginLookupKey() );
if ( pluginContext == null )
{
pluginContext = new HashMap();
pluginContextsByKey.put( plugin.getPluginLookupKey(), pluginContext );
}
return pluginContext;
}
示例14: getPluginContext
import org.apache.maven.plugin.descriptor.PluginDescriptor; //导入依赖的package包/类
public Map<String, Object> getPluginContext( PluginDescriptor plugin, MavenProject project )
{
String projectKey = project.getId();
Map<String, Map<String, Object>> pluginContextsByKey = pluginContextsByProjectAndPluginKey.get( projectKey );
if ( pluginContextsByKey == null )
{
pluginContextsByKey = new ConcurrentHashMap<String, Map<String, Object>>();
pluginContextsByProjectAndPluginKey.put( projectKey, pluginContextsByKey );
}
String pluginKey = plugin.getPluginLookupKey();
Map<String, Object> pluginContext = pluginContextsByKey.get( pluginKey );
if ( pluginContext == null )
{
pluginContext = new ConcurrentHashMap<String, Object>();
pluginContextsByKey.put( pluginKey, pluginContext );
}
return pluginContext;
}
示例15: retrieveContext
import org.apache.maven.plugin.descriptor.PluginDescriptor; //导入依赖的package包/类
Map<String, Object> retrieveContext( MavenSession session )
{
Map<String, Object> context = null;
if ( session != null )
{
PluginDescriptor desc = new PluginDescriptor();
desc.setGroupId( PluginDescriptor.getDefaultPluginGroupId() );
desc.setArtifactId( PluginDescriptor.getDefaultPluginArtifactId( "toolchains" ) );
MavenProject current = session.getCurrentProject();
if ( current != null )
{
//TODO: why is this using the context
context = session.getPluginContext( desc, current );
}
}
return ( context != null ) ? context : new HashMap<String, Object>();
}