Skip to content

Commit

Permalink
Export resources as unmanaged resources directories in sbt
Browse files Browse the repository at this point in the history
  • Loading branch information
lwronski committed Dec 29, 2021
1 parent c74e28f commit 0ee8267
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 10 additions & 1 deletion modules/cli/src/main/scala/scala/cli/export/Sbt.scala
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,17 @@ final case class Sbt(
)
}

val customResourceSettings =
if (options.classPathOptions.resourcesDir.isEmpty) Nil
else {
val resources = options.classPathOptions.resourcesDir.map(p => s"""file("$p")""")
Seq(
s"""Compile / unmanagedResourceDirectories ++= Seq(${resources.mkString(", ")})"""
)
}

SbtProject(
settings = Seq(customCompileOnlyJarsSettings, customJarsSettings)
settings = Seq(customCompileOnlyJarsSettings, customJarsSettings, customResourceSettings)
)
}

Expand Down
3 changes: 2 additions & 1 deletion modules/cli/src/main/scala/scala/cli/export/SbtProject.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ final case class SbtProject(

val buildSbtImportsContent = imports.map(_ + nl).mkString
val buildSbtSettingsContent = settings
.filter(_.nonEmpty)
.map { settings0 =>
settings0.map(s => s + nl).mkString + nl
}
Expand All @@ -53,7 +54,7 @@ final case class SbtProject(
}
for ((path, language, content) <- testSources) {
val path0 = dir / "src" / "test" / language / path
os.write(path0, content)
os.write(path0, content, createFolders = true)
}
}
}
Expand Down

0 comments on commit 0ee8267

Please sign in to comment.