eclipse-platform / eclipse-platform/eclipse.platform

Eclipse Ant Contributions are not available in implicit targets introduced when using AntRunner

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

Descrizione

# Motivation and Severity

The [Epsilon CI Container](https://gitlab.com/committed-consulting/mde-devops/epsilon-ci-container) project uses Eclipse `AntRunner` to execute Model-Driven Workflows. To increase the adoption of this approach, it is important to keep the writing of the ant build files as simple as possible. Often, client builds only have the form of a linear set of instructions.

Since Ant 1.6.0, every project includes an implicit target that contains any and all top-level tasks and/or types. This target will always be executed as part of the project's initialization, even when Ant is run with the [-projecthelp](https://ant.apache.org/manual/running.html#options) option.

This allows a build file to have the following form:

```ant


```

Which is preferable to using:

```ant




```

Also, the implicit target acts as a prelude to all other targets, allowing to perform global actions and definitions.

The [Eclipse Ant support](https://help.eclipse.org/latest/topic/org.eclipse.platform.doc.user/concepts/concepts-antsupport.htm) contributes tasks as using the [Ant Task Extension Point](https://help.eclipse.org/latest/topic/org.eclipse.platform.doc.isv/reference/extension-points/org_eclipse_ant_core_antTasks.html). The Eclipse platform itself uses this extension point to contribute the [`eclipse.convertPath`](https://help.eclipse.org/latest/topic/org.eclipse.platform.doc.isv/guide/ant_eclipse_tasks.htm) task.

Executing the [AntRunner](https://help.eclipse.org/latest/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2FantRunner.htm) should yield the same result as [Running Ant from the Workbench](https://help.eclipse.org/latest/topic/org.eclipse.platform.doc.user/tasks/tasks-ant-running.htm), but when run in the `AntRunner` application, contributed tasks and types are shown as undefined, and the build fails.

# Issue

Developers can not use Ant [Contributions](https://help.eclipse.org/latest/topic/org.eclipse.platform.doc.isv/reference/extension-points/org_eclipse_ant_core_antTasks.html) in implicit targets.

* Actual Behaviour: When an Ant build that contains an implicit target which references a task or type that is a [Contribution](https://help.eclipse.org/latest/topic/org.eclipse.platform.doc.isv/reference/extension-points/org_eclipse_ant_core_antTasks.html) is executed using AntRunner, it fails and the type is shown as missing.

```bash
at org.apache.tools.ant.UnknownElement.getNotFoundException(UnknownElement.java:504)
at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:436)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:166)
at org.apache.tools.ant.Task.perform(Task.java:349)
at org.apache.tools.ant.Target.execute(Target.java:449)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:184)
at org.eclipse.ant.internal.core.ant.InternalAntRunner.parseBuildFile(InternalAntRunner.java:392)
at org.eclipse.ant.internal.core.ant.InternalAntRunner.getTargetNames(InternalAntRunner.java:486)
at org.eclipse.ant.internal.core.ant.InternalAntRunner.processUnrecognizedTargets(InternalAntRunner.java:1253)
at org.eclipse.ant.internal.core.ant.InternalAntRunner.processCommandLine(InternalAntRunner.java:1231)
at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:644)
at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:573)
```

* Expected Behaviour: The build succeeds.

# Technical Detail and Background

For an [Ant Project](https://ant.apache.org/manual/using.html#projects) the following attributes are specified:

Attribute | Description | Required
-- | -- | --
name | the name of the project. | No
default | the default target to use when no target is supplied. | **No; however, since Ant 1.6.0, every project includes an implicit target that contains any and all top-level tasks and/or types. This target will always be executed as part of the project's initialization, even when Ant is run with the -projecthelp option.**

As highlighted,

> since Ant 1.6.0, every project includes an implicit target that contains any and all top-level tasks and/or types. This target will always be executed as part of the project's initialization, even when Ant is run with the [-projecthelp](https://ant.apache.org/manual/running.html#options) option.

# Possible Cause

When processing the command line, the AntRunner attempts to get the target names. This leads to a parse that uses reflection and the classpath to identify legal tasks and types. However, `org.eclipse.ant.internal.core.ant.InternalAntRunner.setTasks(Project)` has not been called at this time, and hence `org.eclipse.ant.core.AntCorePreferences.getTasks()` are not known.

It seems that `setTasks(Project)` must be called earlier. There are three locations in `org.eclipse.ant.internal.core.ant.InternalAntRunner` that need to be amended, as far as I can see:

* [`getTargetNames()`](https://github.com/eclipse-platform/eclipse.platform/blob/18d0171854eec533f733f60d0c278acdf0c9f8ae/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java#L478)
* [`getTargets()`](https://github.com/eclipse-platform/eclipse.platform/blob/18d0171854eec533f733f60d0c278acdf0c9f8ae/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java#L416)
* [`run(List)`](https://github.com/eclipse-platform/eclipse.platform/blob/18d0171854eec533f733f60d0c278acdf0c9f8ae/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java#L606)

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia in ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java, leggendo getTargets(), getTargetNames() e run(List) insieme a setTasks(Project). Riproduci la build fornita con target implicito usando AntRunner e verifica che un task fornito da Eclipse, come eclipse.convertPath, venga riconosciuto e che la build abbia successo.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
build-system, tooling
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.