use of org.eclipse.aether.artifact.Artifact in project BIMserver by opensourceBIM.
the class RemotePluginRepository method main.
public static void main(String[] args) throws ArtifactResolutionException {
System.out.println("------------------------------------------------------------");
System.out.println(RemotePluginRepository.class.getSimpleName());
RepositorySystem system = newRepositorySystem();
RepositorySystemSession session = newRepositorySystemSession(system);
Artifact artifact = new DefaultArtifact("org.eclipse.aether:aether-util:1.0.0.v20140518");
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(artifact);
artifactRequest.setRepositories(newRepositories(system, session));
ArtifactResult artifactResult = system.resolveArtifact(session, artifactRequest);
artifact = artifactResult.getArtifact();
System.out.println(artifact + " resolved to " + artifact.getFile());
}
use of org.eclipse.aether.artifact.Artifact in project karaf by apache.
the class ReactorMavenResolver method resolve.
@Override
public File resolve(String url) throws IOException {
Artifact artifact = toArtifact(url);
File file = reactor.findArtifact(artifact);
return file == null ? fallback.resolve(url) : file;
}
use of org.eclipse.aether.artifact.Artifact in project karaf by apache.
the class ReactorMavenResolver method resolve.
@Override
public File resolve(String url, Exception previousException) throws IOException {
Artifact artifact = toArtifact(url);
File file = reactor.findArtifact(artifact);
return file == null ? fallback.resolve(url, previousException) : file;
}
use of org.eclipse.aether.artifact.Artifact in project activemq-artemis by apache.
the class ArtemisAbstractPlugin method resolveDependencies.
protected Set<File> resolveDependencies(String[] dependencyListParameter, String[] individualListParameter) throws DependencyCollectionException, MojoFailureException, MojoExecutionException {
Set<File> filesSet = new HashSet<>();
if (dependencyListParameter != null) {
for (String lib : dependencyListParameter) {
getLog().debug("********************" + lib);
List<Artifact> artifactsList = explodeDependencies(newArtifact(lib));
for (Artifact artifact : artifactsList) {
File artifactFile = resolveArtifact(artifact);
filesSet.add(artifactFile);
}
}
}
if (individualListParameter != null) {
for (String lib : individualListParameter) {
Artifact artifact = newArtifact(lib);
getLog().debug("Single dpendency resolved::" + artifact);
File artifactFile = resolveArtifact(artifact);
filesSet.add(artifactFile);
}
}
return filesSet;
}
use of org.eclipse.aether.artifact.Artifact in project fabric8 by jboss-fuse.
the class MavenProxyServletSupport method doUpload.
protected UploadContext doUpload(InputStream is, String path) throws InvalidMavenArtifactRequest {
if (path == null) {
throw new InvalidMavenArtifactRequest();
}
int p = path.lastIndexOf('/');
final String filename = path.substring(p + 1);
// TODO -- user uuid?
String uuid = UUID.randomUUID().toString();
File tmp = new File(tmpFolder, uuid);
// noinspection ResultOfMethodCallIgnored
tmp.mkdir();
final File file;
try {
file = readFile(is, tmp, filename);
} catch (FileNotFoundException e) {
throw new IllegalStateException(e);
}
UploadContext result = new UploadContext(file);
// root path, try reading mvn coords
if (p <= 0) {
try {
String mvnCoordsPath = readMvnCoordsPath(file);
if (mvnCoordsPath != null) {
return move(file, mvnCoordsPath);
} else {
// we need manual mvn coords input
result.addHeader(LOCATION_HEADER, file.getPath());
return result;
}
} catch (Exception e) {
LOGGER.warn(String.format("Failed to deploy artifact : %s due to %s", filename, e.getMessage()), e);
return UploadContext.ERROR;
}
}
Matcher artifactMatcher = ARTIFACT_REQUEST_URL_REGEX.matcher(path);
Matcher metadataMatcher = ARTIFACT_METADATA_URL_REGEX.matcher(path);
File target = null;
if (metadataMatcher.matches()) {
LOGGER.info("Received upload request for maven metadata : {}", path);
try {
target = new File(uploadRepository, path);
Files.copy(file, target);
LOGGER.info("Maven metadata installed");
result.setFile(target);
} catch (Exception e) {
result = UploadContext.ERROR;
LOGGER.warn(String.format("Failed to upload metadata: %s due to %s", path, e.getMessage()), e);
}
// If no matching metadata found return nothing
} else if (artifactMatcher.matches()) {
LOGGER.info("Received upload request for maven artifact : {}", path);
Artifact artifact = null;
try {
artifact = convertPathToArtifact(path);
target = new File(uploadRepository, path);
Files.copy(file, target);
result.setFile(target);
result.setGroupId(artifact.getGroupId());
result.setArtifactId(artifact.getArtifactId());
result.setVersion(artifact.getVersion());
result.setType(artifact.getExtension());
LOGGER.info("Artifact installed: {}", artifact.toString());
} catch (Exception e) {
result = UploadContext.ERROR;
LOGGER.warn(String.format("Failed to upload artifact : %s due to %s", artifact, e.getMessage()), e);
}
}
try {
if (file != null) {
// delete tmp directory and file
Files.recursiveDelete(file.getParentFile());
}
} catch (Exception e) {
LOGGER.warn(e.getMessage());
}
return result;
}
Aggregations