Implement resource mapping support (#2592)#2834
Open
krrish175-byte wants to merge 2 commits intoscalacenter:mainfrom
Open
Implement resource mapping support (#2592)#2834krrish175-byte wants to merge 2 commits intoscalacenter:mainfrom
krrish175-byte wants to merge 2 commits intoscalacenter:mainfrom
Conversation
tgodzik
requested changes
Jan 8, 2026
Contributor
tgodzik
left a comment
There was a problem hiding this comment.
For sure we should start with updating bloop-config
| * @param logger Logger for warnings | ||
| * @return List of validation errors | ||
| */ | ||
| def validateMappings( |
Contributor
There was a problem hiding this comment.
I don't think this adds a lot, we should just show clearly if any copy attempt failed
Comment on lines
+137
to
+147
| private def hasDirectoryChanged(dir: AbsolutePath, lastModified: Long): Boolean = { | ||
| if (!dir.exists) return false | ||
|
|
||
| val stream = Files.walk(dir.underlying) | ||
| try { | ||
| stream.anyMatch(path => Files.getLastModifiedTime(path).toMillis > lastModified) | ||
| } finally { | ||
| stream.close() | ||
| } | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
Suggested change
| private def hasDirectoryChanged(dir: AbsolutePath, lastModified: Long): Boolean = { | |
| if (!dir.exists) return false | |
| val stream = Files.walk(dir.underlying) | |
| try { | |
| stream.anyMatch(path => Files.getLastModifiedTime(path).toMillis > lastModified) | |
| } finally { | |
| stream.close() | |
| } | |
| } | |
| } | |
| private def hasDirectoryChanged(dir: AbsolutePath, lastModified: Long): Boolean = { | |
| if (dir.exists) { | |
| val stream = Files.walk(dir.underlying) | |
| try { | |
| stream.anyMatch(path => Files.getLastModifiedTime(path).toMillis > lastModified) | |
| } finally { | |
| stream.close() | |
| } | |
| } | |
| } else { | |
| false | |
| } |
| val projectDirectory = AbsolutePath(project.directory) | ||
|
|
||
| // Parse resource mappings if available (requires bloop-config 2.3.4+) | ||
| // TODO: Uncomment parsing logic once bloop-config is updated with resourceMapping field |
Contributor
There was a problem hiding this comment.
We need to fist change bloop-config, otherwise this will mostly be dead code. We should also make sure that Bloop's sbt plugin properly fills the newly added field
| postCompilationTasks.runAsync(ExecutionContext.ioScheduler) | ||
|
|
||
| // Copy mapped resources after compilation | ||
| val copyMappedResourcesTask = |
Contributor
There was a problem hiding this comment.
We should probably put it alongside the normal copyResources in updateExternalClassesDirWithReadOnly
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.
Description
This PR implements support for file mapping of resources in Bloop, allowing resources to be copied to custom locations in the classes directory (jar-relative paths). This feature enables Bloop to support build configurations similar to SBT's mappings setting, where resources need to be placed at specific paths in the output jar/directory.
Changes
Testing:
Verification:
Unit Tests: Verified recursive directory copying, empty mapping handling, and validation logic.
Integration Tests: Verified that:
Manual Verification: Confirmed that resources appear in the client-visible classes directory (bloop-bsp-clients-classes).
Dependencies / Notes:
This implementation relies on a schema update in bloop-config (to version 2.3.4 or higher) to parse the resourceMapping field from the JSON configuration.
The parsing logic in Project.scala is currently commented out and marked with a TODO, pending the release and upgrade of bloop-config. The internal infrastructure is fully functional and tested via manual injection in tests.
Closing Issue:
Closes #2592
@tgodzik