Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bin folders of dependencies to the classpath when they're open in the workspace #2094

Conversation

sungshik
Copy link
Contributor

@sungshik sungshik commented Dec 6, 2024

Before this PR, when a REPL was created in a project, and when one of its dependencies (as declared in the POM) was open in the same workspace:

  • the src folder of the dependency was loaded from the workspace;
  • the bin folder of the dependency wasn't loaded at all (neither from the workspace, nor from the local Maven repository).

After this PR, the bin folder is loaded from the workspace, too. This PR fixes the following issue (in rascal-language-servers):

See the separate comments for additional clarification/questions.

@@ -543,8 +543,10 @@ public static PathConfig fromSourceProjectRascalManifest(ISourceLocation manifes
switch (mode) {
case INTERPRETER:
srcsWriter.appendAll(childConfig.getSrcs());
libsWriter.append(childConfig.getBin());
Copy link
Contributor Author

@sungshik sungshik Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be conceptually nicer (?) to:

  1. Generalize the bin field from ISourceLocation to List<ISourceLocation> (and rename the field to bins)
  2. Add the bin locations from the dependencies to that list

But, I expect this will touch a lot more places in the existing code, so I thought I'd go for the solution with the smallest footprint first...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bin folder must be in one place; this follows the target folder convention in other build systems like mvn. Also it is required to be unambiguous and unique, because this is what ends up being packaged into a runtime module like a jar or zip or doll.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this does the trick! Surgical precision 👍

Comment on lines 548 to 551
case COMPILER:
// FIXME (?): Add something to `srcsWriter` here?
libsWriter.append(setTargetScheme(projectLoc));
break;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Davy asked to be mindful of possible similar changes for COMPILER, so I added this FIXME provisionally. I'm not sure if the sources need to be explicitly added, or if this is already covered as part of the libs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No the compiler never uses libraries from source positions. That's the main difference between interpreter and compiler mode.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the important feature of the Compiler to be able to work with binary dependencies. It's also important to keep a "single source of truth" , the exact bill of materials, for library dependencies: we never depend on both the source and the binary ofa library.

@sungshik sungshik marked this pull request as ready for review December 6, 2024 17:40
Copy link
Member

@jurgenvinju jurgenvinju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remove the todo. The code checks for existing open projects and now it also adds the target folder to the Classpath libraries.

@sungshik sungshik merged commit 2e3a1f8 into replace-lib-by-mvn-and-others Dec 9, 2024
@sungshik sungshik deleted the replace-lib-by-mvn-and-others-fix/target-folders-on-classpath branch December 9, 2024 08:01
@sungshik
Copy link
Contributor Author

sungshik commented Dec 9, 2024

Thank you for clarifying! Removed the FIXME and merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants