psiroky commented on code in PR #169: URL: https://github.com/apache/maven-compiler-plugin/pull/169#discussion_r1081648930
########## src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java: ########## @@ -1814,29 +1810,26 @@ 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 ); + + for ( ArtifactResult resolved : dependencyResult.getArtifactResults() ) { - elements.add( resolved.getFile().getAbsolutePath() ); + if ( resolved.getArtifact() != null && resolved.getArtifact().getFile() != null ) + { + elements.add( resolved.getArtifact().getFile().getAbsolutePath() ); + } Review Comment: No, I am really just talking "in theory". I did not reproduce this. And the code is likely fine as it is. As someone reading the code for the first time though, if I see a `null` check I expect the "thing" can actually be `null` is some cases, otherwise the `null` check would not there. So I would either remove the `null` check completely (and have an NPE thrown if this happens) or throw another explicit exception. I haven't really had a preference between the two, hence started the discussion. -- 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-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org