use of org.eclipse.aether.repository.RemoteRepository in project xwiki-commons by xwiki.
the class AetherExtensionRepository method downloadPom.
private Artifact downloadPom(Artifact artifact, RepositorySystemSession session) throws VersionResolutionException, ArtifactResolutionException {
List<RemoteRepository> repositories = newResolutionRepositories(session);
Artifact pomArtifact = resolveVersion(artifact, repositories, session);
// Download pom file
ArtifactRequest resolveRequest = new ArtifactRequest(pomArtifact, repositories, "");
ArtifactResult resolveResult = this.artifactResolver.resolveArtifact(session, resolveRequest);
pomArtifact = resolveResult.getArtifact();
return pomArtifact;
}
use of org.eclipse.aether.repository.RemoteRepository in project xwiki-commons by xwiki.
the class AetherExtensionRepository method createModel.
private Model createModel(File pomFile, RepositorySystemSession session) throws ModelBuildingException {
// Search for parent pom in all available Aether repositories
List<RemoteRepository> repositories = newResolutionRepositories(session, true);
ModelBuildingRequest modelRequest = new DefaultModelBuildingRequest();
modelRequest.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
modelRequest.setProcessPlugins(false);
modelRequest.setTwoPhaseBuilding(false);
modelRequest.setSystemProperties(toProperties(session.getUserProperties(), session.getSystemProperties()));
modelRequest.setModelResolver(new ProjectModelResolver(session, null, this.repositorySystem, this.remoteRepositoryManager, repositories, RepositoryMerging.POM_DOMINANT, null));
modelRequest.setPomFile(pomFile);
modelRequest.setActiveProfileIds(Arrays.asList("legacy"));
return this.modelBuilder.build(modelRequest).getEffectiveModel();
}
use of org.eclipse.aether.repository.RemoteRepository in project xwiki-commons by xwiki.
the class MavenBuildExtensionRepository method openStream.
/**
* {@inheritDoc}
* <p>
* Override standard {@link #openStream(org.eclipse.aether.artifact.Artifact)} to reuse running Maven session which
* is much faster.
*
* @see org.xwiki.extension.repository.aether.internal.AetherExtensionRepository#openStream(org.eclipse.aether.artifact.Artifact)
*/
@Override
public InputStream openStream(org.eclipse.aether.artifact.Artifact artifact) throws IOException {
XWikiRepositorySystemSession session = createRepositorySystemSession();
List<RemoteRepository> repositories = newResolutionRepositories(session);
// /////////////////////////////////////////////////////////////////////////////:
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setRepositories(repositories);
ArtifactType artifactType = XWikiRepositorySystemSession.TYPE_MAPPING.get(artifact.getExtension());
if (artifactType == null) {
artifactRequest.setArtifact(artifact);
} else {
artifactRequest.setArtifact(new DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), artifactType.getExtension(), artifact.getVersion()));
}
ArtifactResult artifactResult;
try {
RepositorySystem repositorySystem = getRepositorySystem();
artifactResult = repositorySystem.resolveArtifact(session, artifactRequest);
} catch (org.eclipse.aether.resolution.ArtifactResolutionException e) {
throw new IOException("Failed to resolve artifact", e);
}
File aetherFile = artifactResult.getArtifact().getFile();
return new AetherExtensionFileInputStream(aetherFile, false);
}
use of org.eclipse.aether.repository.RemoteRepository in project resteasy by resteasy.
the class MavenUtil method createMavenGavFile.
public File createMavenGavFile(String artifactGav) throws MalformedURLException {
Artifact artifact = new DefaultArtifact(artifactGav);
if (artifact.getVersion() == null) {
throw new IllegalArgumentException("Null version");
}
VersionScheme versionScheme = new GenericVersionScheme();
try {
versionScheme.parseVersion(artifact.getVersion());
} catch (InvalidVersionSpecificationException e) {
throw new IllegalArgumentException(e);
}
try {
versionScheme.parseVersionRange(artifact.getVersion());
throw new IllegalArgumentException(artifact.getVersion() + " is a version range. A specific version is needed");
} catch (InvalidVersionSpecificationException expected) {
}
RepositorySystemSession session = newRepositorySystemSession();
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(artifact);
for (RemoteRepository remoteRepo : remoteRepositories) {
artifactRequest.addRepository(remoteRepo);
}
ArtifactResult artifactResult;
try {
artifactResult = REPOSITORY_SYSTEM.resolveArtifact(session, artifactRequest);
} catch (ArtifactResolutionException e) {
throw new RuntimeException(e);
}
File file = artifactResult.getArtifact().getFile().getAbsoluteFile();
return file;
}
use of org.eclipse.aether.repository.RemoteRepository in project resteasy by resteasy.
the class MavenUtil method createRemoteRepositories.
private static List<RemoteRepository> createRemoteRepositories(boolean useEapRepository) {
// prepare proxy
String httpProxyHost = System.getProperty(String.format("%s%s", PROXY_HTTP_PREFIX, PROXY_HOST));
String httpsProxyHost = System.getProperty(String.format("%s%s", PROXY_HTTPS_PREFIX, PROXY_HOST));
Integer httpProxyPort = getProxyPort(String.format("%s%s", PROXY_HTTP_PREFIX, PROXY_PORT));
Integer httpsProxyPort = getProxyPort(String.format("%s%s", PROXY_HTTPS_PREFIX, PROXY_PORT));
Proxy httpProxy = null;
Proxy httpsProxy = null;
if (httpProxyHost != null && httpProxyPort != null && !httpProxyHost.isEmpty()) {
httpProxy = new Proxy(Proxy.TYPE_HTTP, httpProxyHost, httpProxyPort);
}
if (httpsProxyHost != null && httpsProxyPort != null && !httpsProxyHost.isEmpty()) {
httpsProxy = new Proxy(Proxy.TYPE_HTTPS, httpsProxyHost, httpsProxyPort);
}
List<RemoteRepository> remoteRepositories = new ArrayList<RemoteRepository>();
if (useEapRepository) {
RemoteRepository.Builder repository = new RemoteRepository.Builder("product-repository", "default", "https://maven.repository.redhat.com/nexus/content/groups/product-techpreview/");
if (httpsProxy != null) {
repository.setProxy(httpsProxy);
}
remoteRepositories.add(repository.build());
}
// always add jboss developer repository
RemoteRepository.Builder repository = new RemoteRepository.Builder("jboss-developer", "default", "http://repository.jboss.org/nexus/content/groups/developer/");
if (httpProxy != null) {
repository.setProxy(httpProxy);
}
remoteRepositories.add(repository.build());
// always add default maven repository
RemoteRepository.Builder repository2 = new RemoteRepository.Builder("maven-default", "default", "https://repo.maven.apache.org/maven2/");
if (httpProxy != null) {
repository2.setProxy(httpProxy);
}
remoteRepositories.add(repository2.build());
return remoteRepositories;
}
Aggregations