xerial / sbt-pack

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

Ability to pack test scoped jars #110 #324

Closed Marc-Ducret closed 1 year ago

Marc-Ducret commented 1 year ago

Using Def.derive allows to propagate Compile/Test configurations.

Therefore Compile / pack packs without the tests and Test / pack packs with the tests.

xerial commented 1 year ago

Interesting. Just from curiosity, could you tell me how you use the packed test code?

xerial commented 1 year ago

It seems this forces the user to always select Compile or Test target for the pack command. Any idea so as not to introduce such a breaking change?

Marc-Ducret commented 1 year ago

Interesting. Just from curiosity, could you tell me how you use the packed test code?

We use ZIO-test, therefore each test suite is a runnable main class. Also we have a custom RunAllSpecs main that uses reflection to run all test suites in our package in the classpath.

Then we simply add Test / packMain := Map("app-test" -> "com.ayolab.testing.RunAllSpecs") to build.sbt .

It seems this forces the user to always select Compile or Test target for the pack command. Any idea so as not to introduce such a breaking change?

Running sbt pack does still fallback on Compile / pack as expected. Though I pushed a commit to pass the tests. The only test I had to change is archive-modules, I had to add > packagedArtifacts, and I don't understand how it was automatically called before.

xerial commented 1 year ago

OK. Let me merge. Will release a new version soon

xerial commented 1 year ago

@Marc-Ducret Released 0.17, but it seems projects using sbt-pack is broken like this. https://github.com/wvlet/airframe/pull/2584

I guess some tests are missing

xerial commented 1 year ago

ok. I've found a fix. If pack task is overwritten, it needs to be properly scoped like Compile / pack := ....