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


Java ArtifactRequest.setArtifact方法代码示例

本文整理汇总了Java中org.eclipse.aether.resolution.ArtifactRequest.setArtifact方法的典型用法代码示例。如果您正苦于以下问题:Java ArtifactRequest.setArtifact方法的具体用法?Java ArtifactRequest.setArtifact怎么用?Java ArtifactRequest.setArtifact使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.aether.resolution.ArtifactRequest的用法示例。


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

示例1: 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

示例2: 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

示例3: 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

示例4: get

import org.eclipse.aether.resolution.ArtifactRequest; //导入方法依赖的package包/类
public Path get(@NotNull String groupName, @NotNull String artifactName, @NotNull String version, @NotNull String artifactFileExtension) {
    Artifact artifact = new DefaultArtifact(groupName, artifactName, artifactFileExtension, version);

    RepositorySystem system = newRepositorySystem();
    RepositorySystemSession session = newRepositorySystemSession(system);

    ArtifactRequest request = new ArtifactRequest();
    request.setArtifact(artifact);
    request.setRepositories(repositories(system, session));

    try {
        ArtifactResult artifactResult = system.resolveArtifact(session, request);

        artifact = artifactResult.getArtifact();

        Log.info(artifact + " resolved to  " + artifact.getFile());

        return artifact.getFile().toPath();

    } catch (ArtifactResolutionException e) {
        throw new RuntimeException(format("Couldn't resolve a '%s' artifact for '%s:%s:%s'",
                artifactFileExtension, groupName, artifactName, version
        ), e);
    }
}
 
开发者ID:jan-molak,项目名称:jenkins-build-monitor-plugin,代码行数:26,代码来源:ArtifactTransporter.java

示例5: resolve

import org.eclipse.aether.resolution.ArtifactRequest; //导入方法依赖的package包/类
@Override
public File resolve(Object artifact, Log log) {
    ArtifactRequest request = new ArtifactRequest();
    request.setArtifact((Artifact) artifact);
    request.setRepositories(projectRepositories);

    log.debug("Resolving artifact " + artifact + " from " + projectRepositories);

    ArtifactResult result;
    try {
        result = repositorySystem.resolveArtifact(repositorySystemSession, request);
    } catch (ArtifactResolutionException e) {
        log.warn("Cound not resolve " + artifact, e);
        return null;
    }

    log.debug("Resolved artifact " + artifact + " to " + result.getArtifact().getFile() + " from " + result.getRepository());

    return result.getArtifact().getFile();
}
 
开发者ID:retog,项目名称:karaf-maven-plugin,代码行数:21,代码来源:Dependency31Helper.java

示例6: resolveById

import org.eclipse.aether.resolution.ArtifactRequest; //导入方法依赖的package包/类
@Override
public File resolveById(String id, Log log) throws MojoFailureException {
    id = MavenUtil.mvnToAether(id);
    ArtifactRequest request = new ArtifactRequest();
    request.setArtifact(new DefaultArtifact(id));
    request.setRepositories(projectRepositories);

    log.debug("Resolving artifact " + id + " from " + projectRepositories);

    ArtifactResult result;
    try {
        result = repositorySystem.resolveArtifact(repositorySystemSession, request);
    } catch (ArtifactResolutionException e) {
        log.warn("Could not resolve " + id, e);
        throw new MojoFailureException(format("Couldn't resolve artifact %s", id), e);
    }

    log.debug("Resolved artifact " + id + " to " + result.getArtifact().getFile() + " from " + result.getRepository());

    return result.getArtifact().getFile();
}
 
开发者ID:retog,项目名称:karaf-maven-plugin,代码行数:22,代码来源:Dependency31Helper.java

示例7: resolve

import org.eclipse.aether.resolution.ArtifactRequest; //导入方法依赖的package包/类
/**
 * Resolves the specified artifact (using its GAV, classifier and packaging).
 *
 * @param mojo       the mojo
 * @param groupId    the groupId of the artifact to resolve
 * @param artifactId the artifactId of the artifact to resolve
 * @param version    the version
 * @param type       the type
 * @param classifier the classifier
 * @return the artifact's file if it can be revolved. The file is located in the local maven repository.
 * @throws MojoExecutionException if the artifact cannot be resolved
 */
public static File resolve(AbstractWisdomMojo mojo, String groupId, String artifactId, String version,
                           String type, String classifier) throws MojoExecutionException {
    ArtifactRequest request = new ArtifactRequest();
    request.setArtifact(
            new DefaultArtifact(groupId, artifactId, classifier, type, version));
    request.setRepositories(mojo.remoteRepos);

    mojo.getLog().info("Resolving artifact " + artifactId +
            " from " + mojo.remoteRepos);

    ArtifactResult result;
    try {
        result = mojo.repoSystem.resolveArtifact(mojo.repoSession, request);
    } catch (ArtifactResolutionException e) {
        mojo.getLog().error("Cannot resolve " + groupId + ":" + artifactId + ":" + version + ":" + type);
        throw new MojoExecutionException(e.getMessage(), e);
    }

    mojo.getLog().info("Resolved artifact " + artifactId + " to " +
            result.getArtifact().getFile() + " from "
            + result.getRepository());

    return result.getArtifact().getFile();
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:37,代码来源:DependencyFinder.java

示例8: resolve

import org.eclipse.aether.resolution.ArtifactRequest; //导入方法依赖的package包/类
@Override
public File resolve(final MavenProject project, final String artifact) {
    final ArtifactResult result;
    try {
        final ProjectBuildingRequest projectBuildingRequest = project.getProjectBuildingRequest();

        final ArtifactRequest request = new ArtifactRequest();
        final ArtifactNameSplitter splitter = ArtifactNameSplitter.of(artifact).split();
        final Artifact defaultArtifact = new DefaultArtifact(splitter.getGroupId(), splitter.getArtifactId(), splitter.getClassifier(), splitter.getPackaging(), splitter.getVersion());
        request.setArtifact(defaultArtifact);
        final List<RemoteRepository> repos = project.getRemoteProjectRepositories();
        request.setRepositories(repos);
        result = repoSystem.resolveArtifact(projectBuildingRequest.getRepositorySession(), request);
    } catch (ArtifactResolutionException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
    return result.getArtifact().getFile();
}
 
开发者ID:wildfly,项目名称:wildfly-maven-plugin,代码行数:19,代码来源:EclipseAetherArtifactResolver.java

示例9: retrieveArtifact

import org.eclipse.aether.resolution.ArtifactRequest; //导入方法依赖的package包/类
/**
 * Uses Aether to retrieve an artifact from the repository.
 *
 * @param coordinates as in groupId:artifactId:version
 * @return the located artifact
 */
Artifact retrieveArtifact(final String coordinates)
{

  final ArtifactRequest request = new ArtifactRequest();
  request.setArtifact(new DefaultArtifact(coordinates));
  request.setRepositories(remoteRepos);

  ArtifactResult result = null;
  try {
    result = repoSystem.resolveArtifact(repoSession, request);
  } catch (final ArtifactResolutionException e) {
    getLog().error("Could not resolve parent artifact (" + coordinates + "): " + e.getMessage());
  }

  if (result != null) {
    return RepositoryUtils.toArtifact(result.getArtifact());
  }
  return null;
}
 
开发者ID:mrice,项目名称:license-check,代码行数:26,代码来源:OpenSourceLicenseCheckMojo.java

示例10: validateVersionOverlap

import org.eclipse.aether.resolution.ArtifactRequest; //导入方法依赖的package包/类
private void validateVersionOverlap(ValidatorContext ctx, Model model) {
    File tmpLocalRepository = createTempLocalRepository();
    RepositorySystemSession tmpSession = createTempSession(tmpLocalRepository);
    
    boolean first = true;
    for (RemoteRepository remoteRepository : ctx.getRemoteRepositories()) {
        if (first) {
            first = false;
            continue; // first remote repository is the validated repository, so we want to skip it
        }

        cleanTempLocalRepository(tmpLocalRepository);            
        
        ArtifactRequest request = new ArtifactRequest();
        request.setArtifact(new DefaultArtifact(model.getGroupId(), model.getArtifactId(), "pom", model.getVersion()));
        request.addRepository(remoteRepository);
        try {
            repositorySystem.resolveArtifact(tmpSession, request);
            ctx.addError(this, model.getPomFile(), new VersionOverlapException(model.getId(), remoteRepository));
        } catch (ArtifactResolutionException e) {
            // noop
        }
    }
    
    deleteTempLocalRepository(tmpLocalRepository);
}
 
开发者ID:release-engineering,项目名称:redhat-repository-validator,代码行数:27,代码来源:VersionOverlapValidator.java

示例11: downloadAndInstallArtifact

import org.eclipse.aether.resolution.ArtifactRequest; //导入方法依赖的package包/类
protected ArtifactResult downloadAndInstallArtifact(String artifact) throws MojoExecutionException {
    ArtifactResult result;

    ArtifactRequest request = new ArtifactRequest();
    request.setArtifact( new DefaultArtifact( artifact ) );
    request.setRepositories( remoteRepos );

    getLog().info( "Resolving artifact " + artifact + " from " + remoteRepos );
    try {
        result = repoSystem.resolveArtifact( repoSession, request );
        return result;
    } catch ( ArtifactResolutionException e ) {
        throw new MojoExecutionException( e.getMessage(), e );
    }
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:16,代码来源:RepackageExtensionMojo.java

示例12: resolveArtifact

import org.eclipse.aether.resolution.ArtifactRequest; //导入方法依赖的package包/类
private Artifact resolveArtifact(Artifact artifact) throws Exception {
    ArtifactRequest request = new ArtifactRequest();
    request.setArtifact(artifact);
    request.setRepositories(repositories());
    ArtifactResult result = system.resolveArtifact(session, request);
    return result.getArtifact();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:AetherResolver.java

示例13: makeRequest

import org.eclipse.aether.resolution.ArtifactRequest; //导入方法依赖的package包/类
private static ArtifactRequest makeRequest ( final List<RemoteRepository> repositories, final Artifact artifact )
{
    final ArtifactRequest artifactRequest = new ArtifactRequest ();
    artifactRequest.setArtifact ( artifact );
    artifactRequest.setRepositories ( repositories );
    return artifactRequest;
}
 
开发者ID:eclipse,项目名称:packagedrone,代码行数:8,代码来源:AetherImporter.java

示例14: resolveArtifact

import org.eclipse.aether.resolution.ArtifactRequest; //导入方法依赖的package包/类
protected File resolveArtifact(Artifact artifact) throws MojoExecutionException, DependencyCollectionException {
   ArtifactRequest request = new ArtifactRequest();
   request.setArtifact(artifact);
   request.setRepositories(remoteRepos);

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

   return result.getArtifact().getFile();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:15,代码来源:ArtemisAbstractPlugin.java

示例15: createArtifactRequest

import org.eclipse.aether.resolution.ArtifactRequest; //导入方法依赖的package包/类
private ArtifactRequest createArtifactRequest(final GAV gav) {
    ArtifactRequest request = new ArtifactRequest();
    request.addRepository(this.getRepository());
    DefaultArtifact artifact = new DefaultArtifact(gav.getGroupId(),
                                                   gav.getArtifactId(),
                                                   "jar",
                                                   gav.getVersion());
    request.setArtifact(artifact);
    return request;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:11,代码来源:FileSystemArtifactRepository.java


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