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)
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:
- 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.
- 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
<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.
Summary
DependencyFilesetsTaskignores themavenProjectIdattribute: the null-check uses the configurable field, but the actual lookup uses a hardcodedgetReference("maven.project"). SettingmavenProjectIdto 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.javalines 54-61 (master @441382c)Problem
Two inconsistencies:
mavenProjectIdfield, but the project is then fetched with the hardcoded"maven.project"reference at line 58. SettingmavenProjectIdto any non-default value therefore either throws a spuriousMaven project reference not found: <id>(when that id is not a registered reference), or is silently ignored and the default project is used anyway."maven.project"reference is only registered by theAntRunMojo. If the task is invoked standalone (e.g. from an externalbuild.xmlvia the<ant>task), the reference isnulland line 61mavenProject.getArtifacts()throws an NPE.Reproduction
Result:
BuildException: Maven project reference not found: nonexistent.ref, although the defaultmaven.projectreference 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.