Include repositories specified in the pom for artifact resolution
This commit is contained in:
@@ -26,12 +26,14 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.maven.RepositoryUtils;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
import org.apache.maven.model.DependencyManagement;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
@@ -245,7 +247,7 @@ public class MavenCore {
|
||||
return artifacts.parallelStream().map(artifact -> {
|
||||
if (!artifact.isResolved()) {
|
||||
try {
|
||||
artifact = maven.resolve(artifact, null, request);
|
||||
artifact = maven.resolve(artifact, project.getRemoteArtifactRepositories(), request);
|
||||
} catch (MavenException e) {
|
||||
Log.log(e);
|
||||
// Maven 2.x quirk: an artifact always points at the local repo,
|
||||
@@ -269,20 +271,20 @@ public class MavenCore {
|
||||
return lrm.getRepository().getBasedir();
|
||||
}
|
||||
|
||||
public Artifact getSources(Artifact artifact) throws MavenException {
|
||||
return maven.resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), CLASSIFIER_SOURCES, null, maven.createExecutionRequest());
|
||||
public Artifact getSources(Artifact artifact, List<ArtifactRepository> repositories) throws MavenException {
|
||||
return maven.resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), CLASSIFIER_SOURCES, repositories, maven.createExecutionRequest());
|
||||
}
|
||||
|
||||
public Artifact getJavadoc(Artifact artifact) throws MavenException {
|
||||
return maven.resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), CLASSIFIER_JAVADOC, null, maven.createExecutionRequest());
|
||||
public Artifact getJavadoc(Artifact artifact, List<ArtifactRepository> repositories) throws MavenException {
|
||||
return maven.resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), CLASSIFIER_JAVADOC, repositories, maven.createExecutionRequest());
|
||||
}
|
||||
|
||||
public Artifact getTests(Artifact artifact) throws MavenException {
|
||||
return maven.resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), CLASSIFIER_TESTS, null, maven.createExecutionRequest());
|
||||
public Artifact getTests(Artifact artifact, List<ArtifactRepository> repositories) throws MavenException {
|
||||
return maven.resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), CLASSIFIER_TESTS, repositories, maven.createExecutionRequest());
|
||||
}
|
||||
|
||||
public Artifact getTestSources(Artifact artifact) throws MavenException {
|
||||
return maven.resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), CLASSIFIER_TESTSOURCES, null, maven.createExecutionRequest());
|
||||
public Artifact getTestSources(Artifact artifact, List<ArtifactRepository> repositories) throws MavenException {
|
||||
return maven.resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), CLASSIFIER_TESTSOURCES, repositories, maven.createExecutionRequest());
|
||||
}
|
||||
|
||||
public Stream<Path> getJreLibs() throws MavenException {
|
||||
|
||||
@@ -192,7 +192,7 @@ public class MavenProjectClasspath implements IClasspath {
|
||||
return new ParserJavadocProvider(type -> {
|
||||
try {
|
||||
Artifact artifact = getArtifactFromJarFile(classpathResource).get();
|
||||
URL sourceContainer = maven.getSources(artifact).getFile().toURI().toURL();
|
||||
URL sourceContainer = maven.getSources(artifact, project.getRemoteArtifactRepositories()).getFile().toURI().toURL();
|
||||
return SourceUrlProviderFromSourceContainer.JAR_SOURCE_URL_PROVIDER.sourceUrl(sourceContainer,
|
||||
type);
|
||||
} catch (MavenException e) {
|
||||
@@ -225,7 +225,7 @@ public class MavenProjectClasspath implements IClasspath {
|
||||
return new HtmlJavadocProvider(type -> {
|
||||
try {
|
||||
Artifact artifact = getArtifactFromJarFile(classpathResource).get();
|
||||
URL sourceContainer = maven.getJavadoc(artifact).getFile().toURI().toURL();
|
||||
URL sourceContainer = maven.getJavadoc(artifact, project.getRemoteArtifactRepositories()).getFile().toURI().toURL();
|
||||
return SourceUrlProviderFromSourceContainer.JAR_JAVADOC_URL_PROVIDER.sourceUrl(sourceContainer,
|
||||
type);
|
||||
} catch (MavenException e) {
|
||||
|
||||
Reference in New Issue
Block a user