Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions modules/build/src/main/scala/scala/build/CrossSources.scala
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,10 @@ object CrossSources {

val resourceDirectoriesFromDirectives = {
val resourceDirsFromCli =
allInputs.elements.flatMap { case rd: ResourceDirectory => Some(rd.path); case _ => None }
allInputs.elements.flatMap {
case rd: ResourceDirectory => Some(rd.path)
case _ => None
}
val resourceDirsFromBuildOptions: Seq[os.Path] =
buildOptions.flatMap(_.value.classPathOptions.resourcesDir).distinct
resourceDirsFromBuildOptions
Expand Down Expand Up @@ -318,7 +321,7 @@ object CrossSources {
}

val resourceDirs: Seq[WithBuildRequirements[os.Path]] =
resolveResourceDirs(finalInputs, preprocessedSources)
resolveResourceDirs(allInputs, preprocessedSources)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using allInpts instead of finalInputs solves the issue

Copy link
Contributor

Choose a reason for hiding this comment

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

it does for this use case, but I do not think it would for all edge cases... I'm working on an alternative fix, sorry this took so long

Copy link
Contributor

Choose a reason for hiding this comment

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

that being said, that your fix does work made me realise how much this part of the code is in need of a refactor 🙃


lazy val allPathsWithDirectivesByScope: Map[Scope, Seq[(os.Path, Position.File)]] =
(pathsWithDirectivePositions ++ inMemoryWithDirectivePositions ++ unwrappedScriptsWithDirectivePositions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,21 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite {
expect(resourceDirs == Seq(path))
}
}
test("do not include test.resourceDir into sources for main scope") {
val testInputs = TestInputs(
os.rel / "simple.sc" ->
"""//> using test.resourceDir foo
|""".stripMargin
)
testInputs.withBuild(baseOptions, buildThreads, bloopConfigOpt, scope = Scope.Main) {
(root, _, maybeBuild) =>
val build =
maybeBuild.toOption.flatMap(_.successfulOpt).getOrElse(sys.error("cannot happen"))
val resourceDirs = build.sources.resourceDirs

expect(resourceDirs.isEmpty)
}
}
test("parse boolean for publish.doc") {
val testInputs = TestInputs(
os.rel / "simple.sc" ->
Expand Down
Loading