You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/10/05 20:02:15 UTC

[GitHub] [maven-compiler-plugin] laeubi commented on a diff in pull request #151: Move away from legacy maven-compat

laeubi commented on code in PR #151:
URL: https://github.com/apache/maven-compiler-plugin/pull/151#discussion_r985641086


##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -1841,29 +1838,36 @@ private List<String> resolveProcessorPathEntries()
                 ArtifactHandler handler = artifactHandlerManager.getArtifactHandler( coord.getType() );
 
                 Artifact artifact = new DefaultArtifact(
-                     coord.getGroupId(),
-                     coord.getArtifactId(),
-                     VersionRange.createFromVersionSpec( coord.getVersion() ),
-                     Artifact.SCOPE_RUNTIME,
-                     coord.getType(),
-                     coord.getClassifier(),
-                     handler,
-                     false );
-
-                ArtifactResolutionRequest request = new ArtifactResolutionRequest()
-                                .setArtifact( artifact )
-                                .setResolveRoot( true )
-                                .setResolveTransitively( true )
-                                .setLocalRepository( session.getLocalRepository() )
-                                .setRemoteRepositories( project.getRemoteArtifactRepositories() );
-
-                ArtifactResolutionResult resolutionResult = repositorySystem.resolve( request );
-
-                resolutionErrorHandler.throwErrors( request, resolutionResult );
-
-                for ( Artifact resolved : resolutionResult.getArtifacts() )
+                        coord.getGroupId(),
+                        coord.getArtifactId(),
+                        coord.getClassifier(),
+                        handler.getExtension(),
+                        coord.getVersion()
+                );
+
+                CollectRequest collectRequest = new CollectRequest( new Dependency( artifact, JavaScopes.RUNTIME ),
+                        project.getRemoteProjectRepositories() );
+                DependencyRequest dependencyRequest = new DependencyRequest();
+                dependencyRequest.setCollectRequest( collectRequest );
+                DependencyResult dependencyResult = repositorySystem.resolveDependencies(
+                        session.getRepositorySession(), dependencyRequest );
+
+                ArrayList<ArtifactResult> failed = new ArrayList<>();
+                for ( ArtifactResult resolved : dependencyResult.getArtifactResults() )
+                {
+                    if ( resolved.getArtifact() != null && resolved.getArtifact().getFile() != null )
+                    {
+                        elements.add( resolved.getArtifact().getFile().getAbsolutePath() );
+                    }
+                    else
+                    {
+                        failed.add( resolved );

Review Comment:
   Can this actually happen or would this not just throw a `DependencyResolutionException` already?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org