use of org.eclipse.aether.deployment.DeployRequest in project buck by facebook.
the class Publisher method createDeployRequest.
private DeployRequest createDeployRequest(List<Artifact> toPublish) {
DeployRequest deployRequest = new DeployRequest().setRepository(remoteRepo);
for (Artifact artifact : toPublish) {
File file = artifact.getFile();
Preconditions.checkNotNull(file);
Preconditions.checkArgument(file.exists(), "No such file: %s", file.getAbsolutePath());
deployRequest.addArtifact(artifact);
}
return deployRequest;
}
use of org.eclipse.aether.deployment.DeployRequest in project buck by facebook.
the class Publisher method publish.
/**
* @param toPublish each {@link Artifact} must contain a file, that will be published under maven
* coordinates in the corresponding {@link Artifact}.
* @see Artifact#setFile
*/
public DeployResult publish(List<Artifact> toPublish) throws DeploymentException {
RepositorySystem repoSys = Preconditions.checkNotNull(locator.getService(RepositorySystem.class));
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
session.setLocalRepositoryManager(repoSys.newLocalRepositoryManager(session, localRepo));
session.setReadOnly();
DeployRequest deployRequest = createDeployRequest(toPublish);
if (dryRun) {
return new DeployResult(deployRequest).setArtifacts(toPublish).setMetadata(deployRequest.getMetadata());
} else {
return repoSys.deploy(session, deployRequest);
}
}
use of org.eclipse.aether.deployment.DeployRequest in project camel by apache.
the class BOMResolver method retrieveUpstreamBOMVersions.
private void retrieveUpstreamBOMVersions() throws Exception {
RepositorySystem system = newRepositorySystem();
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
LocalRepository localRepo = new LocalRepository(LOCAL_REPO);
session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
String camelVersion = DependencyResolver.resolveCamelParentProperty("${project.version}");
List<Artifact> neededArtifacts = new LinkedList<>();
neededArtifacts.add(new DefaultArtifact("org.apache.camel:camel:pom:" + camelVersion).setFile(camelRoot("pom.xml")));
neededArtifacts.add(new DefaultArtifact("org.apache.camel:camel-parent:pom:" + camelVersion).setFile(camelRoot("parent/pom.xml")));
neededArtifacts.add(new DefaultArtifact("org.apache.camel:spring-boot:pom:" + camelVersion).setFile(camelRoot("platforms/spring-boot/pom.xml")));
neededArtifacts.add(new DefaultArtifact("org.apache.camel:camel-spring-boot-dm:pom:" + camelVersion).setFile(camelRoot("platforms/spring-boot/spring-boot-dm/pom.xml")));
neededArtifacts.add(new DefaultArtifact("org.apache.camel:camel-spring-boot-dependencies:pom:" + camelVersion).setFile(camelRoot("platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml")));
Artifact camelSpringBootParent = new DefaultArtifact("org.apache.camel:camel-starter-parent:pom:" + camelVersion).setFile(camelRoot("platforms/spring-boot/spring-boot-dm/camel-starter-parent/pom.xml"));
neededArtifacts.add(camelSpringBootParent);
RemoteRepository localRepoDist = new RemoteRepository.Builder("org.apache.camel.itest.springboot", "default", new File(LOCAL_REPO).toURI().toString()).build();
for (Artifact artifact : neededArtifacts) {
DeployRequest deployRequest = new DeployRequest();
deployRequest.addArtifact(artifact);
deployRequest.setRepository(localRepoDist);
system.deploy(session, deployRequest);
}
RemoteRepository mavenCentral = new RemoteRepository.Builder("central", "default", "http://repo1.maven.org/maven2/").build();
ArtifactDescriptorRequest dReq = new ArtifactDescriptorRequest(camelSpringBootParent, Arrays.asList(localRepoDist, mavenCentral), null);
ArtifactDescriptorResult dRes = system.readArtifactDescriptor(session, dReq);
this.versions = new TreeMap<>();
for (Dependency dependency : dRes.getManagedDependencies()) {
Artifact a = dependency.getArtifact();
String key = a.getGroupId() + ":" + a.getArtifactId();
versions.put(key, dependency.getArtifact().getVersion());
}
}
use of org.eclipse.aether.deployment.DeployRequest in project bnd by bndtools.
the class AetherRepository method put.
@Override
public PutResult put(InputStream stream, PutOptions options) throws Exception {
init();
DigestInputStream digestStream = new DigestInputStream(stream, MessageDigest.getInstance("SHA-1"));
final File tmpFile = IO.createTempFile(cacheDir, "put", ".bnd");
try {
IO.copy(digestStream, tmpFile);
byte[] digest = digestStream.getMessageDigest().digest();
if (options.digest != null && !Arrays.equals(options.digest, digest))
throw new IOException("Retrieved artifact digest doesn't match specified digest");
// Get basic info about the bundle we're deploying
Jar jar = new Jar(tmpFile);
Artifact artifact = ConversionUtils.fromBundleJar(jar);
artifact = artifact.setFile(tmpFile);
// Setup the Aether repo session and create the deployment request
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
session.setLocalRepositoryManager(repoSystem.newLocalRepositoryManager(session, localRepo));
final DeployRequest request = new DeployRequest();
request.addArtifact(artifact);
request.setRepository(remoteRepo);
// Capture the result including remote resource URI
final ResultHolder resultHolder = new ResultHolder();
session.setTransferListener(new AbstractTransferListener() {
@Override
public void transferSucceeded(TransferEvent event) {
TransferResource resource = event.getResource();
if (event.getRequestType() == RequestType.PUT && tmpFile.equals(resource.getFile())) {
PutResult result = new PutResult();
result.artifact = URI.create(resource.getRepositoryUrl() + resource.getResourceName());
resultHolder.result = result;
System.out.println("UPLOADED to: " + URI.create(resource.getRepositoryUrl() + resource.getResourceName()));
}
}
@Override
public void transferFailed(TransferEvent event) {
if (event.getRequestType() == RequestType.PUT && tmpFile.equals(event.getResource().getFile()))
resultHolder.error = event.getException();
}
@Override
public void transferCorrupted(TransferEvent event) throws TransferCancelledException {
if (event.getRequestType() == RequestType.PUT && tmpFile.equals(event.getResource().getFile()))
resultHolder.error = event.getException();
}
});
// Do the deploy and report results
repoSystem.deploy(session, request);
if (resultHolder.result != null) {
if (indexedRepo != null)
indexedRepo.reset();
return resultHolder.result;
} else if (resultHolder.error != null) {
throw new Exception("Error during artifact upload", resultHolder.error);
} else {
throw new Exception("Artifact was not uploaded");
}
} finally {
if (tmpFile != null && tmpFile.isFile())
IO.delete(tmpFile);
}
}
use of org.eclipse.aether.deployment.DeployRequest in project drools by kiegroup.
the class MavenRepository method deployArtifact.
/**
* Deploys a jar on a remote repository.
*
* @param repository The remote repository where the kjar will be deployed
* @param releaseId The releaseId with which the deployment will be made
* @param jar The jar to be deployed
* @param pomfile The pom file to be deployed together with the kjar
*/
public void deployArtifact(RemoteRepository repository, ReleaseId releaseId, File jar, File pomfile) {
Artifact jarArtifact = new DefaultArtifact(releaseId.getGroupId(), releaseId.getArtifactId(), "jar", releaseId.getVersion());
jarArtifact = jarArtifact.setFile(jar);
Artifact pomArtifact = new SubArtifact(jarArtifact, "", "pom");
pomArtifact = pomArtifact.setFile(pomfile);
DeployRequest deployRequest = new DeployRequest();
deployRequest.addArtifact(jarArtifact).addArtifact(pomArtifact).setRepository(repository);
try {
aether.getSystem().deploy(aether.getSession(), deployRequest);
} catch (DeploymentException e) {
throw new RuntimeException(e);
}
}
Aggregations