eclipse-platform / eclipse-platform/eclipse.platform

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

Offen
#616 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Java
Sterne
165
Forks
174
Ø Merge
2 T. 8 Std.
Gemergte PRs (30 T.)
22

Beschreibung

# 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)

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne in ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java, indem du getTargets(), getTargetNames() und run(List) zusammen mit setTasks(Project) liest. Reproduziere den bereitgestellten Build mit implizitem Target mit AntRunner und überprüfe, dass eine von Eclipse beigesteuerte Task wie eclipse.convertPath erkannt wird und der Build erfolgreich ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
build-system, tooling
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.