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


Java ArtifactRequest類代碼示例

本文整理匯總了Java中org.eclipse.aether.resolution.ArtifactRequest的典型用法代碼示例。如果您正苦於以下問題:Java ArtifactRequest類的具體用法?Java ArtifactRequest怎麽用?Java ArtifactRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ArtifactRequest類屬於org.eclipse.aether.resolution包,在下文中一共展示了ArtifactRequest類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: resolveModel

import org.eclipse.aether.resolution.ArtifactRequest; //導入依賴的package包/類
@Override
public ModelSource resolveModel(String groupId, String artifactId, String version)
        throws UnresolvableModelException {
    Artifact pomArtifact = new DefaultArtifact(groupId, artifactId, "", "pom", version);

    try {
        ArtifactRequest request = new ArtifactRequest(pomArtifact, repositories, null);
        pomArtifact = system.resolveArtifact(session, request).getArtifact();
    } catch (org.eclipse.aether.resolution.ArtifactResolutionException ex) {
        throw new UnresolvableModelException(ex.getMessage(), groupId, artifactId, version, ex);
    } 

    File pomFile = pomArtifact.getFile();

    return new FileModelSource(pomFile);
}
 
開發者ID:GateNLP,項目名稱:gate-core,代碼行數:17,代碼來源:SimpleModelResolver.java

示例2: fillfromExtraDependencies

import org.eclipse.aether.resolution.ArtifactRequest; //導入依賴的package包/類
protected void fillfromExtraDependencies(final Manifest manifest, final Map<String, File> files)
        throws IOException, MojoExecutionException {
    if (this.additionalDependencies != null) {
        try {
            final Collection<ArtifactRequest> requests = new ArrayList<>(this.additionalDependencies.length);

            for (final Dependency dep : this.additionalDependencies) {
                final DefaultArtifact art = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId(),
                        dep.getClassifier(), dep.getType(), dep.getVersion());
                final org.eclipse.aether.graph.Dependency adep = new org.eclipse.aether.graph.Dependency(art,
                        JavaScopes.RUNTIME);
                requests.add(new ArtifactRequest(new DefaultDependencyNode(adep)));
            }

            final List<ArtifactResult> result = this.resolver.resolveArtifacts(this.repositorySession, requests);

            for (final ArtifactResult ares : result) {
                getLog().debug("Additional dependency: " + ares);
                processArtifact(manifest, files, ares.getArtifact().getFile());
            }
        } catch (final ArtifactResolutionException e) {
            throw new MojoExecutionException("Failed to resolve additional dependencies", e);
        }
    }
}
 
開發者ID:ctron,項目名稱:osgi-dp,代碼行數:26,代碼來源:AbstractDpMojo.java

示例3: load

import org.eclipse.aether.resolution.ArtifactRequest; //導入依賴的package包/類
@Override
public Optional<ArtifactResult> load(ArtifactCoordinates coordinates) throws Exception {
  Artifact artifact = new DefaultArtifact(coordinates.toString());

  ArtifactRequest artifactRequest = new ArtifactRequest();
  artifactRequest.setArtifact(artifact);
  artifactRequest.setRepositories(this.remoteProjectRepos);

  ArtifactResult artifactResult;
  try {
    artifactResult = this.repoSystem.resolveArtifact(this.repoSession, artifactRequest);
  } catch (ArtifactResolutionException e) {
    // must not throw the error or log as an error since this is an expected behavior
    artifactResult = null;
  }

  return Optional.fromNullable(artifactResult);
}
 
開發者ID:shillner,項目名稱:unleash-maven-plugin,代碼行數:19,代碼來源:ArtifactCacheLoader.java

示例4: resolvePluginDependency

import org.eclipse.aether.resolution.ArtifactRequest; //導入依賴的package包/類
/**
 * Uses the aether to resolve a plugin dependency and returns the file for further processing.
 *
 * @param d the dependency to resolve.
 * @param pluginRepos the plugin repositories to use for dependency resolution.
 * @param resolver the resolver for aether access.
 * @param repoSystemSession the session for the resolver.
 * @return optionally a file which is the resolved dependency.
 */
public static Optional<File> resolvePluginDependency(Dependency d, List<RemoteRepository> pluginRepos,
    ArtifactResolver resolver, RepositorySystemSession repoSystemSession) {
  Artifact a = new DefaultArtifact(d.getGroupId(), d.getArtifactId(), d.getClassifier(), d.getType(), d.getVersion());
  ArtifactRequest artifactRequest = new ArtifactRequest();
  artifactRequest.setArtifact(a);
  artifactRequest.setRepositories(pluginRepos);
  try {
    ArtifactResult artifactResult = resolver.resolveArtifact(repoSystemSession, artifactRequest);
    if (artifactResult.getArtifact() != null) {
      return Optional.fromNullable(artifactResult.getArtifact().getFile());
    }
    return Optional.absent();
  } catch (ArtifactResolutionException e) {
    return Optional.absent();
  }
}
 
開發者ID:shillner,項目名稱:maven-cdi-plugin-utils,代碼行數:26,代碼來源:MavenUtil.java

示例5: download

import org.eclipse.aether.resolution.ArtifactRequest; //導入依賴的package包/類
public List<ArtifactDescriptor> download(List<ArtifactInfo> unresolvedArtifacts) throws IOException {
  List<RemoteRepository> repositories = this.remoteRepositories;
  List<ArtifactRequest> artifactRequests = unresolvedArtifacts.stream()
      .map(dependency -> {
        ArtifactRequest artifactRequest = new ArtifactRequest();
        artifactRequest.setArtifact(dependency.artifact);
        artifactRequest.setRepositories(repositories);
        return artifactRequest;
      })
      .collect(Collectors.toList());

  List<ArtifactResult> artifactResults;
  try {
    artifactResults = system.resolveArtifacts(session, artifactRequests);
  } catch (ArtifactResolutionException e) {
    throw new IOException(e);
  }
  
  return artifactResults.stream()
    .map(result -> new ArtifactDescriptor(result.getArtifact()))
    .collect(Collectors.toList());
}
 
開發者ID:forax,項目名稱:pro,代碼行數:23,代碼來源:Aether.java

示例6: getArtifact

import org.eclipse.aether.resolution.ArtifactRequest; //導入依賴的package包/類
private File getArtifact(final String groupId, final String artifactId, final String classifier, final String extension, final String version) throws MojoExecutionException {
	final DefaultArtifact artifact = new DefaultArtifact(groupId, artifactId, classifier, extension, version);

	final LocalArtifactRequest localRequest = new LocalArtifactRequest(artifact, projectRepoList, null);
	final LocalRepositoryManager localManager = repoSession.getLocalRepositoryManager();
	final LocalArtifactResult localResult = localManager.find(repoSession, localRequest);
	if (localResult.isAvailable()) {
		return localResult.getFile();
	}

	try {
		final ArtifactRequest remoteRequest = new ArtifactRequest(artifact, projectRepoList, null);
		final ArtifactResult remoteResult = repoSystem.resolveArtifact(repoSession, remoteRequest);
		return remoteResult.getArtifact().getFile();
	}
	catch (final ArtifactResolutionException e) {
		throw new MojoExecutionException("Could not retrieve artifact", e);
	}
}
 
開發者ID:wmono,項目名稱:tsc-maven-plugin,代碼行數:20,代碼來源:AbstractTypeScriptMojo.java

示例7: resolve

import org.eclipse.aether.resolution.ArtifactRequest; //導入依賴的package包/類
private URL resolve( Artifact artifact )
    throws MojoExecutionException
{
    ArtifactRequest request = new ArtifactRequest( artifact, remoteRepository, null );

    try
    {
        return
            repositorySystem
                .resolveArtifact( repositorySession, request )
                .getArtifact()
                .getFile()
                .toURI()
                .toURL();
    }
    catch ( ArtifactResolutionException | MalformedURLException e )
    {
        throw new MojoExecutionException( "Cannot resolve artifact: " + artifact, e );
    }
}
 
開發者ID:expretio,項目名稱:capnp-maven-plugin,代碼行數:21,代碼來源:CapnProtoMojo.java

示例8: preparePlain

import org.eclipse.aether.resolution.ArtifactRequest; //導入依賴的package包/類
/**
 * Prepare a plain import process
 * <p>
 * Prepare a simple import request with a specific list of coordinates
 * </p>
 */
public static AetherResult preparePlain ( final Path tmpDir, final ImportConfiguration cfg ) throws ArtifactResolutionException
{
    Objects.requireNonNull ( tmpDir );
    Objects.requireNonNull ( cfg );

    final RepositoryContext ctx = new RepositoryContext ( tmpDir, cfg.getRepositoryUrl (), cfg.isAllOptional () );

    // extend

    final List<ArtifactRequest> requests = extendRequests ( cfg.getCoordinates ().stream ().map ( c -> {
        final DefaultArtifact artifact = new DefaultArtifact ( c.toString () );
        return makeRequest ( ctx.getRepositories (), artifact );
    } ), ctx, cfg );

    // process

    return asResult ( resolve ( ctx, requests ), cfg, empty () );
}
 
開發者ID:eclipse,項目名稱:packagedrone,代碼行數:25,代碼來源:AetherImporter.java

示例9: processImport

import org.eclipse.aether.resolution.ArtifactRequest; //導入依賴的package包/類
/**
 * Process the actual import request
 * <p>
 * This method takes the import configuration as is and simply tries to
 * import it. Not manipulating the list of coordinates any more
 * </p>
 */
public static Collection<ArtifactResult> processImport ( final Path tmpDir, final ImportConfiguration cfg ) throws ArtifactResolutionException
{
    Objects.requireNonNull ( tmpDir );
    Objects.requireNonNull ( cfg );

    final RepositoryContext ctx = new RepositoryContext ( tmpDir, cfg.getRepositoryUrl () );

    final Collection<ArtifactRequest> requests = new LinkedList<> ();

    for ( final MavenCoordinates coords : cfg.getCoordinates () )
    {
        // main artifact

        final DefaultArtifact main = new DefaultArtifact ( coords.toString () );
        requests.add ( makeRequest ( ctx.getRepositories (), main ) );
    }

    // process

    return ctx.getSystem ().resolveArtifacts ( ctx.getSession (), requests );
}
 
開發者ID:eclipse,項目名稱:packagedrone,代碼行數:29,代碼來源:AetherImporter.java

示例10: resolveArtifact

import org.eclipse.aether.resolution.ArtifactRequest; //導入依賴的package包/類
private File resolveArtifact(final String group,
                             final String name,
                             final String version,
                             final String classifier,
                             final String type) throws ArtifactResolutionException {
    final DefaultArtifact artifact = new DefaultArtifact(group, name, classifier, type, version);
    final LocalArtifactResult localResult = this.repositorySystemSession.getLocalRepositoryManager()
            .find(this.repositorySystemSession, new LocalArtifactRequest(artifact, this.remoteRepositories, null));
    File file = null;

    if (localResult.isAvailable()) {
        file = localResult.getFile();
    } else {
        final ArtifactResult result;
        result = resolver.resolveArtifact(this.repositorySystemSession,
                                          new ArtifactRequest(artifact, this.remoteRepositories, null));
        if (result.isResolved()) {
            file = result.getArtifact().getFile();
        }
    }

    return file;
}
 
開發者ID:wildfly-swarm,項目名稱:wildfly-swarm-fraction-plugin,代碼行數:24,代碼來源:FractionReferenceMojo.java

示例11: resolveDependencies

import org.eclipse.aether.resolution.ArtifactRequest; //導入依賴的package包/類
private Map<Artifact, Dependency> resolveDependencies(BomImport bom) throws Exception {
    org.eclipse.aether.artifact.Artifact artifact = new org.eclipse.aether.artifact.DefaultArtifact(bom.getGroupId(), bom.getArtifactId(), "pom", bom.getVersion());

    List<RemoteRepository> repositories = remoteRepositories;
    if (bom.getRepository() != null) {
        // Include the additional repository into the copy
        repositories = new LinkedList<RemoteRepository>(repositories);
        RemoteRepository repo = new RemoteRepository.Builder(bom.getArtifactId() + "-repository", "default", bom.getRepository()).build();
        repositories.add(0, repo);
    }

    ArtifactRequest artifactRequest = new ArtifactRequest(artifact, repositories, null);
    system.resolveArtifact(session, artifactRequest); // To get an error when the artifact does not exist

    ArtifactDescriptorRequest req = new ArtifactDescriptorRequest(artifact, repositories, null);
    ArtifactDescriptorResult res = system.readArtifactDescriptor(session, req);

    Map<Artifact, Dependency> mavenDependencies = new LinkedHashMap<Artifact, Dependency>();
    if (res.getManagedDependencies() != null) {
        for (org.eclipse.aether.graph.Dependency dep : res.getManagedDependencies()) {
            mavenDependencies.put(toMavenArtifact(dep), toMavenDependency(dep));
        }
    }

    return mavenDependencies;
}
 
開發者ID:sundrio,項目名稱:sundrio,代碼行數:27,代碼來源:ExternalBomResolver.java

示例12: containsArtifact

import org.eclipse.aether.resolution.ArtifactRequest; //導入依賴的package包/類
@Override
public boolean containsArtifact(final GAV gav) {
    ArtifactRequest request = createArtifactRequest(gav);
    try {
        Aether aether = Aether.getAether();
        aether.getSystem().resolveArtifact(aether.getSession(),
                                           request);
    } catch (ArtifactResolutionException e) {
        logger.trace("Artifact {} not found.",
                     gav,
                     e);
        return false;
    }
    logger.trace("Artifact {} found.",
                 gav);
    return true;
}
 
開發者ID:kiegroup,項目名稱:appformer,代碼行數:18,代碼來源:FileSystemArtifactRepository.java

示例13: getArtifactFileFromRepository

import org.eclipse.aether.resolution.ArtifactRequest; //導入依賴的package包/類
@Override
public File getArtifactFileFromRepository(final GAV gav) {
    ArtifactRequest request = createArtifactRequest(gav);
    ArtifactResult result = null;
    try {
        result = Aether.getAether().getSystem().resolveArtifact(
                Aether.getAether().getSession(),
                request);
    } catch (ArtifactResolutionException e) {
        logger.warn(e.getMessage(),
                    e);
    }

    if (result == null) {
        return null;
    }

    File artifactFile = null;
    if (result.isResolved() && !result.isMissing()) {
        artifactFile = result.getArtifact().getFile();
    }

    return artifactFile;
}
 
開發者ID:kiegroup,項目名稱:appformer,代碼行數:25,代碼來源:FileSystemArtifactRepository.java

示例14: fetchDependency

import org.eclipse.aether.resolution.ArtifactRequest; //導入依賴的package包/類
private Path fetchDependency(final String artifactIdentifier) throws MojoExecutionException {
    ArtifactRequest request = new ArtifactRequest();
    final DefaultArtifact artifact = new DefaultArtifact(artifactIdentifier);
    request.setArtifact(artifact);
    request.setRepositories(remoteRepos);

    LogProvider.debug("Resolving artifact " + artifact + " from " + remoteRepos);

    ArtifactResult result;
    try {
        result = repoSystem.resolveArtifact(repoSession, request);
    } catch (ArtifactResolutionException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }

    LogProvider.debug("Resolved artifact " + artifact + " to " + result.getArtifact().getFile() + " from " + result.getRepository());
    return result.getArtifact().getFile().toPath();
}
 
開發者ID:sdaschner,項目名稱:jaxrs-analyzer-maven-plugin,代碼行數:19,代碼來源:JAXRSAnalyzerMojo.java

示例15: resolveDevServerJar

import org.eclipse.aether.resolution.ArtifactRequest; //導入依賴的package包/類
public String resolveDevServerJar() {
    String version = getYawpVersion();
    List<RemoteRepository> allRepos = ImmutableList.copyOf(Iterables.concat(getProjectRepos()));

    ArtifactRequest request = new ArtifactRequest(new DefaultArtifact(YAWP_GROUP_ID, YAWP_DEVSERVER_ARTIFACT_ID, "jar", version), allRepos,
            null);

    ArtifactResult result;
    try {
        result = repoSystem.resolveArtifact(repoSession, request);
    } catch (ArtifactResolutionException e) {
        throw new RuntimeException("Could not resolve DevServer artifact in Maven.");
    }

    return result.getArtifact().getFile().getPath();
}
 
開發者ID:feroult,項目名稱:yawp,代碼行數:17,代碼來源:DevServerMojo.java


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