2

In our project, we have multiple test source directories. For each test source directory, the requirement is to generate different jar file. How to do that using sbt pack plugin or some other sbt plugin. Simplified project is available at:-

https://github.com/moglideveloper/multiJar

mogli
  • 1,549
  • 4
  • 29
  • 57
  • @TomerShetah : I will really appreciate, if you can post build.sbt code referring https://github.com/moglideveloper/multiJar/blob/master/build.sbt. I want different spec jars for different spec source directories. – mogli Dec 16 '20 at 11:09
  • yes it's generating 3 different jars but all jars have classes from all spec source directories. – mogli Dec 16 '20 at 11:13
  • Are you sure? What is the output of `java -jar specA/target/pack/lib/speca_2.12-0.1.0-SNAPSHOT.jar`? – Tomer Shetah Dec 16 '20 at 11:19

1 Answers1

1

You just need to add the following 3 lines:

lazy val specA = project.enablePlugins(PackPlugin)
lazy val specB = project.enablePlugins(PackPlugin)
lazy val specC = project.enablePlugins(PackPlugin)

Then each spec will generate a different jar.

If you don't define those projects, sbt assumes that you have only one project. When packing each project creates a different jar, which you can define its own properties.

Please see here which properties you can set. Please see this post to be sure that pack is the one you want to use.

Tomer Shetah
  • 8,413
  • 7
  • 27
  • 35