My understanding of the sbt manual is that the steps are the following:
- generate the Java classes
- create a jar with the jar command
- create a
lib
folder in the Scala project root and place the jar into this folder
- refresh the project
- import the Java classes into the Scala files like this:
import com.daml.sor.workflow.workflow.Product
I’m using IntelliJ IDEA.
I’ve done the steps above and get the error value daml is not a member of com
.
What am I doing wrong?
If you didn’t fiddle with your unmanaged dependencies settings, sbt
should indeed look for them in the lib
directory. If you have a multi-module setup, you might want to check whether this is based on the root of the individual module rather than the root of the whole project.
Alternatively, you might want to consider the idea of generating the source files and putting them in a place where they can be picked up by sbt
to make them available when you’re compiling the whole project (this is what happens with ScalaPB for Protobuf/gRPC for example, with the generated code going in the target
directory alongside other build artifacts).
1 Like
So far none of these seem to work, probably because I am doing something fundamentally wrong, continue the experimentation.
Thank you for the hints, these are the two lines I needed to add to build.stb
for the generated files and the Java binding to be included:
Compile / unmanagedSourceDirectories += baseDirectory.value / "scala-test" / "generated-files"
libraryDependencies += "com.daml" % "bindings-rxjava" % "2.6.1"
I hope this is the beginning of a beautiful friendship between me and Scala.