当前位置: 首页>>代码示例>>Java>>正文


Java ArtifactResolutionResult类代码示例

本文整理汇总了Java中org.apache.maven.artifact.resolver.ArtifactResolutionResult的典型用法代码示例。如果您正苦于以下问题:Java ArtifactResolutionResult类的具体用法?Java ArtifactResolutionResult怎么用?Java ArtifactResolutionResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ArtifactResolutionResult类属于org.apache.maven.artifact.resolver包,在下文中一共展示了ArtifactResolutionResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadSourcesDependency

import org.apache.maven.artifact.resolver.ArtifactResolutionResult; //导入依赖的package包/类
private void loadSourcesDependency(JavaProjectBuilder javaDocBuilder, Artifact sourcesArtifact) {
    // create request
    ArtifactResolutionRequest request = new ArtifactResolutionRequest();
    request.setArtifact(sourcesArtifact);

    // resolve deps
    ArtifactResolutionResult result = repositorySystem.resolve(request);

    // load source file into javadoc builder
    result.getArtifacts().forEach(artifact -> {
        try {
            JarFile jarFile = new JarFile(artifact.getFile());
            for (Enumeration entries = jarFile.entries(); entries.hasMoreElements(); ) {
                JarEntry entry = (JarEntry) entries.nextElement();
                String name = entry.getName();
                if (name.endsWith(".java") && !name.endsWith("/package-info.java")) {
                    javaDocBuilder.addSource(new URL("jar:" + artifact.getFile().toURI().toURL().toString() + "!/" + name));
                }
            }
        } catch (Exception e) {
            getLog().warn("Unable to load jar source " + artifact + " : " + e.getMessage());
        }
    });
}
 
开发者ID:jboz,项目名称:living-documentation,代码行数:25,代码来源:AbstractGlossaryMojo.java

示例2: resolveArtifactTransitively

import org.apache.maven.artifact.resolver.ArtifactResolutionResult; //导入依赖的package包/类
private Set<Artifact> resolveArtifactTransitively( final Artifact artifact ) {
   final ArtifactResolutionRequest request = new ArtifactResolutionRequest().setArtifact( artifact ).setResolveRoot( true ).setResolveTransitively( true )
         .setRemoteRepositories( this.remoteArtifactRepositories ).setLocalRepository( this.localRepository );
   if( this.excludeOptionalDependencies ){
      request.setCollectionFilter( OptionalArtifactFilter.INSTANCE );
   }
   final ArtifactResolutionResult result = this.resolver.resolve( request );
   if( !result.isSuccess() ){
      for( Artifact missing : result.getMissingArtifacts() ){
         getLog().error( String.format( "Could not resolve artifact: [%s]", missing ) );
      }
      if( result.hasExceptions() && getLog().isDebugEnabled() ){
         for( Exception exception : result.getExceptions() ){
            getLog().debug( exception );
         }
      }
   }
   final Set<Artifact> dependencies = result.getArtifacts();
   return dependencies;
}
 
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:21,代码来源:AbstractFitNesseMojo.java

示例3: addDependency

import org.apache.maven.artifact.resolver.ArtifactResolutionResult; //导入依赖的package包/类
private void addDependency( String groupId, String artifactId, String scope, boolean optional ) {
   final Artifact artifact = createArtifact( groupId, artifactId );
   artifact.setOptional( optional );
   artifact.setScope( scope );
   if( !optional ){
      this.mojo.project.getArtifacts().add( artifact );
   }
   this.mojo.project.getDependencies().add( createDependecy( groupId, artifactId, scope ) );
   this.mojo.project.getDependencyArtifacts().add( artifact );
   final ResolutionRequestForArtifact requestMatcher = new ResolutionRequestForArtifact( artifact );
   when( this.artifactResolver.resolve( argThat( requestMatcher ) ) ).thenAnswer( new Answer<ArtifactResolutionResult>() {
      @Override
      public ArtifactResolutionResult answer( InvocationOnMock invocation ) throws Throwable {
         ArtifactResolutionRequest request = (ArtifactResolutionRequest) invocation.getArguments()[0];
         if( requestMatcher.matches( request ) ){
            return createArtifactResolutionResult( artifact, request.getCollectionFilter() );
         }
         // Should never happen?
         return null;
      }
   } );
}
 
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:23,代码来源:FitNesseMojoTestHelper.java

示例4: createArtifactResolutionResult

import org.apache.maven.artifact.resolver.ArtifactResolutionResult; //导入依赖的package包/类
private ArtifactResolutionResult createArtifactResolutionResult( Collection<Artifact> artifacts, List<Artifact> missingArtifacts, ArtifactResolutionException exception, ArtifactFilter filter ) {
   ArtifactResolutionResult result = new ArtifactResolutionResult();
   Set<Artifact> strippedArtifacts = new HashSet<Artifact>( artifacts );
   if( OptionalArtifactFilter.INSTANCE.equals( filter ) ){
      Iterator<Artifact> artifactItr = strippedArtifacts.iterator();
      while( artifactItr.hasNext() ){
         boolean include = OptionalArtifactFilter.INSTANCE.include( artifactItr.next() );
         if( !include ){
            artifactItr.remove();
         }
      }
   }
   result.setArtifacts( new HashSet<Artifact>( strippedArtifacts ) );
   if( missingArtifacts != null ){
      result.setUnresolvedArtifacts( missingArtifacts );
   }
   if( exception != null ){
      result.addErrorArtifactException( exception );
   }
   return result;
}
 
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:22,代码来源:FitNesseMojoTestHelper.java

示例5: getDependencies

import org.apache.maven.artifact.resolver.ArtifactResolutionResult; //导入依赖的package包/类
private List<File> getDependencies() throws MojoExecutionException {
    Set<Artifact> artifacts = new HashSet<>();
    String version = props.getProperty("version");
    String jettyVersion = props.getProperty("jettyVersion");

    getLog().info("Resolving dependencies for version " + version +" of jetty-console-core");

    artifacts.add(artifactFactory.createDependencyArtifact("org.simplericity.jettyconsole", "jetty-console-core", VersionRange.createFromVersion(version), "jar", null, "runtime"));

    List<File> artifactFiles = new ArrayList<File>();
    try {
        ArtifactResolutionResult result = resolver.resolveTransitively(artifacts, project.getArtifact(), remoteRepositories, localRepository, artifactMetadataSource);
        for(Artifact artifact : (Set<Artifact>) result.getArtifacts()) {
            artifactFiles.add(artifact.getFile());
        }
        return artifactFiles;

    } catch (ArtifactResolutionException | ArtifactNotFoundException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
}
 
开发者ID:eirbjo,项目名称:jetty-console,代码行数:22,代码来源:CreateDescriptorMojo.java

示例6: getTransitiveDependencies

import org.apache.maven.artifact.resolver.ArtifactResolutionResult; //导入依赖的package包/类
protected List getTransitiveDependencies( final Set previousArtifacts )
    throws ProjectBuildingException, InvalidDependencyVersionException, ArtifactResolutionException,
    ArtifactNotFoundException
{
    final List dependencies = new ArrayList();
    for ( Iterator iter = previousArtifacts.iterator(); iter.hasNext(); )
    {
        final Artifact a = (Artifact) iter.next();
        final Artifact pomArtifact =
            factory.createArtifact( a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getScope(), "pom" );
        final MavenProject pomProject =
            mavenProjectBuilder.buildFromRepository( pomArtifact, project.getRemoteArtifactRepositories(),
                                                     localRepository );
        final Set pomProjectArtifacts = pomProject.createArtifacts( factory, null, null );
        final ArtifactResolutionResult result =
            resolver.resolveTransitively( pomProjectArtifacts, pomArtifact, localRepository,
                                          project.getRemoteArtifactRepositories(), metadataSource, null );
        dependencies.addAll( result.getArtifacts() );
    }
    return dependencies;
}
 
开发者ID:mojohaus,项目名称:clirr-maven-plugin,代码行数:22,代码来源:AbstractClirrMojo.java

示例7: resolveTransitively

import org.apache.maven.artifact.resolver.ArtifactResolutionResult; //导入依赖的package包/类
public ArtifactResolutionResult resolveTransitively(
    Set<Artifact> artifacts,
    Artifact originatingArtifact,
    ArtifactRepository localRepository,
    List<ArtifactRepository> remoteRepositories,
    ArtifactMetadataSource source,
    ArtifactFilter filter)
    throws ArtifactResolutionException, ArtifactNotFoundException {
  return resolveTransitively(
      artifacts,
      originatingArtifact,
      Collections.EMPTY_MAP,
      localRepository,
      remoteRepositories,
      source,
      filter);
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:CheArtifactResolver.java

示例8: resolve

import org.apache.maven.artifact.resolver.ArtifactResolutionResult; //导入依赖的package包/类
public Set<Artifact> resolve(String groupId, String artifactId, String version, final String exclusion)
        throws MojoExecutionException {
    ArtifactResolutionRequest request = new ArtifactResolutionRequest()
        .setResolveTransitively(true)
        .setResolveRoot(true)
        .setArtifact(system.createArtifact(groupId, artifactId, version, "jar"))
        .setLocalRepository(this.localRepo)
        .setRemoteRepositories(remoteRepos).setCollectionFilter(new ArtifactFilter() {
            
            @Override
            public boolean include(Artifact artifact) {
                if (exclusion != null && 
                        (artifact.getGroupId() + ":" + artifact.getArtifactId()).equals(exclusion)) {
                    return false;
                }
                return artifact.getScope() == null || artifact.getScope().equals("compile") || artifact.getScope().equals("runtime");
            }
        });

    ArtifactResolutionResult result = system.resolve(request);  
    // TODO error handling
    return result.getArtifacts();
}
 
开发者ID:torquebox,项目名称:jruby9-maven-plugins,代码行数:24,代码来源:ArtifactHelper.java

示例9: resolveProjectDependencies

import org.apache.maven.artifact.resolver.ArtifactResolutionResult; //导入依赖的package包/类
private Set<Artifact> resolveProjectDependencies(List<Dependency> dependencies) throws MojoExecutionException {
    Set<Artifact> resolvedArtifacts = new HashSet<>();
    try {
        getLog().debug("Project dependencies: "+dependencies);
        // make Artifacts of all the dependencies
        Set<Artifact> dependencyArtifacts = MavenMetadataSource.createArtifacts(this.artifactFactory, dependencies, null, null, null);
        getLog().debug("Artifacts build from dependencies: "+dependencyArtifacts);

        for (Artifact dependencyArtifact : dependencyArtifacts) {
            artifactResolver.resolve(dependencyArtifact, this.remoteRepositories, this.localRepository);
            ArtifactResolutionResult result = artifactResolver.resolveTransitively(dependencyArtifacts, dependencyArtifact, this.remoteRepositories, this.localRepository, this.metadataSource);
            resolvedArtifacts.addAll(result.getArtifacts());
        }
        resolvedArtifacts.addAll(dependencyArtifacts);
        return resolvedArtifacts;
    } catch (Exception ex) {
        throw new MojoExecutionException("Encountered problems resolving dependencies of the executable "
                + "in preparation for its execution.", ex);
    }
}
 
开发者ID:lazydoc,项目名称:lazydoc,代码行数:21,代码来源:LazyDocMojo.java

示例10: getPluginTransitiveDependencies

import org.apache.maven.artifact.resolver.ArtifactResolutionResult; //导入依赖的package包/类
/**
 * Read transitive dependencies of given plugin and store them in map.
 *
 * @param plugin
 *            plugin to read
 * @param map
 *            map, where founded transitive dependencies will be stored
 * @param repoSystem
 *            repository system
 * @param localRepository
 *            local repository
 * @param remoteRepos
 *            list of remote repositories
 */
private static void getPluginTransitiveDependencies(final Plugin plugin,
        final Map<Artifact, Collection<Artifact>> map, final RepositorySystem repoSystem,
        final ArtifactRepository localRepository, final List<ArtifactRepository> remoteRepos) {

    List<Dependency> pluginDependencies = plugin.getDependencies();
    for (Dependency dep : pluginDependencies) {
        Artifact artifact = repoSystem.createDependencyArtifact(dep);

        ArtifactResolutionRequest request = new ArtifactResolutionRequest();
        request.setArtifact(artifact);
        request.setResolveTransitively(true);
        request.setLocalRepository(localRepository);
        request.setRemoteRepositories(remoteRepos);

        ArtifactResolutionResult result = repoSystem.resolve(request);
        Set<Artifact> pluginDependencyDependencies = result.getArtifacts();
        map.put(artifact, pluginDependencyDependencies);
    }
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:34,代码来源:Util.java

示例11: getPomArtifacts

import org.apache.maven.artifact.resolver.ArtifactResolutionResult; //导入依赖的package包/类
/**
 * Create Artifact objects for all pom files corresponding to the artifacts that you send in.
 *
 * @param   artifacts
 *          Set of artifacts to obtain pom's for
 *
 * @return  Artifacts for all the pom files
 */
private Set<Artifact> getPomArtifacts(Set<Artifact> artifacts)
throws MojoExecutionException {
    Set<Artifact> poms = new HashSet<>();

    for (Artifact artifact : artifacts) {
        if (shouldSkipArtifact(artifact)) {
            continue;
        }

        ArtifactResolutionRequest rreq = getArtifactResolutionRequestForPom(artifact);
        ArtifactResolutionResult result = repositorySystem.resolve(rreq);

        if (result.isSuccess()) {
            poms.add(rreq.getArtifact());
        } else {
            getLog().warn("No pom for " + artifact.getId());
        }
    }

    return poms;
}
 
开发者ID:s4u,项目名称:pgpverify-maven-plugin,代码行数:30,代码来源:PGPVerifyMojo.java

示例12: resolveAscArtifact

import org.apache.maven.artifact.resolver.ArtifactResolutionResult; //导入依赖的package包/类
/**
 * Retrieves the PGP signature file that corresponds to the given Maven artifact.
 *
 * @param   artifact
 *          The artifact for which a signature file is desired.
 * @return  Either a Maven artifact for the signature file, or {@code null} if the signature
 *          file could not be retrieved.
 *
 * @throws  MojoExecutionException
 *          If the signature could not be retrieved and the Mojo has been configured to fail
 *          on a missing signature.
 */
private Artifact resolveAscArtifact(Artifact artifact) throws MojoExecutionException {
    Artifact ascArtifact = null;

    if (!shouldSkipArtifact(artifact)) {
        final ArtifactResolutionRequest ascReq = getArtifactResolutionRequestForAsc(artifact);
        final ArtifactResolutionResult ascResult = repositorySystem.resolve(ascReq);

        if (ascResult.isSuccess()) {
            ascArtifact = ascReq.getArtifact();

            getLog().debug(ascArtifact.toString() + " " + ascArtifact.getFile());
        } else {
            if (failNoSignature) {
                getLog().error("No signature for " + artifact.getId());
                throw new MojoExecutionException("No signature for " + artifact.getId());
            } else {
                getLog().warn("No signature for " + artifact.getId());
            }
        }
    }

    return ascArtifact;
}
 
开发者ID:s4u,项目名称:pgpverify-maven-plugin,代码行数:36,代码来源:PGPVerifyMojo.java

示例13: collect

import org.apache.maven.artifact.resolver.ArtifactResolutionResult; //导入依赖的package包/类
public ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact,
                                         Map managedVersions, ArtifactRepository localRepository,
                                         List<ArtifactRepository> remoteRepositories,
                                         ArtifactMetadataSource source, ArtifactFilter filter,
                                         List<ResolutionListener> listeners,
                                         List<ConflictResolver> conflictResolvers )
{
    ArtifactResolutionRequest request = new ArtifactResolutionRequest();
    request.setLocalRepository( localRepository );
    request.setRemoteRepositories( remoteRepositories );
    injectSession( request );
    return collect( artifacts, originatingArtifact, managedVersions, request, source, filter, listeners,
                    conflictResolvers );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:15,代码来源:DefaultLegacyArtifactCollector.java

示例14: testResolveWithFilter

import org.apache.maven.artifact.resolver.ArtifactResolutionResult; //导入依赖的package包/类
public void testResolveWithFilter()
    throws ArtifactResolutionException, InvalidVersionSpecificationException
{
    ArtifactSpec a = createArtifactSpec( "a", "1.0" );
    ArtifactSpec b = a.addDependency( "b", "1.0" );
    ArtifactSpec c = a.addDependency( "c", "3.0" );

    b.addDependency( "c", "2.0" );
    ArtifactSpec d = b.addDependency( "d", "4.0" );

    ArtifactResolutionResult res = collect( a );
    assertEquals( "Check artifact list",
                  createSet( new Object[] { a.artifact, b.artifact, c.artifact, d.artifact } ), res.getArtifacts() );

    ArtifactFilter filter = new ExclusionSetFilter( new String[] { "b" } );
    res = collect( a, filter );
    assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, c.artifact } ), res.getArtifacts() );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:19,代码来源:DefaultArtifactCollectorTest.java

示例15: testResolveCorrectDependenciesWhenDifferentDependenciesOnNearest

import org.apache.maven.artifact.resolver.ArtifactResolutionResult; //导入依赖的package包/类
public void testResolveCorrectDependenciesWhenDifferentDependenciesOnNearest()
    throws ArtifactResolutionException, InvalidVersionSpecificationException
{
    ArtifactSpec a = createArtifactSpec( "a", "1.0" );
    ArtifactSpec b = a.addDependency( "b", "1.0" );
    ArtifactSpec c2 = b.addDependency( "c", "2.0" );
    c2.addDependency( "d", "1.0" );

    ArtifactSpec e = createArtifactSpec( "e", "1.0" );
    ArtifactSpec c1 = e.addDependency( "c", "1.0" );
    ArtifactSpec f = c1.addDependency( "f", "1.0" );

    ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, e.artifact } ) );
    assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, e.artifact, c1.artifact,
        f.artifact } ), res.getArtifacts() );
    assertEquals( "Check version", "1.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:18,代码来源:DefaultArtifactCollectorTest.java


注:本文中的org.apache.maven.artifact.resolver.ArtifactResolutionResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。