eclipse-tycho / tycho

Tycho project repository (tycho)
https://tycho.eclipseprojects.io
Eclipse Public License 2.0
166 stars 189 forks source link

Parsing custom variables in linked project resources #3820

Open HeikoKlare opened 4 months ago

HeikoKlare commented 4 months ago

Current Behavior

The ProjectParser is able to resolve linked resources and also supports some pre-defined variable names supported by the Eclipse platform (such as PROJECT_LOC and PARENT-X-PROJECT_LOC). It does, however, not yet support custom variables that can be defined in the variablesList of a project description file to share paths between multiple linked resources. When using custom variables in the location URIs of linked resources, they are considered as ordinary path segments.

Example

The binary fragments in SWT define a variable for the path to the host project:

<variableList>
    <variable>
        <name>SWT_HOST_PLUGIN</name>
        <value>$%7BPARENT-2-PROJECT_LOC%7D/bundles/org.eclipse.swt</value>
    </variable>
</variableList>

This is then used in locationURIs for linked resources, such as:

<link>
    <name>Eclipse SWT WebKit</name>
    <type>2</type>
    <locationURI>SWT_HOST_PLUGIN/Eclipse%20SWT%20WebKit</locationURI>
</link>

In this case, Tycho considers SWT_HOST_PLUGIN as an ordinary path segment as it is not aware of custom variables.

Expected Behavior

Tycho should resolve custom variables just like the project description resolver of the Eclipse platform does.

I do not consider this an urgent topic, as those variables are only a means to avoid repetitions. Still it would by nice to have in order to be consistent with the capabilities of project description files in the Eclipse platform.

laeubi commented 4 months ago

Actually there is already org.eclipse.tycho.model.project.EclipseProject.getVariables() but it seems unused at the moment.

HeikoKlare commented 4 months ago

Actually there is already org.eclipse.tycho.model.project.EclipseProject.getVariables() but it seems unused at the moment.

Indeed, and ProjectParser.parse() already fills EclipseProject with the defined variables, so the variables and their values can already be retrieved. ProjectParser.resolvePath() will require some additional logic to resolve them (probably analogous to org.eclipse.core.internal.resources.ProjectPathVariableManager.resolveVariable()).