use of org.apache.maven.artifact.repository.ArtifactRepository in project intellij-community by JetBrains.
the class Maven30ServerEmbedderImpl method convertRepositories.
@NotNull
protected List<ArtifactRepository> convertRepositories(List<MavenRemoteRepository> repositories) throws RemoteException {
List<ArtifactRepository> result = new ArrayList<ArtifactRepository>();
for (MavenRemoteRepository each : repositories) {
try {
ArtifactRepositoryFactory factory = getComponent(ArtifactRepositoryFactory.class);
result.add(ProjectUtils.buildArtifactRepository(MavenModelConverter.toNativeRepository(each), factory, myContainer));
} catch (InvalidRepositoryException e) {
Maven3ServerGlobals.getLogger().warn(e);
}
}
return result;
}
use of org.apache.maven.artifact.repository.ArtifactRepository in project intellij-community by JetBrains.
the class Maven3ServerIndexFetcher method connect.
@Override
public void connect(String _ignoredContextId, String _ignoredUrl) throws IOException {
ArtifactRepository artifactRepository = myRepositorySystem.createArtifactRepository(myOriginalRepositoryId, myOriginalRepositoryUrl, null, null, null);
final ArtifactRepository mirrorRepository = myWagonManager.getMirrorRepository(artifactRepository);
String mirrorUrl = mirrorRepository.getUrl();
String indexUrl = mirrorUrl + (mirrorUrl.endsWith("/") ? "" : "/") + ".index";
Repository repository = new Repository(myOriginalRepositoryId, indexUrl);
try {
myWagon = myWagonManager.getWagon(repository);
myWagon.addTransferListener(myListener);
myWagon.connect(repository, myWagonManager.getAuthenticationInfo(mirrorRepository.getId()), myWagonManager.getProxy(mirrorRepository.getProtocol()));
} catch (AuthenticationException e) {
IOException newEx = new IOException("Authentication exception connecting to " + repository);
newEx.initCause(e);
throw newEx;
} catch (WagonException e) {
IOException newEx = new IOException("Wagon exception connecting to " + repository);
newEx.initCause(e);
throw newEx;
}
}
use of org.apache.maven.artifact.repository.ArtifactRepository in project intellij-community by JetBrains.
the class Maven2ServerIndexFetcher method connect.
public void connect(String _ignoredContextId, String _ignoredUrl) throws IOException {
final ArtifactRepository mirrorRepository = myWagonManager.getMirrorRepository(new DefaultArtifactRepository(myOriginalRepositoryId, myOriginalRepositoryUrl, null));
String mirrorUrl = mirrorRepository.getUrl();
String indexUrl = mirrorUrl + (mirrorUrl.endsWith("/") ? "" : "/") + ".index";
Repository repository = new Repository(myOriginalRepositoryId, indexUrl);
try {
myWagon = myWagonManager.getWagon(repository);
myWagon.addTransferListener(myListener);
myWagon.connect(repository, myWagonManager.getAuthenticationInfo(mirrorRepository.getId()), myWagonManager.getProxy(mirrorRepository.getProtocol()));
} catch (AuthenticationException e) {
IOException newEx = new IOException("Authentication exception connecting to " + repository);
newEx.initCause(e);
throw newEx;
} catch (WagonException e) {
IOException newEx = new IOException("Wagon exception connecting to " + repository);
newEx.initCause(e);
throw newEx;
}
}
use of org.apache.maven.artifact.repository.ArtifactRepository in project intellij-community by JetBrains.
the class Maven3ServerEmbedderImpl method createLocalRepository.
private ArtifactRepository createLocalRepository() {
try {
final ArtifactRepository localRepository = getComponent(RepositorySystem.class).createLocalRepository(new File(myMavenSettings.getLocalRepository()));
final String customRepoId = System.getProperty("maven3.localRepository.id", "localIntelliJ");
if (customRepoId != null) {
// see details at https://youtrack.jetbrains.com/issue/IDEA-121292
localRepository.setId(customRepoId);
}
return localRepository;
} catch (InvalidRepositoryException e) {
throw new RuntimeException(e);
// Legacy code.
}
//ArtifactRepositoryLayout layout = getComponent(ArtifactRepositoryLayout.class, "default");
//ArtifactRepositoryFactory factory = getComponent(ArtifactRepositoryFactory.class);
//
//String url = myMavenSettings.getLocalRepository();
//if (!url.startsWith("file:")) url = "file://" + url;
//
//ArtifactRepository localRepository = factory.createArtifactRepository("local", url, layout, null, null);
//
//boolean snapshotPolicySet = myMavenSettings.isOffline();
//if (!snapshotPolicySet && snapshotUpdatePolicy == MavenServerSettings.UpdatePolicy.ALWAYS_UPDATE) {
// factory.setGlobalUpdatePolicy(ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS);
//}
//factory.setGlobalChecksumPolicy(ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN);
//
//return localRepository;
}
use of org.apache.maven.artifact.repository.ArtifactRepository in project maven-plugins by apache.
the class ResourceResolver method resolveAndUnpack.
private List<String> resolveAndUnpack(final List<Artifact> artifacts, final SourceResolverConfig config, final List<String> validClassifiers, final boolean propagateErrors) throws ArtifactResolutionException, ArtifactNotFoundException {
// NOTE: Since these are '-sources' and '-test-sources' artifacts, they won't actually
// resolve transitively...this is just used to aggregate resolution failures into a single
// exception.
final Set<Artifact> artifactSet = new LinkedHashSet<Artifact>(artifacts);
final Artifact pomArtifact = config.project().getArtifact();
final ArtifactRepository localRepo = config.localRepository();
final List<ArtifactRepository> remoteRepos = config.project().getRemoteArtifactRepositories();
final ArtifactFilter filter;
if (config.filter() != null) {
filter = new ArtifactIncludeFilterTransformer().transform(config.filter());
} else {
filter = null;
}
ArtifactFilter resolutionFilter = null;
if (filter != null) {
// Wrap the filter in a ProjectArtifactFilter in order to always include the pomArtifact for resolution.
// NOTE that this is necessary, b/c the -sources artifacts are added dynamically to the pomArtifact
// and the resolver also checks the dependency trail with the given filter, thus the pomArtifact has
// to be explicitly included by the filter, otherwise the -sources artifacts won't be resolved.
resolutionFilter = new ProjectArtifactFilter(pomArtifact, filter);
}
Map<String, Artifact> managed = config.project().getManagedVersionMap();
final ArtifactResolutionResult resolutionResult = resolver.resolveTransitively(artifactSet, pomArtifact, managed, localRepo, remoteRepos, artifactMetadataSource, resolutionFilter);
final List<String> result = new ArrayList<String>(artifacts.size());
for (final Artifact a : (Collection<Artifact>) resolutionResult.getArtifacts()) {
if (!validClassifiers.contains(a.getClassifier()) || (filter != null && !filter.include(a))) {
continue;
}
final File d = new File(config.outputBasedir(), a.getArtifactId() + "-" + a.getVersion() + "-" + a.getClassifier());
if (!d.exists()) {
d.mkdirs();
}
try {
final UnArchiver unArchiver = archiverManager.getUnArchiver(a.getType());
unArchiver.setDestDirectory(d);
unArchiver.setSourceFile(a.getFile());
unArchiver.extract();
result.add(d.getAbsolutePath());
} catch (final NoSuchArchiverException e) {
if (propagateErrors) {
throw new ArtifactResolutionException("Failed to retrieve valid un-archiver component: " + a.getType(), a, e);
}
} catch (final ArchiverException e) {
if (propagateErrors) {
throw new ArtifactResolutionException("Failed to unpack: " + a.getId(), a, e);
}
}
}
return result;
}
Aggregations