本文整理汇总了Java中org.apache.maven.artifact.resolver.ArtifactResolutionResult.isSuccess方法的典型用法代码示例。如果您正苦于以下问题:Java ArtifactResolutionResult.isSuccess方法的具体用法?Java ArtifactResolutionResult.isSuccess怎么用?Java ArtifactResolutionResult.isSuccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.artifact.resolver.ArtifactResolutionResult
的用法示例。
在下文中一共展示了ArtifactResolutionResult.isSuccess方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: resolveArtifact
import org.apache.maven.artifact.resolver.ArtifactResolutionResult; //导入方法依赖的package包/类
/**
* Resolves the given artifact from a repository.
*
* @param artifact artifact to resolve
* @throws IllegalStateException if unable to resolve artifact
*/
private void resolveArtifact(Artifact artifact) {
ArtifactResolutionRequest resolutionRequest =
new ArtifactResolutionRequest()
.setLocalRepository(localRepository)
.setRemoteRepositories(remoteRepositories)
.setArtifact(artifact);
ArtifactResolutionResult resolutionResult = repositorySystem.resolve(resolutionRequest);
if (!resolutionResult.isSuccess()) {
throw new IllegalStateException("Unable to resolve artifact " + artifact.toString());
}
}
示例5: unpackBaseImage
import org.apache.maven.artifact.resolver.ArtifactResolutionResult; //导入方法依赖的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);
}
}
示例6: resolveArtifact
import org.apache.maven.artifact.resolver.ArtifactResolutionResult; //导入方法依赖的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.");
}
}
示例7: getProjectClassLoader
import org.apache.maven.artifact.resolver.ArtifactResolutionResult; //导入方法依赖的package包/类
private ClassLoader getProjectClassLoader() throws MojoExecutionException {
try {
// compiled classes
List<String> classfiles = this.project.getCompileClasspathElements();
if (this.scanTestClasses) {
classfiles.addAll(this.project.getTestClasspathElements());
}
// classpath to url
List<URL> classURLs = new ArrayList<>(classfiles.size());
for (String classfile : classfiles) {
classURLs.add(new File(classfile).toURI().toURL());
}
// dependency artifacts to url
ArtifactResolutionRequest sharedreq = new ArtifactResolutionRequest().setResolveRoot(true)
.setResolveTransitively(true)
.setLocalRepository(this.session.getLocalRepository())
.setRemoteRepositories(this.project.getRemoteArtifactRepositories());
ArtifactRepository repository = this.session.getLocalRepository();
Set<Artifact> artifacts = this.project.getDependencyArtifacts();
for (Artifact artifact : artifacts) {
if (!Artifact.SCOPE_TEST.equalsIgnoreCase(artifact.getScope())) {
ArtifactResolutionRequest request = new ArtifactResolutionRequest(sharedreq).setArtifact(artifact);
ArtifactResolutionResult result = this.repositorySystem.resolve(request);
if (result.isSuccess()) {
File file = repository.find(artifact).getFile();
if (file != null && file.isFile() && file.canRead()) {
classURLs.add(file.toURI().toURL());
}
}
}
}
for (URL url : classURLs) {
this.log.info(" * classpath: " + url);
}
return new URLClassLoader(classURLs.toArray(EMPTY_URLS), this.getClass().getClassLoader());
} catch (Exception e) {
this.log.error(e);
throw new MojoExecutionException("Error while creating classloader", e);
}
}