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