···11+{ fetchurl, stdenv, coreutils, makeWrapper }:
22+33+let version = "1.9.6"; in
44+55+stdenv.mkDerivation {
66+ name = "ant-${version}";
77+88+ buildInputs = [ makeWrapper ];
99+1010+ src = fetchurl {
1111+ url = "mirror://apache/ant/binaries/apache-ant-${version}-bin.tar.bz2";
1212+ sha256 = "1cwd5vq175gyicw0hkm8idwa33zxwhf7xlxywaqxcqqdjql0jfx4";
1313+ };
1414+1515+ contrib = fetchurl {
1616+ url = mirror://sourceforge/ant-contrib/ant-contrib-1.0b3-bin.tar.bz2;
1717+ sha256 = "96effcca2581c1ab42a4828c770b48d54852edf9e71cefc9ed2ffd6590571ad1";
1818+ };
1919+2020+ installPhase =
2121+ ''
2222+ mkdir -p $out/bin $out/lib/ant
2323+ mv * $out/lib/ant/
2424+2525+ # Get rid of the manual (35 MiB). Maybe we should put this in a
2626+ # separate output. Keep the antRun script since it's vanilla sh
2727+ # and needed for the <exec/> task (but since we set ANT_HOME to
2828+ # a weird value, we have to move antRun to a weird location).
2929+ # Get rid of the other Ant scripts since we provide our own.
3030+ mv $out/lib/ant/bin/antRun $out/bin/
3131+ rm -rf $out/lib/ant/{manual,bin,WHATSNEW}
3232+ mkdir $out/lib/ant/bin
3333+ mv $out/bin/antRun $out/lib/ant/bin/
3434+3535+ # Install ant-contrib.
3636+ unpackFile $contrib
3737+ cp -p ant-contrib/ant-contrib-*.jar $out/lib/ant/lib/
3838+3939+ cat >> $out/bin/ant <<EOF
4040+ #! ${stdenv.shell} -e
4141+4242+ ANT_HOME=$out/lib/ant
4343+4444+ # Find the JDK by looking for javac. As a fall-back, find the
4545+ # JRE by looking for java. The latter allows just the JRE to be
4646+ # used with (say) ECJ as the compiler. Finally, allow the GNU
4747+ # JVM.
4848+ if [ -z "\$JAVA_HOME" ]; then
4949+ for i in javac java gij; do
5050+ if p="\$(type -p \$i)"; then
5151+ export JAVA_HOME="\$(${coreutils}/bin/dirname \$(${coreutils}/bin/dirname \$(${coreutils}/bin/readlink -f \$p)))"
5252+ break
5353+ fi
5454+ done
5555+ if [ -z "\$JAVA_HOME" ]; then
5656+ echo "\$0: cannot find the JDK or JRE" >&2
5757+ exit 1
5858+ fi
5959+ fi
6060+6161+ if [ -z \$NIX_JVM ]; then
6262+ if [ -e \$JAVA_HOME/bin/java ]; then
6363+ NIX_JVM=\$JAVA_HOME/bin/java
6464+ elif [ -e \$JAVA_HOME/bin/gij ]; then
6565+ NIX_JVM=\$JAVA_HOME/bin/gij
6666+ else
6767+ NIX_JVM=java
6868+ fi
6969+ fi
7070+7171+ LOCALCLASSPATH="\$ANT_HOME/lib/ant-launcher.jar\''${LOCALCLASSPATH:+:}\$LOCALCLASSPATH"
7272+7373+ exec \$NIX_JVM \$NIX_ANT_OPTS \$ANT_OPTS -classpath "\$LOCALCLASSPATH" \
7474+ -Dant.home=\$ANT_HOME -Dant.library.dir="\$ANT_LIB" \
7575+ org.apache.tools.ant.launch.Launcher \$NIX_ANT_ARGS \$ANT_ARGS \
7676+ -cp "\$CLASSPATH" "\$@"
7777+ EOF
7878+7979+ chmod +x $out/bin/ant
8080+ ''; # */
8181+8282+ meta = {
8383+ homepage = http://ant.apache.org/;
8484+ description = "A Java-based build tool";
8585+8686+ longDescription = ''
8787+ Apache Ant is a Java-based build tool. In theory, it is kind of like
8888+ Make, but without Make's wrinkles.
8989+9090+ Why another build tool when there is already make, gnumake, nmake, jam,
9191+ and others? Because all those tools have limitations that Ant's
9292+ original author couldn't live with when developing software across
9393+ multiple platforms. Make-like tools are inherently shell-based -- they
9494+ evaluate a set of dependencies, then execute commands not unlike what
9595+ you would issue in a shell. This means that you can easily extend
9696+ these tools by using or writing any program for the OS that you are
9797+ working on. However, this also means that you limit yourself to the
9898+ OS, or at least the OS type such as Unix, that you are working on.
9999+100100+ Ant is different. Instead of a model where it is extended with
101101+ shell-based commands, Ant is extended using Java classes. Instead of
102102+ writing shell commands, the configuration files are XML-based, calling
103103+ out a target tree where various tasks get executed. Each task is run
104104+ by an object that implements a particular Task interface.
105105+ '';
106106+107107+ license = stdenv.lib.licenses.asl20;
108108+ maintainers = [ stdenv.lib.maintainers.eelco ];
109109+ platforms = stdenv.lib.platforms.all;
110110+ };
111111+}