[PoC] Add multimodule support to Scala CLI ⚠️ #3085
Draft
MaciejG604 wants to merge 36 commits intoVirtusLab:mainfrom
Draft
[PoC] Add multimodule support to Scala CLI ⚠️ #3085MaciejG604 wants to merge 36 commits intoVirtusLab:mainfrom
MaciejG604 wants to merge 36 commits intoVirtusLab:mainfrom
Conversation
dc40778 to
ea0acc0
Compare
- copy HasGeneratedSources.scala into ManagesBuildTargets.scala - copy HasGeneratedSourcesImpl.scala into ManagesBuildTargetsImpl.scala.
Use ProjectName class instead of plain String
…inputs for further processing
… and complicates the build process in compose mode.
…ut in reality does not test anything with the last call to compile.
Contributor
|
Without diving into the changes, how could this PR address scenarios like full-stack apps - e.g. where you need to bundle some compiled scala-js into a route from a scala jvm server |
…ependencies, WIP - test still needs fixing
ea0acc0 to
812bce1
Compare
Contributor
Author
|
@bishabosha I haven't given much thought to Scala JS, when preparing those changes and I'm not sure if building with Scala JS and depending on other modules will work out of the box with the changes prepared here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is posted here to get some opinions on whether this is valid at all, not really in the code-sense but rather in the "Scala CLI as the official Scala runner"-sense.
This is a proof of concept PR stemming from previous work on scala-compose repo. The goal is to add support for projects containing multiple modules, each with separate classpath, that can depend on each other. Presented changes introduce BSP support that seems to work with Metals and a little worse with IntelliJ. This is still a work in progress and there are some things to figure out before this could be merged.
The main idea is to reuse the code that we already have for single module projects and simply loop over modules, calling functions same as before. This, in most parts avoids touching critical elements of the logic. Also, it allows for the behaviour to stay exactly the same when operating on single module projects.
The outline of the changes done to the code base:
HasGeneratedSourcestoManagesBuildTargets- the oldHasGeneratedSourcesImplassumed that the project contains only one module and operated on its Scopes keeping a map of those, new implementation keeps the same information by theProjectNamekey which allows to store the Main and Test build targets same as before, but can handle mutliple of those. We're mostly relying on Bloop to keep the BSP standard while comunicating with the IDE client, so supporting mutliple build targets is ready out of the box if we can keep track of them. This change seems really safe - only one test blew up due to some race condition that I was not able to track down 😞.Inputsclass that aggregates information about files that get fed into the build process and also validates them. To multiply the instances ofInputs(renamed toModuleInputsand later toModules) I introduced theInputsComposerclass that analyzes the configuration frommodules.tomland creates instances ofInputswith the correct links between them. Putting this code intobspandsetup-idecommands is quite simple - it basically requires to switch to working onSeq[Inputs]instead ofInputs.runcommand which resulted in introducing a new trait with the old nameInputsthat kept track of which module is the "target" of the command and allows to compute the compile order of modules (also keep some universal stuff like workspace path to not callSeq[Inputs].head.workspaceeverywhere).Things that still need figuring out:
.scala-build/target-123/classes/mainwhich does not contain external sources like libraries, this will require some reorganization of the build procedure so that we stop after computing each build target'sProject, link them together and the proceed with calling Bloop for compilation.