當前位置: 首頁>>代碼示例>>Java>>正文


Java PluginDescriptor.getArtifacts方法代碼示例

本文整理匯總了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;
}
 
開發者ID:fstab,項目名稱:promagent,代碼行數:15,代碼來源:AgentDependencies.java

示例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;
}
 
開發者ID:takari,項目名稱:takari-lifecycle,代碼行數:15,代碼來源:TestPropertiesMojoTest.java

示例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) {

            }
        }
    }
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:44,代碼來源:ExtractConnectorDescriptorsMojo.java

示例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." );
}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:51,代碼來源:PluginManagerTest.java


注:本文中的org.apache.maven.plugin.descriptor.PluginDescriptor.getArtifacts方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。