[ https://issues.apache.org/jira/browse/MPLUGIN-457?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17712680#comment-17712680 ]
ASF GitHub Bot commented on MPLUGIN-457: ---------------------------------------- michael-o commented on code in PR #201: URL: https://github.com/apache/maven-plugin-tools/pull/201#discussion_r1167577893 ########## maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java: ########## @@ -229,22 +229,8 @@ public class DescriptorGeneratorMojo extends AbstractGeneratorMojo { @Parameter(defaultValue = "${settings}", readonly = true, required = true) private Settings settings; - /** - * List of Remote Repositories used by the resolver - * - * @since 3.0 - */ - @Parameter(defaultValue = "${project.remoteArtifactRepositories}", required = true, readonly = true) - private List<ArtifactRepository> remoteRepos; - - /** - * Location of the local repository. - * - * @since 3.0 - */ - @Parameter(defaultValue = "${localRepository}", required = true, readonly = true) - private ArtifactRepository local; - + @Parameter(defaultValue = "${repositorySystemSession}", readonly = true, required = true) + private RepositorySystemSession repositorySystemSession; Review Comment: I meantioned this already in another PR from @cstamas: According to `grep(1)` the most used named for this variable is `repoSession`. We should try to reuse names. ########## maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java: ########## @@ -570,19 +572,18 @@ protected void extendJavaProjectBuilderWithSourcesJar( JavaProjectBuilder builder, Artifact artifact, PluginToolsRequest request, String classifier) throws ExtractionException { try { - Artifact sourcesArtifact = repositorySystem.createArtifactWithClassifier( + org.eclipse.aether.artifact.Artifact sourcesArtifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), - artifact.getVersion(), + classifier, artifact.getType(), - classifier); - - ArtifactResolutionRequest req = new ArtifactResolutionRequest(); - req.setArtifact(sourcesArtifact); - req.setLocalRepository(request.getLocal()); - req.setRemoteRepositories(request.getRemoteRepos()); - ArtifactResolutionResult res = repositorySystem.resolve(req); - if (res.hasMissingArtifacts() || res.hasExceptions()) { + artifact.getVersion()); + + ArtifactRequest resolveRequest = new ArtifactRequest(sourcesArtifact, request.getRemoteRepos(), null); Review Comment: To `ArtifactHandler` required? ########## maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/DefaultPluginToolsRequest.java: ########## @@ -53,9 +54,9 @@ public class DefaultPluginToolsRequest implements PluginToolsRequest { private Set<Artifact> dependencies; - private List<ArtifactRepository> remoteRepos; + private List<RemoteRepository> remoteRepos; - private ArtifactRepository local; + private RepositorySystemSession repoSession; Review Comment: Here you do use `repoSession` :-D ########## maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java: ########## @@ -570,19 +572,18 @@ protected void extendJavaProjectBuilderWithSourcesJar( JavaProjectBuilder builder, Artifact artifact, PluginToolsRequest request, String classifier) throws ExtractionException { try { - Artifact sourcesArtifact = repositorySystem.createArtifactWithClassifier( + org.eclipse.aether.artifact.Artifact sourcesArtifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), - artifact.getVersion(), + classifier, artifact.getType(), - classifier); - - ArtifactResolutionRequest req = new ArtifactResolutionRequest(); - req.setArtifact(sourcesArtifact); - req.setLocalRepository(request.getLocal()); - req.setRemoteRepositories(request.getRemoteRepos()); - ArtifactResolutionResult res = repositorySystem.resolve(req); - if (res.hasMissingArtifacts() || res.hasExceptions()) { + artifact.getVersion()); + + ArtifactRequest resolveRequest = new ArtifactRequest(sourcesArtifact, request.getRemoteRepos(), null); + try { + ArtifactResult result = repositorySystem.resolveArtifact(request.getRepoSession(), resolveRequest); + sourcesArtifact = result.getArtifact(); + } catch (ArtifactResolutionException e) { getLogger() .warn("Unable to get sources artifact for " + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() Review Comment: Why the pain and not use `Artifact#getId()`? ########## maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java: ########## @@ -570,19 +572,18 @@ protected void extendJavaProjectBuilderWithSourcesJar( JavaProjectBuilder builder, Artifact artifact, PluginToolsRequest request, String classifier) throws ExtractionException { try { - Artifact sourcesArtifact = repositorySystem.createArtifactWithClassifier( + org.eclipse.aether.artifact.Artifact sourcesArtifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), - artifact.getVersion(), + classifier, artifact.getType(), - classifier); - - ArtifactResolutionRequest req = new ArtifactResolutionRequest(); - req.setArtifact(sourcesArtifact); - req.setLocalRepository(request.getLocal()); - req.setRemoteRepositories(request.getRemoteRepos()); - ArtifactResolutionResult res = repositorySystem.resolve(req); - if (res.hasMissingArtifacts() || res.hasExceptions()) { + artifact.getVersion()); Review Comment: There is a converter util from Maven Artifact to Resolver Artifact > Use Resolver API, get rid of localRepository > -------------------------------------------- > > Key: MPLUGIN-457 > URL: https://issues.apache.org/jira/browse/MPLUGIN-457 > Project: Maven Plugin Tools > Issue Type: Improvement > Reporter: Slawomir Jaranowski > Assignee: Slawomir Jaranowski > Priority: Major > Fix For: next-release > > -- This message was sent by Atlassian Jira (v8.20.10#820010)