From d17359ab1129f5dcd98ad6217c4e8284d9604b47 Mon Sep 17 00:00:00 2001 From: BoykoAlex Date: Mon, 12 Dec 2016 15:24:06 -0500 Subject: [PATCH] Include repositories specified in the pom for artifact resolution --- .../ide/vscode/commons/maven/MavenCore.java | 20 ++++++++++--------- .../maven/java/MavenProjectClasspath.java | 4 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/MavenCore.java b/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/MavenCore.java index 5c264ce18..2b7e290c1 100644 --- a/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/MavenCore.java +++ b/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/MavenCore.java @@ -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 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 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 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 repositories) throws MavenException { + return maven.resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), CLASSIFIER_TESTSOURCES, repositories, maven.createExecutionRequest()); } public Stream getJreLibs() throws MavenException { diff --git a/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/MavenProjectClasspath.java b/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/MavenProjectClasspath.java index b07d61ca1..54bbffc42 100644 --- a/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/MavenProjectClasspath.java +++ b/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/MavenProjectClasspath.java @@ -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) {