use of org.eclipse.aether.artifact.DefaultArtifact in project drools by kiegroup.
the class MavenRepository method resolveVersion.
public Version resolveVersion(String artifactName) {
Artifact artifact = new DefaultArtifact(artifactName);
VersionRangeRequest versionRequest = new VersionRangeRequest();
versionRequest.setArtifact(artifact);
for (RemoteRepository repo : remoteRepositoriesForRequest) {
versionRequest.addRepository(repo);
}
try {
VersionRangeResult versionRangeResult = aether.getSystem().resolveVersionRange(aether.getSession(), versionRequest);
return versionRangeResult.getHighestVersion();
} catch (VersionRangeResolutionException e) {
if (log.isDebugEnabled()) {
log.debug("Unable to resolve version range for artifact: " + artifactName, e);
} else {
log.warn("Unable to resolve version range for artifact: " + artifactName);
}
return null;
}
}
use of org.eclipse.aether.artifact.DefaultArtifact 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);
}
}
use of org.eclipse.aether.artifact.DefaultArtifact in project drools by kiegroup.
the class MavenRepository method getArtifactDependecies.
public List<DependencyDescriptor> getArtifactDependecies(String artifactName) {
Artifact artifact = new DefaultArtifact(artifactName);
CollectRequest collectRequest = new CollectRequest();
Dependency root = new Dependency(artifact, "");
collectRequest.setRoot(root);
for (RemoteRepository repo : remoteRepositoriesForRequest) {
collectRequest.addRepository(repo);
}
CollectResult collectResult;
try {
collectResult = aether.getSystem().collectDependencies(aether.getSession(), collectRequest);
} catch (DependencyCollectionException e) {
throw new RuntimeException(e);
}
CollectDependencyVisitor visitor = new CollectDependencyVisitor();
collectResult.getRoot().accept(visitor);
List<DependencyDescriptor> descriptors = new ArrayList<DependencyDescriptor>();
for (DependencyNode node : visitor.getDependencies()) {
// skip root to not add artifact as dependency
if (node.getDependency().equals(root)) {
continue;
}
descriptors.add(new DependencyDescriptor(node.getDependency().getArtifact()));
}
return descriptors;
}
use of org.eclipse.aether.artifact.DefaultArtifact in project drools by kiegroup.
the class MavenRepository method deployPomArtifact.
public void deployPomArtifact(String groupId, String artifactId, String version, File pomfile) {
Artifact pomArtifact = new DefaultArtifact(groupId, artifactId, "pom", version);
pomArtifact = pomArtifact.setFile(pomfile);
DeployRequest deployRequest = new DeployRequest();
deployRequest.addArtifact(pomArtifact).setRepository(aether.getLocalRepository());
try {
aether.getSystem().deploy(aether.getSession(), deployRequest);
} catch (DeploymentException e) {
throw new RuntimeException(e);
}
}
use of org.eclipse.aether.artifact.DefaultArtifact in project kie-wb-common by kiegroup.
the class MavenDependencyConfigExecutorTest method installArtifactLocally.
private void installArtifactLocally(final String groupId, final String artifactId, final String version) throws Exception {
Artifact pomArtifact = new DefaultArtifact(groupId, artifactId, "pom", version);
final Path pom = getPom(groupId, artifactId, version);
pomArtifact = pomArtifact.setFile(pom.toFile());
final InstallRequest installRequest = new InstallRequest();
installRequest.addArtifact(pomArtifact);
final DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
RepositorySystem system = locator.getService(RepositorySystem.class);
final DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
final LocalRepository localRepo = new LocalRepository(m2Folder);
session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
system.install(session, installRequest);
}
Aggregations