Skip to content

Instantly share code, notes, and snippets.

@mslinn
Created February 18, 2012 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mslinn/1860817 to your computer and use it in GitHub Desktop.
Save mslinn/1860817 to your computer and use it in GitHub Desktop.
Invoke javap with latest Scala 2.9.1 and Akka 2.0 jars from ivy cache
#!/bin/bash
# Author Mike Slinn
# Invoke javap with latest Scala 2.9.1 and Akka 2.0 jars
# Does not use SBT or scala scripts, so this actually works on all platforms that have bash, including Cygwin.
# Invoke javap as usual with all options except classpath:
# javap scala.None
# You can add to the classpath with -cp, if that option is provided first:
# javap -cp org.apache.httpcomponents/httpclient/jars/ scala.None
# The additions to the classpath are assumed to exist in the ~.ivy2/cache and must end with /jars/
# The latest jar in that directory will be used
if [ $OSTYPE == cygwin ]; then
DELIM=";"
DHOME=`cygpath -dmas "$HOMEDRIVE$HOMEPATH"`
IVY=$DHOME/.ivy2/cache
else
IVY=~/.ivy2/cache
DELIM=:
fi
function newest {
for f in $IVY/${1}*.jar; do JAR=$f; done
echo $JAR
}
function D {
if [ "$CP" != "" ]; then
echo "$DELIM"
else
echo ""
fi
}
# Include SBT/Maven compiled project classes if invoked from root of project
if [ -d target/scala-2.9.1/classes ]; then
CP=target/scala-2.9.1/classes:
fi
# getopts is broken under cygwin :(
while [ "$1" == -cp ]; do
shift
CP=$CP$(D)$(newest $1)
shift
done
CP=$CP$(D)$(newest com.typesafe.akka/akka-actor/jars/)
CP=$CP$(D)$(newest org.scala-lang/scala-library/jars/)
CP=$CP$(D)$(newest com.github.scala-incubator.io/scala-io-core_2.9.1/jars/)
CP=$CP$(D)$(newest com.github.scala-incubator.io/scala-io-file_2.9.1/jars/)
CP=$CP$(D)$(newest org.scala-tools/scala-stm_2.9.1/jars/)
#echo $CP
$JAVA_HOME/bin/javap -classpath $CP "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment