From eb0643210f2007775df3d116f237056ec5916874 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 21 Nov 2011 20:38:58 +0000 Subject: Implemented manifest-based class-paths. If you run a jar directly, like scala foo.jar Then if a Class-Path attribute is present in the jar manifest, the classpath will be constructed from that instead of the arguments. Some things remain to be determined, like whether it's supposed to replace a classpath given on the command line or supplement it, and whether the master jar should be on the classpath or only and exactly the jars listed in the manifest. There's a really nice test case, which won't be run of course, but I can't stand going any further without tests for these hard to test on all platforms things. The faux .check file shows what I see. Closes SI-4355, review by harrah. --- .../jar-manifest/resources/MANIFEST.MF | 3 ++ test/script-tests/jar-manifest/run-test | 41 ++++++++++++++++++++++ test/script-tests/jar-manifest/run-test.check | 30 ++++++++++++++++ test/script-tests/jar-manifest/src/jar-test.scala | 34 ++++++++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 test/script-tests/jar-manifest/resources/MANIFEST.MF create mode 100755 test/script-tests/jar-manifest/run-test create mode 100644 test/script-tests/jar-manifest/run-test.check create mode 100644 test/script-tests/jar-manifest/src/jar-test.scala (limited to 'test/script-tests/jar-manifest') diff --git a/test/script-tests/jar-manifest/resources/MANIFEST.MF b/test/script-tests/jar-manifest/resources/MANIFEST.MF new file mode 100644 index 0000000000..93c54c3c6f --- /dev/null +++ b/test/script-tests/jar-manifest/resources/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: bippy.Runner +Class-Path: bippy.jar dingus.jar http://mirrors.ibiblio.org/pub/mirrors/maven2/com/thoughtworks/paranamer/paranamer/2.4/paranamer-2.4.jar diff --git a/test/script-tests/jar-manifest/run-test b/test/script-tests/jar-manifest/run-test new file mode 100755 index 0000000000..2c6d5876b8 --- /dev/null +++ b/test/script-tests/jar-manifest/run-test @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# + +set -e + +paranamerjar="http://mirrors.ibiblio.org/pub/mirrors/maven2/com/thoughtworks/paranamer/paranamer/2.4/paranamer-2.4.jar" +build=$(dirname $0)/../../../build/pack + +if [[ -n "$SCALA_HOME" ]]; then + scala="$SCALA_HOME/bin/scala" +elif [[ -d $build ]]; then + scala=$(cd $build && pwd -P)/bin/scala +else + scala="scala" +fi + +echo "$($scala -version 2>&1)" +scalac="${scala}c" + +[[ -d lib ]] || mkdir lib +[[ -f lib/paranamer-2.4.jar ]] || ( printf >&2 "Grabbing paranamer jar\n\n" && cd lib && wget --quiet "$paranamerjar" ) + +rm -rf target && mkdir target +"$scalac" -d target -cp lib/'*' src/*.scala +cd target + +jar cmf ../resources/MANIFEST.MF bippy.jar bippy +jar cf dingus.jar dingus + +run () { + echo "" + echo "% $@" + "$@" +} + +cat < + echo(m.getName, "has parameters:", namer.lookupParameterNames(m).mkString(", ")) + } + echo("") + echo("Urls exposed through the classloader:") + getClass.getClassLoader match { + case x: HasClassPath => x.classPathURLs foreach (x => echo(x)) + case _ => echo("None! Seems unlikely we'd get this far then.") + } + } + } +} + +package dingus { + class Printable { + override def toString = "\"Greetings from dingus.jar!\"" + } +} \ No newline at end of file -- cgit v1.2.3