Saturday, February 18, 2017

Using a Java Agent with Scala/SBT

Just some notes to myself:

Adding unmanaged dependencies to a build:

Unmanaged dependencies work like this: add jars to lib and they will be placed on the project classpath. lib is a sister directory to src
Dependencies in lib go on all the classpaths (for compile, test, run, and console).

from: http://www.scala-sbt.org/0.13/docs/Library-Dependencies.html

Start SBT with Java Agent JAR file:

An example. SizeOf is a program which uses java.lang.instrument and must be launched as a Java Agent:

java -jar -javaagent:/lib/SizeOf.jar /opt/local/share/sbt/sbt-launch.jar 'run-main org.clulab.reach.ShowSizes'

Ended up using JAMM (https://github.com/jbellis/jamm):

java -jar -javaagent:/Users/hickst/workspaceCLU/clulab/reach/main/lib/jamm-0.3.1.jar /opt/local/share/sbt/sbt-launch.jar 'run-main org.clulab.reach.ShowMemReachable'