at v206 106 lines 3.8 kB view raw
1{ fetchurl, stdenv, coreutils, makeWrapper }: 2 3let version = "1.9.6"; in 4 5stdenv.mkDerivation { 6 name = "ant-${version}"; 7 8 buildInputs = [ makeWrapper ]; 9 10 src = fetchurl { 11 url = "mirror://apache/ant/binaries/apache-ant-${version}-bin.tar.bz2"; 12 sha256 = "1cwd5vq175gyicw0hkm8idwa33zxwhf7xlxywaqxcqqdjql0jfx4"; 13 }; 14 15 contrib = fetchurl { 16 url = mirror://sourceforge/ant-contrib/ant-contrib-1.0b3-bin.tar.bz2; 17 sha256 = "96effcca2581c1ab42a4828c770b48d54852edf9e71cefc9ed2ffd6590571ad1"; 18 }; 19 20 installPhase = 21 '' 22 mkdir -p $out/bin $out/lib/ant 23 mv * $out/lib/ant/ 24 25 # Get rid of the manual (35 MiB). Maybe we should put this in a 26 # separate output. Also get rid of the Ant scripts since we 27 # provide our own. 28 rm -rf $out/lib/ant/{manual,bin,WHATSNEW} 29 30 # Install ant-contrib. 31 unpackFile $contrib 32 cp -p ant-contrib/ant-contrib-*.jar $out/lib/ant/lib/ 33 34 cat >> $out/bin/ant <<EOF 35 #! ${stdenv.shell} -e 36 37 ANT_HOME=$out/lib/ant 38 39 # Find the JDK by looking for javac. As a fall-back, find the 40 # JRE by looking for java. The latter allows just the JRE to be 41 # used with (say) ECJ as the compiler. Finally, allow the GNU 42 # JVM. 43 if [ -z "\$JAVA_HOME" ]; then 44 for i in javac java gij; do 45 if p="\$(type -p \$i)"; then 46 export JAVA_HOME="\$(${coreutils}/bin/dirname \$(${coreutils}/bin/dirname \$(${coreutils}/bin/readlink -f \$p)))" 47 break 48 fi 49 done 50 if [ -z "\$JAVA_HOME" ]; then 51 echo "\$0: cannot find the JDK or JRE" >&2 52 exit 1 53 fi 54 fi 55 56 if [ -z \$NIX_JVM ]; then 57 if [ -e \$JAVA_HOME/bin/java ]; then 58 NIX_JVM=\$JAVA_HOME/bin/java 59 elif [ -e \$JAVA_HOME/bin/gij ]; then 60 NIX_JVM=\$JAVA_HOME/bin/gij 61 else 62 NIX_JVM=java 63 fi 64 fi 65 66 LOCALCLASSPATH="\$ANT_HOME/lib/ant-launcher.jar\''${LOCALCLASSPATH:+:}\$LOCALCLASSPATH" 67 68 exec \$NIX_JVM \$NIX_ANT_OPTS \$ANT_OPTS -classpath "\$LOCALCLASSPATH" \ 69 -Dant.home=\$ANT_HOME -Dant.library.dir="\$ANT_LIB" \ 70 org.apache.tools.ant.launch.Launcher \$NIX_ANT_ARGS \$ANT_ARGS \ 71 -cp "\$CLASSPATH" "\$@" 72 EOF 73 74 chmod +x $out/bin/ant 75 ''; # */ 76 77 meta = { 78 homepage = http://ant.apache.org/; 79 description = "A Java-based build tool"; 80 81 longDescription = '' 82 Apache Ant is a Java-based build tool. In theory, it is kind of like 83 Make, but without Make's wrinkles. 84 85 Why another build tool when there is already make, gnumake, nmake, jam, 86 and others? Because all those tools have limitations that Ant's 87 original author couldn't live with when developing software across 88 multiple platforms. Make-like tools are inherently shell-based -- they 89 evaluate a set of dependencies, then execute commands not unlike what 90 you would issue in a shell. This means that you can easily extend 91 these tools by using or writing any program for the OS that you are 92 working on. However, this also means that you limit yourself to the 93 OS, or at least the OS type such as Unix, that you are working on. 94 95 Ant is different. Instead of a model where it is extended with 96 shell-based commands, Ant is extended using Java classes. Instead of 97 writing shell commands, the configuration files are XML-based, calling 98 out a target tree where various tasks get executed. Each task is run 99 by an object that implements a particular Task interface. 100 ''; 101 102 license = stdenv.lib.licenses.asl20; 103 maintainers = [ stdenv.lib.maintainers.eelco ]; 104 platforms = stdenv.lib.platforms.all; 105 }; 106}