use of org.sonatype.aether.artifact.Artifact in project zeppelin by apache.
the class SparkDependencyResolver method loadFromMvn.
private List<String> loadFromMvn(String artifact, Collection<String> excludes, boolean addSparkContext) throws Exception {
List<String> loadedLibs = new LinkedList<>();
Collection<String> allExclusions = new LinkedList<>();
allExclusions.addAll(excludes);
allExclusions.addAll(Arrays.asList(exclusions));
List<ArtifactResult> listOfArtifact;
listOfArtifact = getArtifactsWithDep(artifact, allExclusions);
Iterator<ArtifactResult> it = listOfArtifact.iterator();
while (it.hasNext()) {
Artifact a = it.next().getArtifact();
String gav = a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getVersion();
for (String exclude : allExclusions) {
if (gav.startsWith(exclude)) {
it.remove();
break;
}
}
}
List<URL> newClassPathList = new LinkedList<>();
List<File> files = new LinkedList<>();
for (ArtifactResult artifactResult : listOfArtifact) {
logger.info("Load " + artifactResult.getArtifact().getGroupId() + ":" + artifactResult.getArtifact().getArtifactId() + ":" + artifactResult.getArtifact().getVersion());
newClassPathList.add(artifactResult.getArtifact().getFile().toURI().toURL());
files.add(artifactResult.getArtifact().getFile());
loadedLibs.add(artifactResult.getArtifact().getGroupId() + ":" + artifactResult.getArtifact().getArtifactId() + ":" + artifactResult.getArtifact().getVersion());
}
global.new Run();
if (sc.version().startsWith("1.1")) {
updateRuntimeClassPath_1_x(newClassPathList.toArray(new URL[0]));
} else {
updateRuntimeClassPath_2_x(newClassPathList.toArray(new URL[0]));
}
updateCompilerClassPath(newClassPathList.toArray(new URL[0]));
if (addSparkContext) {
for (File f : files) {
sc.addJar(f.getAbsolutePath());
}
}
return loadedLibs;
}
use of org.sonatype.aether.artifact.Artifact in project gradle by gradle.
the class MavenDeployAction method publishArtifacts.
@Override
protected void publishArtifacts(Collection<Artifact> artifacts, RepositorySystem repositorySystem, RepositorySystemSession session) throws DeploymentException {
RemoteRepository gradleRepo = remoteRepository;
if (artifacts.iterator().next().isSnapshot() && remoteSnapshotRepository != null) {
gradleRepo = remoteSnapshotRepository;
}
if (gradleRepo == null) {
throw new GradleException("Must specify a repository for deployment");
}
org.sonatype.aether.repository.RemoteRepository aetherRepo = createRepository(gradleRepo);
DeployRequest request = new DeployRequest();
request.setRepository(aetherRepo);
for (Artifact artifact : artifacts) {
request.addArtifact(artifact);
}
LOGGER.info("Deploying to {}", gradleRepo.getUrl());
repositorySystem.deploy(session, request);
}
use of org.sonatype.aether.artifact.Artifact in project karaf by apache.
the class Dependency30Helper method artifactToMvn.
@Override
public String artifactToMvn(Object _artifact, String versionOrRange) {
Artifact artifact = (Artifact) _artifact;
String bundleName;
if (artifact.getExtension().equals("jar") && MavenUtil.isEmpty(artifact.getClassifier())) {
bundleName = String.format("mvn:%s/%s/%s", artifact.getGroupId(), artifact.getArtifactId(), versionOrRange);
} else {
if (MavenUtil.isEmpty(artifact.getClassifier())) {
bundleName = String.format("mvn:%s/%s/%s/%s", artifact.getGroupId(), artifact.getArtifactId(), versionOrRange, artifact.getExtension());
} else {
bundleName = String.format("mvn:%s/%s/%s/%s/%s", artifact.getGroupId(), artifact.getArtifactId(), versionOrRange, artifact.getExtension(), artifact.getClassifier());
}
}
return bundleName;
}
use of org.sonatype.aether.artifact.Artifact in project gradle by gradle.
the class AbstractMavenPublishAction method publish.
public void publish() {
List<Artifact> artifacts = new ArrayList<Artifact>();
if (mainArtifact.getFile() != null) {
artifacts.add(mainArtifact);
}
artifacts.add(pomArtifact);
if (metadataArtifact != null) {
artifacts.add(metadataArtifact);
}
for (Artifact artifact : attached) {
File file = artifact.getFile();
if (file != null && file.isFile()) {
artifacts.add(artifact);
}
}
try {
publishArtifacts(artifacts, newRepositorySystem(), session);
} catch (RepositoryException e) {
throw new GradleException(e.getMessage(), e);
}
}
use of org.sonatype.aether.artifact.Artifact in project motech by motech.
the class ModuleAdminServiceImpl method getPropertyFromPom.
private String getPropertyFromPom(String propertyName, MavenRepositorySystemSession mvnRepository, RepositorySystem system, RemoteRepository remoteRepository, PomInformation pomInformation) throws ArtifactResolutionException {
Properties properties = pomInformation.getProperties();
String property = properties.getProperty(propertyName);
if (property == null) {
if (pomInformation.getParentPomInformation() == null) {
if (pomInformation.getParent() != null) {
Artifact artifact = new DefaultArtifact(pomInformation.getParent().getGroupId(), pomInformation.getParent().getArtifactId(), "pom", pomInformation.getParent().getVersion());
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(artifact);
if (pomInformation.getRepositories() != null) {
for (RemoteRepository repository : pomInformation.getRepositories()) {
artifactRequest.addRepository(repository);
}
}
artifactRequest.addRepository(remoteRepository);
ArtifactResult artifactResult = system.resolveArtifact(mvnRepository, artifactRequest);
File parentPOM = artifactResult.getArtifact().getFile();
pomInformation.parseParentPom(parentPOM);
return getPropertyFromPom(propertyName, mvnRepository, system, remoteRepository, pomInformation.getParentPomInformation());
} else {
return null;
}
} else {
return getPropertyFromPom(propertyName, mvnRepository, system, remoteRepository, pomInformation.getParentPomInformation());
}
} else {
return property;
}
}
Aggregations