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.)
This commit is contained in:
Eelco Dolstra
2014-01-06 14:36:14 +01:00
parent e36427fd4e
commit 5d6259a973
4 changed files with 22 additions and 11 deletions
+6 -10
View File
@@ -1,4 +1,4 @@
{ stdenv, fetchurl, unzip, ant, jdk }:
{ stdenv, fetchurl, unzip, ant, jdk, makeWrapper }:
let
version = "3.7.2";
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
sha256 = "0swyysbyfmv068x8q1c5jqpwk5zb4xahg17aypx5rwb660f8fpbm";
};
buildInputs = [ unzip ant jdk ];
buildInputs = [ unzip ant jdk makeWrapper ];
unpackPhase = ''
mkdir "${name}"
@@ -25,16 +25,12 @@ stdenv.mkDerivation rec {
buildPhase = "ant build";
installPhase = ''
mkdir -pv $out/lib/java
cp -v *.jar $out/lib/java
mkdir -pv $out/share/java
cp -v *.jar $out/share/java
mkdir -pv $out/bin
cat > $out/bin/ecj <<EOF
#! /bin/sh
exec ${jdk.jre}/bin/java -cp $out/lib/java/ecj.jar org.eclipse.jdt.internal.compiler.batch.Main "\$@"
EOF
chmod u+x $out/bin/ecj
makeWrapper ${jdk.jre}/bin/java $out/bin/ecj \
--add-flags "-cp $out/share/java/ecj.jar org.eclipse.jdt.internal.compiler.batch.Main"
'';
meta = {