apache / apache/maven-antrun-plugin
dependencyfilesets ignores the mavenProjectId attribute (hardcoded 'maven.project' reference)
- Dominant language
- Java
- Stars
- 36
- Forks
- 20
- Avg merge
- 1h 48m
- Merged PRs (30d)
- 1
Description
## 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: ` (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 `` task), the reference is `null` and line 61 `mavenProject.getArtifacts()` throws an NPE.
## Reproduction
```xml
```
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.