Java Code Examples for org.eclipse.aether.resolution.ArtifactResolutionException#printStackTrace()

The following examples show how to use org.eclipse.aether.resolution.ArtifactResolutionException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CachingArtifactResolvingHelper.java    From thorntail with Apache License 2.0 6 votes vote down vote up
private File resolveArtifactFile(ArtifactSpec spec) {
    ArtifactRequest request = new ArtifactRequest();
    request.setArtifact(artifact(spec));

    remoteRepositories.forEach(request::addRepository);

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

        return artifactResult.isResolved()
                ? artifactResult.getArtifact().getFile()
                : null;
    } catch (ArtifactResolutionException e) {
        e.printStackTrace();
        return null;
    }
}
 
Example 2
Source File: MavenArtifactResolvingHelper.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Override
public ArtifactSpec resolve(ArtifactSpec spec) {
    if (spec.file == null) {
        final DefaultArtifact artifact = new DefaultArtifact(spec.groupId(), spec.artifactId(), spec.classifier(),
                typeToExtension(spec.type()), spec.version(), new DefaultArtifactType(spec.type()));

        final LocalArtifactResult localResult = this.session.getLocalRepositoryManager()
                .find(this.session, new LocalArtifactRequest(artifact, this.remoteRepositories, null));
        if (localResult.isAvailable()) {
            spec.file = localResult.getFile();
        } else {
            try {
                final ArtifactResult result = resolver.resolveArtifact(this.session,
                        new ArtifactRequest(artifact, this.remoteRepositories, null));
                if (result.isResolved()) {
                    spec.file = result.getArtifact().getFile();
                }
            } catch (ArtifactResolutionException e) {
                e.printStackTrace();
            }
        }
    }

    return spec.file != null ? spec : null;
}
 
Example 3
Source File: MavenArtifactResolvingHelper.java    From wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public ArtifactSpec resolve(ArtifactSpec spec) {
    if (spec.file == null) {
        final DefaultArtifact artifact = new DefaultArtifact(spec.groupId(), spec.artifactId(), spec.classifier(),
                spec.type(), spec.version());

        final LocalArtifactResult localResult = this.session.getLocalRepositoryManager()
                .find(this.session, new LocalArtifactRequest(artifact, this.remoteRepositories, null));
        if (localResult.isAvailable()) {
            spec.file = localResult.getFile();
        } else {
            try {
                final ArtifactResult result = resolver.resolveArtifact(this.session,
                        new ArtifactRequest(artifact,
                                this.remoteRepositories,
                                null));
                if (result.isResolved()) {
                    spec.file = result.getArtifact().getFile();
                }
            } catch (ArtifactResolutionException e) {
                System.err.println("ERR " + e);
                e.printStackTrace();
            }
        }
    }

    return spec.file != null ? spec : null;

}
 
Example 4
Source File: MavenArtifactResolvingHelper.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public ArtifactSpec resolve(ArtifactSpec spec) {
    if (spec.file == null) {
        final DefaultArtifact artifact = new DefaultArtifact(spec.groupId(), spec.artifactId(), spec.classifier(),
                spec.type(), spec.version());

        final LocalArtifactResult localResult = this.session.getLocalRepositoryManager()
                .find(this.session, new LocalArtifactRequest(artifact, this.remoteRepositories, null));
        if (localResult.isAvailable()) {
            spec.file = localResult.getFile();
        } else {
            try {
                final ArtifactResult result = resolver.resolveArtifact(this.session,
                        new ArtifactRequest(artifact,
                                this.remoteRepositories,
                                null));
                if (result.isResolved()) {
                    spec.file = result.getArtifact().getFile();
                }
            } catch (ArtifactResolutionException e) {
                System.err.println("ERR " + e);
                e.printStackTrace();
            }
        }
    }

    return spec.file != null ? spec : null;

}
 
Example 5
Source File: MavenPluginLocation.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
public String getLatestVersionString() {
	Artifact lastArt = new DefaultArtifact(groupId, artifactId, "jar", "LATEST");

	ArtifactRequest request = new ArtifactRequest();
	request.setArtifact(lastArt);
	request.setRepositories(mavenPluginRepository.getRepositoriesAsList());
	
	try {
		ArtifactResult resolveArtifact = mavenPluginRepository.getSystem().resolveArtifact(mavenPluginRepository.getSession(), request);
		return resolveArtifact.getArtifact().getVersion();
	} catch (ArtifactResolutionException e1) {
		e1.printStackTrace();
	}
	return null;
}