elharo opened a new issue, #371:
URL: https://github.com/apache/maven-antrun-plugin/issues/371
## Summary
`DependencyFilesetsTask` ignores the `mavenProjectId` attribute: the
null-check uses the configurable field, but the actual lookup uses a hardcoded
`getReference("maven.project")`. Setting `mavenProjectId` to anything other
than the default breaks the task, and using the task outside the antrun mojo
causes an NPE.
## Affected code
`src/main/java/org/apache/maven/ant/tasks/DependencyFilesetsTask.java` lines
54-61 (master @ `441382c`)
```java
if (this.getProject().getReference(mavenProjectId) == null) {
throw new BuildException("Maven project reference not found: " +
mavenProjectId);
}
MavenProject mavenProject = this.getProject().getReference("maven.project");
```
## Problem
Two inconsistencies:
1. The existence check at line 54 uses the configurable `mavenProjectId`
field, but the project is then fetched with the hardcoded `"maven.project"`
reference at line 58. Setting `mavenProjectId` to any non-default value
therefore either throws a spurious `Maven project reference not found: <id>`
(when that id is not a registered reference), or is silently ignored and the
default project is used anyway.
2. The hardcoded `"maven.project"` reference is only registered by the
`AntRunMojo`. If the task is invoked standalone (e.g. from an external
`build.xml` via the `<ant>` task), the reference is `null` and line 61
`mavenProject.getArtifacts()` throws an NPE.
## Reproduction
```xml
<target xmlns:mvn="http://maven.apache.org/ANTRUN">
<mvn:dependencyfilesets mavenProjectId="nonexistent.ref"/>
</target>
```
Result: `BuildException: Maven project reference not found:
nonexistent.ref`, although the default `maven.project` reference exists.
## Expected behavior
The attribute should either be honored consistently (both check and lookup)
or removed; the lookup should not silently depend on a hardcoded reference id.
--
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]