Marin Marin - 11 months ago 71
Scala Question

Is this build.sbt ok for packaging?

I am trying to package an unmanaged jar along with some Scala code. I program using IntelliJ, and I am not sure if the package is being built correctly.


is as follows:

name := "InvokeCompiler"

version := "1.0"

scalaVersion := "2.11.8"

exportJars := true

val parserLocation = "lib/parser-0.0.1.jar"

mappings in (Compile, packageBin) ~= {


//unmanagedJars in Compile += file(parserLocation)

mappings in (Compile, packageBin) <+= baseDirectory map { base =>

(base / parserLocation) -> "parser-0.0.1.jar"

I want to make a new jar file that contains the unmanaged jar and the code I wrote. This jar will be converted to a
for use it in C#. But, when doing this, IKVMC throws all sorts of warnings. When I add the
it produces the
only contains the class I wrote myself.

Answer Source

You don't say how you're building it, so that might be the first problem. Specifically, you should use the sbt publish-local command. To verify that the dependency is include simply unzip the JAR file and look.

If you need the resulting JAR file to be executable, then you should add this to your build.sbt:

mainClass in Compile := Some("name.of.your.main.Class")

Replace name.of.your.main.Class with your class name. You are doing something similar but potentially problematic:

mappings in (Compile, packageBin) ~= {

What this means is that anything that has a class name that doesn't start with Main will be filtered out. Unless you have a good reason for this, I'd get rid of it and point the package main method explicitly. What mappings does is described here.