Skip to content

Commit

Permalink
[MJAVADOC-742] Fix resolution of docletArtifacts (#186)
Browse files Browse the repository at this point in the history
Co-authored-by: Slawomir Jaranowski <s.jaranowski@gmail.com>
Co-authored-by: Konrad Windszus <kwin@apache.org>
  • Loading branch information
3 people authored Sep 11, 2023
1 parent bee4197 commit 24362d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@
import org.eclipse.aether.artifact.ArtifactTypeRegistry;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.eclipse.aether.collection.CollectRequest;
import org.eclipse.aether.graph.DefaultDependencyNode;
import org.eclipse.aether.graph.DependencyFilter;
import org.eclipse.aether.resolution.ArtifactRequest;
import org.eclipse.aether.resolution.ArtifactResolutionException;
Expand Down Expand Up @@ -3251,8 +3250,11 @@ private List<String> getArtifactsAbsolutePath(JavadocPathArtifact javadocArtifac

DependencyFilter filter = new ScopeDependencyFilter(
Arrays.asList(Artifact.SCOPE_COMPILE, Artifact.SCOPE_PROVIDED), Collections.emptySet());
DependencyRequest req =
new DependencyRequest(new DefaultDependencyNode(RepositoryUtils.toArtifact(artifact)), filter);
DependencyRequest req = new DependencyRequest(
new CollectRequest(
new org.eclipse.aether.graph.Dependency(RepositoryUtils.toArtifact(artifact), null),
RepositoryUtils.toRepos(project.getRemoteArtifactRepositories())),
filter);
Iterable<ArtifactResult> deps =
repoSystem.resolveDependencies(repoSession, req).getArtifactResults();
for (ArtifactResult a : deps) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1080,19 +1080,17 @@ public void testTagletArtifacts() throws Exception {
Path testPom = unit.resolve("tagletArtifacts-test/tagletArtifacts-test-plugin-config.xml");
JavadocReport mojo = lookupMojo(testPom);

MavenSession session = spy(newMavenSession(mojo.project));
ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class);
when(buildingRequest.getRemoteRepositories()).thenReturn(mojo.project.getRemoteArtifactRepositories());
when(session.getProjectBuildingRequest()).thenReturn(buildingRequest);
DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession();
repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory()
.newInstance(repositorySession, new LocalRepository(localRepo)));
when(buildingRequest.getRepositorySession()).thenReturn(repositorySession);
when(session.getRepositorySession()).thenReturn(repositorySession);
MavenSession session = newMavenSession(mojo.project);
DefaultRepositorySystemSession repoSysSession = (DefaultRepositorySystemSession) session.getRepositorySession();
repoSysSession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory()
.newInstance(session.getRepositorySession(), new LocalRepository(new File("target/local-repo"))));
// Ensure remote repo connection uses SSL
File globalSettingsFile = new File(getBasedir(), "target/test-classes/unit/settings.xml");
session.getRequest().setGlobalSettingsFile(globalSettingsFile);
LegacySupport legacySupport = lookup(LegacySupport.class);
legacySupport.setSession(session);
setVariableValueToObject(mojo, "session", session);
setVariableValueToObject(mojo, "repoSession", repositorySession);
setVariableValueToObject(mojo, "repoSession", repoSysSession);
mojo.execute();

Path optionsFile = new File(mojo.getOutputDirectory(), "options").toPath();
Expand Down

0 comments on commit 24362d2

Please sign in to comment.