本文整理汇总了Java中org.apache.maven.plugin.descriptor.PluginDescriptor.getArtifacts方法的典型用法代码示例。如果您正苦于以下问题:Java PluginDescriptor.getArtifacts方法的具体用法?Java PluginDescriptor.getArtifacts怎么用?Java PluginDescriptor.getArtifacts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.plugin.descriptor.PluginDescriptor
的用法示例。
在下文中一共展示了PluginDescriptor.getArtifacts方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveVersions
import org.apache.maven.plugin.descriptor.PluginDescriptor; //导入方法依赖的package包/类
private static List<Artifact> resolveVersions(PluginDescriptor pluginDescriptor, String pluginArtifactId, List<ExpectedDependency> expectedDependencies) throws MojoExecutionException {
List<Artifact> actualDependencies = new ArrayList<>();
for (Artifact artifact : pluginDescriptor.getArtifacts()) {
if (! isExpected(artifact, expectedDependencies)) {
continue;
}
if (isKnown(artifact, actualDependencies)) {
continue;
}
failOnVersionConflict(artifact, actualDependencies, pluginArtifactId);
actualDependencies.add(artifact);
}
return actualDependencies;
}
示例2: newMojoExecution
import org.apache.maven.plugin.descriptor.PluginDescriptor; //导入方法依赖的package包/类
private MojoExecution newMojoExecution(Xpp3Dom... parameters) throws IOException {
MojoExecution execution = mojos.newMojoExecution("testProperties", parameters);
PluginDescriptor pluginDescriptor = execution.getMojoDescriptor().getPluginDescriptor();
ArtifactHandler handler = new DefaultArtifactHandler("jar");
DefaultArtifact workspaceResolver = new DefaultArtifact("io.takari.m2e.workspace", "org.eclipse.m2e.workspace.cli", "1", Artifact.SCOPE_COMPILE, ".jar", null, handler);
workspaceResolver.setFile(new File("target/workspaceResolver.jar").getCanonicalFile());
List<Artifact> pluginArtifacts = new ArrayList<>(pluginDescriptor.getArtifacts());
pluginArtifacts.add(workspaceResolver);
pluginDescriptor.setArtifacts(pluginArtifacts);
return execution;
}
示例3: execute
import org.apache.maven.plugin.descriptor.PluginDescriptor; //导入方法依赖的package包/类
@Override
@SuppressWarnings("PMD.EmptyCatchBlock")
public void execute() throws MojoExecutionException, MojoFailureException {
ArrayNode root = new ArrayNode(JsonNodeFactory.instance);
URLClassLoader classLoader = null;
try {
PluginDescriptor desc = (PluginDescriptor) getPluginContext().get("pluginDescriptor");
List<Artifact> artifacts = desc.getArtifacts();
ProjectBuildingRequest buildingRequest =
new DefaultProjectBuildingRequest(session.getProjectBuildingRequest());
buildingRequest.setRemoteRepositories(remoteRepositories);
for (Artifact artifact : artifacts) {
ArtifactResult result = artifactResolver.resolveArtifact(buildingRequest, artifact);
File jar = result.getArtifact().getFile();
classLoader = createClassLoader(jar);
if (classLoader == null) {
throw new IOException("Can not create classloader for " + jar);
}
ObjectNode entry = new ObjectNode(JsonNodeFactory.instance);
addConnectorMeta(entry, classLoader);
addComponentMeta(entry, classLoader);
if (entry.size() > 0) {
addGav(entry, artifact);
root.add(entry);
}
}
if (root.size() > 0) {
saveCamelMetaData(root);
}
} catch (ArtifactResolverException | IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
} finally {
if (classLoader != null) {
try {
classLoader.close();
} catch (IOException ignored) {
}
}
}
}
示例4: testThatPluginDependencyThatHasSystemScopeIsResolved
import org.apache.maven.plugin.descriptor.PluginDescriptor; //导入方法依赖的package包/类
public void testThatPluginDependencyThatHasSystemScopeIsResolved()
throws Exception
{
/*
File systemPath = new File( getBasedir(), "pom.xml" );
Plugin plugin = new PluginBuilder( "org.apache.maven", "project-test", "1.0" )
.addDependency( "org.apache.maven", "system-dependency", "1.0", Artifact.SCOPE_SYSTEM, systemPath.getAbsolutePath() )
.get();
MavenProject pluginProject = new ProjectBuilder( "org.apache.maven", "project-test", "1.0" )
.addPlugin( plugin )
.addDependency( "junit", "junit", "3.8.1", Artifact.SCOPE_COMPILE )
.get();
// i'm making this artifact which is assumed to come from a pom in the metadata processor, then it tries to create a POM artifact
// and parse it for the dependencies and it blows up.
//
// we need to pass this through as is so it doesn't get parsed again.
Artifact pluginArtifact = new ProjectArtifact( pluginProject );
Set<Artifact> artifacts = pluginManager.getPluginArtifacts( pluginArtifact, plugin, getLocalRepository(), getPluginArtifactRepositories() );
System.out.println( artifacts );
*/
MavenSession session = createMavenSession( getProject( "project-contributing-system-scope-plugin-dep" ) );
MavenProject project = session.getCurrentProject();
Plugin plugin = project.getPlugin( "org.apache.maven.its.plugins:maven-it-plugin" );
RepositoryRequest repositoryRequest = new DefaultRepositoryRequest();
repositoryRequest.setLocalRepository( getLocalRepository() );
repositoryRequest.setRemoteRepositories( getPluginArtifactRepositories() );
PluginDescriptor pluginDescriptor =
pluginManager.loadPlugin( plugin, session.getCurrentProject().getRemotePluginRepositories(),
session.getRepositorySession() );
pluginManager.getPluginRealm( session, pluginDescriptor );
List<Artifact> artifacts = pluginDescriptor.getArtifacts();
for ( Artifact a : artifacts )
{
if ( a.getGroupId().equals( "org.apache.maven.its.mng3586" ) && a.getArtifactId().equals( "tools" ) )
{
// The system scoped dependencies will be present in the classloader for the plugin
return;
}
}
fail( "Can't find the system scoped dependency in the plugin artifacts." );
}