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


Java ArtifactResolutionRequest.setArtifact方法代码示例

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


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

示例1: loadSourcesDependency

import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的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: getPluginTransitiveDependencies

import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的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

示例3: getArtifactResolutionRequestForAsc

import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
/**
 * Create ArtifactResolutionRequest for asc file corresponding to artifact.
 *
 * @param artifact artifact
 * @return new ArtifactResolutionRequest
 */
private ArtifactResolutionRequest getArtifactResolutionRequestForAsc(Artifact artifact) {
    Artifact aAsc = repositorySystem.createArtifactWithClassifier(
            artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
            artifact.getType(), artifact.getClassifier());

    ArtifactResolutionRequest rreq = new ArtifactResolutionRequest();

    aAsc.setArtifactHandler(new AscArtifactHandler(aAsc));

    rreq.setArtifact(aAsc);
    rreq.setResolveTransitively(false);
    rreq.setLocalRepository(localRepository);
    rreq.setRemoteRepositories(pomRemoteRepositories);

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

示例4: resolve

import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
public Set<Artifact> resolve(MavenProject project, Artifact artifact) throws MavenExecutionException {
	Set<Artifact> artifacts = new HashSet<>();
	ArtifactResolutionRequest artifactResolutionRequest = new ArtifactResolutionRequest();
	artifactResolutionRequest.setResolveTransitively(true);
	artifactResolutionRequest.setRemoteRepositories(project.getRemoteArtifactRepositories());
	artifactResolutionRequest.setLocalRepository(project.getProjectBuildingRequest().getLocalRepository());
	artifactResolutionRequest.setArtifact(artifact);
	ArtifactResolutionResult artifactResolutionResult = mavenRepoSystem.resolve(artifactResolutionRequest);
	artifactResolutionResult.getArtifacts().stream()
		.peek(d -> { if (Flag.verbose()) logger.info("RESOLVED '{}' FROM '{}'", d,  artifact); })
		.filter(d -> "jar".equals(d.getType()))
		.filter(d -> "compile".equals(d.getScope()) || "provided".equals(d.getScope()) || "runtime".equals(d.getScope()))
		.forEach(d -> artifacts.add(d));
	return artifacts;
}
 
开发者ID:commsen,项目名称:EM,代码行数:16,代码来源:Dependencies.java

示例5: resolve

import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
/**
 * 
 * @param sources
 * @param remoteRepositories - these instances need to be properly mirrored and proxied. Either by creating via EmbedderFactory.createRemoteRepository()
 *              or by using instances from MavenProject
 * @param localRepository
 * @throws ArtifactResolutionException
 * @throws ArtifactNotFoundException 
 */
public void resolve(Artifact sources, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository) throws ArtifactResolutionException, ArtifactNotFoundException {
    setUpLegacySupport();
    ArtifactResolutionRequest req = new ArtifactResolutionRequest();
    req.setLocalRepository(localRepository);
    req.setRemoteRepositories(remoteRepositories);
    req.setArtifact(sources);
    req.setOffline(isOffline());
    ArtifactResolutionResult result = repositorySystem.resolve(req);
    normalizePath(sources);
    // XXX check result for exceptions and throw them now?
    for (Exception ex : result.getExceptions()) {
        LOG.log(Level.FINE, null, ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:MavenEmbedder.java

示例6: resolveDependency

import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
private void resolveDependency(Dependency dep,
                               TreeSet<File> includes,
                               File workingDir,
                               Set<Artifact> resolvedArtifacts) throws MojoFailureException, MojoExecutionException {
    Artifact artifact = repositorySystem.createDependencyArtifact(dep);
    // Avoid resolving stuff we already have resolved.
    if (resolvedArtifacts.contains(artifact)) {
        return;
    }

    ArtifactResolutionRequest request = new ArtifactResolutionRequest();
    request.setLocalRepository(localRepository);
    request.setRemoteRepositories(remoteRepositories);
    request.setManagedVersionMap(project.getManagedVersionMap());
    request.setResolveTransitively(false);
    request.setArtifact(artifact);

    ArtifactResolutionResult result = artifactResolver.resolve(request);

    boolean found = false;
    for (Artifact resolved : result.getArtifacts()) {
        if (artifact.equals(resolved)) {
            resolvedArtifacts.add(resolved);
            addDependencyInclude(workingDir, includes, resolved);
            found = true;
            break;
        }
    }

    if (!found) {
        throw new MojoFailureException("Unable to resolve providence dependency: " +
                                       artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" +
                                       artifact.getVersion() + ":" + artifact.getClassifier());
    }
}
 
开发者ID:morimekta,项目名称:providence,代码行数:36,代码来源:BaseGenerateSourcesMojo.java

示例7: resolve

import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
private Set<Artifact> resolve(final Set<Artifact> dependencies) {
    ArtifactResolutionRequest request = new ArtifactResolutionRequest();
    request.setArtifact(getProject().getArtifact());
    request.setArtifactDependencies(dependencies);
    request.setLocalRepository(localRepository);
    request.setRemoteRepositories(remoteRepositories);
    request.setManagedVersionMap(getProject().getManagedVersionMap());
    request.setResolveTransitively(true);
    ArtifactResolutionResult result = artifactResolver.resolve(request);
    return result.getArtifacts();
}
 
开发者ID:sundrio,项目名称:sundrio,代码行数:12,代码来源:GenerateBomMojo.java

示例8: resolveArtifact

import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
private void resolveArtifact(Artifact baselineArtifact) {
    final ArtifactResolutionRequest request = new ArtifactResolutionRequest();
    request.setArtifact(baselineArtifact);
    request.setLocalRepository(localRepository);
    request.setRemoteRepositories(remoteRepositories);
    request.setOffline(session.isOffline());
    repositorySystem.resolve(request);
}
 
开发者ID:code-distillery,项目名称:baselining-maven-plugin,代码行数:9,代码来源:BaselineMojo.java

示例9: unpackBaseImage

import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
protected void unpackBaseImage(File buildDir, boolean useDefaultPrefix) throws Exception {
    String imageName = project.getProperties().getProperty(DOCKER_BASE_IMAGE_PROPERTY);
    Objects.notNull(imageName, DOCKER_BASE_IMAGE_PROPERTY);

    ImageMavenCoords baseImageCoords = ImageMavenCoords.parse(imageName, useDefaultPrefix);
    String coords = baseImageCoords.getAetherCoords();

    Artifact artifact = repositorySystem.createArtifactWithClassifier(baseImageCoords.getGroupId(),
            baseImageCoords.getArtifactId(), baseImageCoords.getVersion(), baseImageCoords.getType(),
            baseImageCoords.getClassifier());
    getLog().info("Resolving Jube image: " + artifact);

    ArtifactResolutionRequest request = new ArtifactResolutionRequest();
    request.setArtifact(artifact);
    request.setLocalRepository(localRepository);
    request.setRemoteRepositories(pomRemoteRepositories);

    ArtifactResolutionResult result = artifactResolver.resolve(request);
    if (!result.isSuccess()) {
        throw new ArtifactNotFoundException("Cannot download Jube image", artifact);
    }

    getLog().info("Resolved Jube image: " + artifact);

    if (artifact.getFile() != null) {
        File file = artifact.getFile();
        getLog().info("File: " + file);

        if (!file.exists() || file.isDirectory()) {
            throw new MojoExecutionException("Resolved file for " + coords + " is not a valid file: " + file.getAbsolutePath());
        }
        getLog().info("Unpacking base image " + file.getAbsolutePath() + " to build dir: " + buildDir);
        Zips.unzip(new FileInputStream(file), buildDir);
    }
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:36,代码来源:BuildMojo.java

示例10: getArtifactResolutionRequestForPom

import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
/**
 * Create ArtifactResolutionRequest for pom file corresponding to artifact.
 *
 * @param artifact artifact
 * @return new ArtifactResolutionRequest
 */
private ArtifactResolutionRequest getArtifactResolutionRequestForPom(Artifact artifact) {
    Artifact aAsc = repositorySystem.createProjectArtifact(
            artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());

    ArtifactResolutionRequest rreq = new ArtifactResolutionRequest();
    rreq.setArtifact(aAsc);
    rreq.setResolveTransitively(false);
    rreq.setLocalRepository(localRepository);
    rreq.setRemoteRepositories(pomRemoteRepositories);

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

示例11: resolveArtifact

import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
/**
 * Resolve an artifact from repository
 *
 * @param project MavenProject
 * @param artifact Artifact
 * @throws org.apache.maven.plugin.MojoExecutionException
 */
public void resolveArtifact(final MavenProject project, final Artifact artifact) throws MojoExecutionException {
    logger.debug("Resolving artifact " + artifact.toString());

    final ArtifactResolutionRequest artifactRequest = new ArtifactResolutionRequest();
    artifactRequest.setArtifact(artifact);
    artifactRequest.setLocalRepository(localRepository);
    artifactRequest.setRemoteRepositories(project.getRemoteArtifactRepositories());

    final ArtifactResolutionResult resolutionResult = repositorySystem.resolve(artifactRequest);

    if (!resolutionResult.isSuccess()) {
        logger.debug("Failed to resolved " + artifact.toString() +" artifact.");
    }
}
 
开发者ID:Axway,项目名称:grapes-maven-plugin,代码行数:22,代码来源:ArtifactResolver.java

示例12: resolveArtifact

import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
/**
 * Resolves an artifact to a particular repository.
 *
 * @param artifact  Artifact to resolve
 * @return fully resolved artifact.
 */
private Artifact resolveArtifact( Artifact artifact ) throws MojoExecutionException
{
    final ArtifactResolutionRequest artifactResolutionRequest = new ArtifactResolutionRequest();
    artifactResolutionRequest.setArtifact( artifact );
    if ( remoteArtifactRepositories != null && !remoteArtifactRepositories.isEmpty() )
    {
        artifactResolutionRequest.setRemoteRepositories( remoteArtifactRepositories );
    }
    final ArtifactResolutionResult resolutionResult = this.artifactResolver.resolve( artifactResolutionRequest );

    log.debug( "Resolving : " + artifact );
    if ( resolutionResult.getArtifacts().size() == 0 )
    {
        throw new MojoExecutionException( "Could not resolve artifact " + artifact
                + ". Please install it with \"mvn install:install-file ...\" or deploy it to a repository "
                + "with \"mvn deploy:deploy-file ...\"" );
    }
    if ( resolutionResult.getArtifacts().size() > 1 )
    {
        log.debug( "Resolved artifacts : " + resolutionResult.getArtifacts() );
        throw new MojoExecutionException( "Could not resolve artifact " + artifact
                + " to single target. Found the following possible options : " + resolutionResult.getArtifacts() );
    }

    final Artifact resolvedArtifact = resolutionResult.getArtifacts().iterator().next();
    log.debug( "Resolved : " + resolvedArtifact );
    return resolvedArtifact;
}
 
开发者ID:simpligility,项目名称:android-ndk-maven-plugin,代码行数:35,代码来源:ArtifactResolverHelper.java


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