eclipse-platform / eclipse-platform/eclipse.platform

AntRunner does not use ProjectHelperRegistry / Blocks Polyglot Interpretation in Eclipse

Aperta
#205 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
165
Fork
174
Merge medio
2g 8h
PR unite (30g)
22

Descrizione

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.

![image](https://user-images.githubusercontent.com/782737/194190448-f3a98a74-19a7-413d-9b1d-0e4f8191a023.png)

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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.