xerial / sbt-pack

A sbt plugin for creating distributable Scala packages.
496 stars 76 forks source link

Shared JVM options for all scripts #434

Open markarasev opened 1 year ago

markarasev commented 1 year ago

We have a project that generates a lot of executable scripts using sbt-pack (159 as of today, still growing), and we have a few JVM options that we would like all executables to share. The packJvmOpts requires to specify every script name which is cumbersome in our situation. Also, these options should be used in every new script, and it is really easy to forget to add a new entry in packJvmOpts.

What I naturally tried was packJvmOpts := Map("*" -> Seq("-D...")), but obviously it didn't work. While it would be nice to support "*", it may imply to support glob patterns as a whole for consistency, and therefore significantly complicate the implementation and the options merging logic (this consideration stands for regexes too).

Another simpler alternative would be to add a packSharedJvmOpts setting.

WDYT?

Note: I also tried to write a custom task using the generated value of packMain to build packJvmOpts, but I could not overwrite the pack task to do this (creating a new custom myPack task calling pack under the hood does the job but is not ideal), but this is more of a SBT-related issue.

xerial commented 1 year ago

Supporting wildcard * looks good and would work for your use case:

packJvmOpts := Map("*" -> Seq("-D..."))