Skip to content

Commit

Permalink
ant: use upstream launcher script
Browse files Browse the repository at this point in the history
  • Loading branch information
tomodachi94 committed Nov 30, 2024
1 parent 1ae7d13 commit 0ac4c03
Showing 1 changed file with 9 additions and 41 deletions.
50 changes: 9 additions & 41 deletions pkgs/by-name/an/ant/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ stdenv.mkDerivation (finalAttrs: {
pname = "ant";
version = "1.10.15";

buildInputs = [ jre ];

nativeBuildInputs = [ makeWrapper ];

src = fetchurl {
Expand Down Expand Up @@ -41,47 +43,13 @@ stdenv.mkDerivation (finalAttrs: {
unpackFile $contrib
cp -p ant-contrib/ant-contrib-*.jar $out/lib/ant/lib/
cat >> $out/bin/ant <<EOF
#! ${stdenv.shell} -e
ANT_HOME=$out/lib/ant
# Find the JDK by looking for javac. As a fall-back, find the
# JRE by looking for java. The latter allows just the JRE to be
# used with (say) ECJ as the compiler. Finally, allow the GNU
# JVM.
if [ -z "\''${JAVA_HOME-}" ]; then
for i in javac java gij; do
if p="\$(type -p \$i)"; then
export JAVA_HOME="\$(${coreutils}/bin/dirname \$(${coreutils}/bin/dirname \$(${coreutils}/bin/readlink -f \$p)))"
break
fi
done
if [ -z "\''${JAVA_HOME-}" ]; then
echo "\$0: cannot find the JDK or JRE" >&2
exit 1
fi
fi
if [ -z \$NIX_JVM ]; then
if [ -e \$JAVA_HOME/bin/java ]; then
NIX_JVM=\$JAVA_HOME/bin/java
elif [ -e \$JAVA_HOME/bin/gij ]; then
NIX_JVM=\$JAVA_HOME/bin/gij
else
NIX_JVM=java
fi
fi
LOCALCLASSPATH="\$ANT_HOME/lib/ant-launcher.jar\''${LOCALCLASSPATH:+:}\$LOCALCLASSPATH"
exec \$NIX_JVM \$NIX_ANT_OPTS \$ANT_OPTS -classpath "\$LOCALCLASSPATH" \
-Dant.home=\$ANT_HOME -Dant.library.dir="\$ANT_LIB" \
org.apache.tools.ant.launch.Launcher \$NIX_ANT_ARGS \$ANT_ARGS \
-cp "\$CLASSPATH" "\$@"
EOF
chmod +x $out/bin/ant
# Wrap the wrappers.
for wrapper in ant runant.py runant.pl; do
wrapProgram "$out/lib/ant/bin/$wrapper" \
--set JAVA_HOME "${jre.home}" \
--set ANT_HOME "$out/lib/ant" \
--prefix CLASSPATH : "$out/lib/ant/lib"
done
'';

passthru = {
Expand Down

0 comments on commit 0ac4c03

Please sign in to comment.