eclipse-xtext / eclipse-xtext/xtext

JdtToBeBuiltComputer may skip indexing relevant jars

Open
#3,389 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help_wanted
Dominant language
Java
Stars
831
Forks
330
Avg merge
3d 7h
Merged PRs (30d)
12

Description

The following has been observed in Xtext 2.28, but it seems the code in question hasn't changed since:

  • Assume a jar file Lib.jar containing DSL files X1.mydsl ...
  • Assume a chain of dependent DSL projects, P3 -> P2 -> P1, each with an additional dependency on Lib.jar
  • By some cause the index for Lib.jar has gone missing or is badly outdated
    • Replacing the file on disk seems to trigger this. This might be the result of m2e updating dependencies.
  • User sees resolve errors in P3 "Couldn't resolve reference to MyThing 'X1'" and triggers a clean build on P3
  • Errors remain - bummer.

This happens because

  • the full build on P3 will ask JdtToBeBuiltComputer whether or not Lib.jar should be reindexed
    • the answer is "no"
    • this happens because the code (via isBuiltByUpstream()) assumes that Lib.jar will have been indexed already via P1 (and P2).
    • this assumption is wrong in the case of building individual projects, rather than the entire workspace

User is left with these (non-obvious) workarounds:

  • clean build the entire workspace - which can be a real performance problem, if it's needed for each update of maven dependencies, e.g.
  • figure out which is the most-upstream project that depends on Lib.jar to perform the clean build there. In a large workspace this may not be an obvious thing to figure out.

I believe this could best be addressed by replacing the following expression in updateProject()

  • workspace.computeProjectOrder(workspace.getRoot().getProjects())
  • with some invocation buildContext.getAllReferencedBuildConfigs()
    • this would require exposing the builder instance to JdtToBeBuiltComputer so it can call getContext().

This change would ensure that the assumption "isBuiltByUpstream()` considers only those projects that participate in the current builder invocation.

Injecting such a change from a DSL implementation is not straight forward, as there doesn't seem to be a way to replace JdtToBeBuiltComputer with your own variant, one can only add additional contributions. Moreover, the issue may potentially affect all DSLs, so a fix in Xtext itself seems preferable.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at JdtToBeBuiltComputer.updateProject() and trace how isBuiltByUpstream() uses workspace.computeProjectOrder(). Inspect the builder context and the proposed getAllReferencedBuildConfigs() entry point, then reproduce the P3 → P2 → P1 scenario with Lib.jar. Done means a clean build of an individual project reindexes Lib.jar when it is part of the current builder invocation.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.