eclipse-platform / eclipse-platform/eclipse.platform
AntRunner does not use ProjectHelperRegistry / Blocks Polyglot Interpretation in Eclipse
- Dominant language
- Java
- Stars
- 165
- Forks
- 174
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 22
Description
Ant is meant to allow polyglot interpretation using [custom Project Helpers](https://ant.apache.org/manual/projecthelper.html).
The build file below should prompt ant to consult the [`ProjectHelperRepository`](https://ant.apache.org/manual/api/org/apache/tools/ant/ProjectHelperRepository.html) to see if any [`ProjectHelper`](https://ant.apache.org/manual/api/org/apache/tools/ant/ProjectHelper.html) is able to handle the `custom.format`.
```xml
```
Eclipse's `InternalAntRunner` does not do that. Instead it selects the [current project helper](https://github.com/eclipse-platform/eclipse.platform/blob/master/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java#L390), which is [the first project helper found in the classpath](https://ant.apache.org/manual/api/org/apache/tools/ant/ProjectHelper.html#getProjectHelper()).
This behaviour is incorrect. Instead, it should call [`ProjectHelper.configureProject()`](https://github.com/apache/ant/blob/master/src/main/org/apache/tools/ant/ProjectHelper.java#L100) first. This correct behaviour is implemented by all `ant` invocations in the ant distribution, as visible from the call graph below.

This a snippet of the implementation of the function.
```java
/**
* Configures the project with the contents of the specified build file.
*
* @param project The project to configure. Must not be null.
* @param buildFile A build file giving the project's configuration.
* Must not be null.
*
* @exception BuildException if the configuration is invalid or cannot be read
*/
public static void configureProject(Project project, File buildFile) throws BuildException {
FileResource resource = new FileResource(buildFile);
ProjectHelper helper = ProjectHelperRepository.getInstance().getProjectHelperForBuildFile(resource);
project.addReference(PROJECTHELPER_REFERENCE, helper);
helper.parse(project, buildFile);
}
```
Could you please add this, as it blocks polyglot use of ant.
Contributor guide
Assessment
This issue has not been assessed yet.