elharo opened a new issue, #372:
URL: https://github.com/apache/maven-antrun-plugin/issues/372

   ## Summary
   `AntRunMojo.copyProperties(MavenProject, Project)` dereferences 
`artifact.getFile()` without a null check when registering the per-dependency 
artifact properties. Any project dependency whose artifact has no resolved file 
crashes the mojo with an opaque `NullPointerException` instead of a clear 
resolution error.
   
   ## Affected code
   `src/main/java/org/apache/maven/plugins/antrun/AntRunMojo.java` lines 
430-436 (master @ `441382c`)
   
   ```java
   Set<Artifact> depArtifacts = mavenProject.getArtifacts();
   for (Artifact artifact : depArtifacts) {
       String propName = artifact.getDependencyConflictId();
       antProject.setProperty(propertyPrefix + propName, 
artifact.getFile().getPath());
   }
   ```
   
   ## Problem
   `artifact.getFile()` may be `null` (e.g. partial/offline resolution, or 
dependencies whose artifact file was never downloaded), and the code calls 
`.getPath()` on it directly. The same class already handles this case 
consistently in `getPathFromArtifacts` (AntRunMojo.java:362-381), which throws 
a `DependencyResolutionRequiredException` when `artifact.getFile() == null`:
   
   ```java
   for (Artifact a : artifacts) {
       File file = a.getFile();
       if (file == null) {
           throw new DependencyResolutionRequiredException(a);
       }
       list.add(file.getPath());
   }
   ```
   
   ## Expected behavior
   Dependency artifacts with no resolved file should be skipped or reported 
with a clear, actionable error (matching `getPathFromArtifacts`), rather than 
aborting the whole mojo with an NPE that gives no hint of which dependency is 
the cause.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to