diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-01-06 13:42:37 +0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-01-06 14:36:14 +0100 |
commit | 5d6259a9739d03f6ae2751b342689c877e7209df (patch) | |
tree | 9f051e9ee23a6de43a137799c5ebdd49081219ed /pkgs/build-support/setup-hooks/set-java-classpath.sh | |
parent | e36427fd4e7f33360bbbcd85d8cf276664c277b1 (diff) | |
download | nixlib-5d6259a9739d03f6ae2751b342689c877e7209df.tar nixlib-5d6259a9739d03f6ae2751b342689c877e7209df.tar.gz nixlib-5d6259a9739d03f6ae2751b342689c877e7209df.tar.bz2 nixlib-5d6259a9739d03f6ae2751b342689c877e7209df.tar.lz nixlib-5d6259a9739d03f6ae2751b342689c877e7209df.tar.xz nixlib-5d6259a9739d03f6ae2751b342689c877e7209df.tar.zst nixlib-5d6259a9739d03f6ae2751b342689c877e7209df.zip |
Add a setup hook that automatically sets up $CLASSPATH
All JARs in $pkg/share/java (for each $pkg in the build inputs) are added to $CLASSPATH. Thus, you can say buildInputs = [ setJavaClassPath someJavaDependency ]; and the JARs in someJavaDependency will be found automatically by tools like javac or ant. Note that the manual used to say that JARs should be installed in lib/java; this is now share/java, following the Debian policy: http://www.debian.org/doc/packaging-manuals/java-policy/x110.html The directory share/java makes more sense because JARs are architecture-independent. (Also, a quick grep shows that we were not exactly consistent about this in Nixpkgs.)
Diffstat (limited to 'pkgs/build-support/setup-hooks/set-java-classpath.sh')
-rw-r--r-- | pkgs/build-support/setup-hooks/set-java-classpath.sh | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/pkgs/build-support/setup-hooks/set-java-classpath.sh b/pkgs/build-support/setup-hooks/set-java-classpath.sh new file mode 100644 index 000000000000..76e8e42ca268 --- /dev/null +++ b/pkgs/build-support/setup-hooks/set-java-classpath.sh @@ -0,0 +1,13 @@ +# This setup hook adds every JAR in the share/java subdirectories of +# the build inputs to $CLASSPATH. + +export CLASSPATH + +addPkgToClassPath () { + local jar + for jar in $1/share/java/*.jar; do + export CLASSPATH=''${CLASSPATH}''${CLASSPATH:+:}''${jar} + done +} + +envHooks=(''${envHooks[@]} addPkgToClassPath) |