Last active
August 26, 2020 11:10
-
-
Save Slakah/706fc780a381a8702c101d219e38cc64 to your computer and use it in GitHub Desktop.
Publish vendor Jar to maven from sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// publish to your maven repo using `sbt "myProject/publish"` | |
// note maven appears to only really support a single jar per library, so create multiple sub-modules | |
// name of the jar in modules/my-project/lib/<name>.jar | |
val jarName = "my-vendor-jar" | |
lazy val myJar = (project in file("modules/my-jar")) | |
.settings( | |
name := "my-jar", | |
... | |
// settings to treat the unmanaged lib jar as the main jar of the published artifact | |
(Compile / packageBin) := unmanagedBase.value / s"$jarName.jar", | |
artifacts := Classpaths.artifactDefs(List(makePom, Compile / packageBin)).value, | |
packagedArtifacts := Classpaths.packaged(List(makePom, Compile / packageBin)).value, | |
// shouldn't depend on scala, or be tied to scala version | |
autoScalaLibrary := false, | |
crossPaths := false | |
) | |
// another sub-project can depend on the jar project, and have the jar available on the classpath | |
lazy val service = (project in file("modules/service")) | |
.dependsOn(myJar) | |
.settings(...) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment