2021-12-06 16:07:01 +00:00
|
|
|
{ jdk8, jdk11, jdk17 }:
|
|
|
|
|
2021-08-05 21:33:18 +00:00
|
|
|
rec {
|
2021-12-06 16:07:01 +00:00
|
|
|
gen =
|
|
|
|
|
2022-02-20 05:27:41 +00:00
|
|
|
{ version, nativeVersion, sha256, defaultJava ? jdk8, supportedPlatforms ? null }:
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
{ lib, stdenv, fetchurl, makeWrapper, unzip, java ? defaultJava
|
2021-12-26 17:43:05 +00:00
|
|
|
, javaToolchains ? [ ], ncurses5, ncurses6 }:
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "gradle";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
inherit sha256;
|
|
|
|
url =
|
|
|
|
"https://services.gradle.org/distributions/gradle-${version}-bin.zip";
|
|
|
|
};
|
|
|
|
|
|
|
|
dontBuild = true;
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper unzip ];
|
|
|
|
buildInputs = [ java ];
|
|
|
|
|
|
|
|
# NOTE: For more information on toolchains,
|
|
|
|
# see https://docs.gradle.org/current/userguide/toolchains.html
|
|
|
|
installPhase = with builtins;
|
|
|
|
let
|
|
|
|
toolchain = rec {
|
|
|
|
var = x: "JAVA_TOOLCHAIN_NIX_${toString x}";
|
|
|
|
vars = (lib.imap0 (i: x: ("${var i} ${x}")) javaToolchains);
|
|
|
|
varNames = lib.imap0 (i: x: var i) javaToolchains;
|
|
|
|
property = " -Porg.gradle.java.installations.fromEnv='${
|
|
|
|
concatStringsSep "," varNames
|
|
|
|
}'";
|
|
|
|
};
|
|
|
|
vars = concatStringsSep "\n" (map (x: " --set ${x} \\")
|
|
|
|
([ "JAVA_HOME ${java}" ] ++ toolchain.vars));
|
|
|
|
in ''
|
|
|
|
mkdir -pv $out/lib/gradle/
|
|
|
|
cp -rv lib/ $out/lib/gradle/
|
|
|
|
|
|
|
|
gradle_launcher_jar=$(echo $out/lib/gradle/lib/gradle-launcher-*.jar)
|
|
|
|
test -f $gradle_launcher_jar
|
|
|
|
makeWrapper ${java}/bin/java $out/bin/gradle \
|
|
|
|
${vars}
|
|
|
|
--add-flags "-classpath $gradle_launcher_jar org.gradle.launcher.GradleMain${toolchain.property}"
|
|
|
|
'';
|
|
|
|
|
|
|
|
dontFixup = !stdenv.isLinux;
|
|
|
|
|
|
|
|
fixupPhase = let arch = if stdenv.is64bit then "amd64" else "i386";
|
|
|
|
in ''
|
2021-12-26 17:43:05 +00:00
|
|
|
for variant in "" "-ncurses5" "-ncurses6"; do
|
|
|
|
mkdir "patching$variant"
|
|
|
|
pushd "patching$variant"
|
|
|
|
jar xf $out/lib/gradle/lib/native-platform-linux-${arch}$variant-${nativeVersion}.jar
|
|
|
|
patchelf \
|
|
|
|
--set-rpath "${stdenv.cc.cc.lib}/lib64:${lib.makeLibraryPath [ stdenv.cc.cc ncurses5 ncurses6 ]}" \
|
|
|
|
net/rubygrapefruit/platform/linux-${arch}$variant/libnative-platform*.so
|
|
|
|
jar cf native-platform-linux-${arch}$variant-${nativeVersion}.jar .
|
|
|
|
mv native-platform-linux-${arch}$variant-${nativeVersion}.jar $out/lib/gradle/lib/
|
|
|
|
popd
|
|
|
|
done
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
# The scanner doesn't pick up the runtime dependency in the jar.
|
|
|
|
# Manually add a reference where it will be found.
|
|
|
|
mkdir $out/nix-support
|
|
|
|
echo ${stdenv.cc.cc} > $out/nix-support/manual-runtime-dependencies
|
2021-12-26 17:43:05 +00:00
|
|
|
# Gradle will refuse to start without _both_ 5 and 6 versions of ncurses.
|
|
|
|
echo ${ncurses5} >> $out/nix-support/manual-runtime-dependencies
|
|
|
|
echo ${ncurses6} >> $out/nix-support/manual-runtime-dependencies
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Enterprise-grade build system";
|
|
|
|
longDescription = ''
|
|
|
|
Gradle is a build system which offers you ease, power and freedom.
|
|
|
|
You can choose the balance for yourself. It has powerful multi-project
|
|
|
|
build support. It has a layer on top of Ivy that provides a
|
|
|
|
build-by-convention integration for Ivy. It gives you always the choice
|
|
|
|
between the flexibility of Ant and the convenience of a
|
|
|
|
build-by-convention behavior.
|
|
|
|
'';
|
|
|
|
homepage = "https://www.gradle.org/";
|
|
|
|
changelog = "https://docs.gradle.org/${version}/release-notes.html";
|
|
|
|
downloadPage = "https://gradle.org/next-steps/?version=${version}";
|
2022-06-26 10:26:21 +00:00
|
|
|
sourceProvenance = with sourceTypes; [
|
|
|
|
binaryBytecode
|
|
|
|
binaryNativeCode
|
|
|
|
];
|
2021-12-06 16:07:01 +00:00
|
|
|
license = licenses.asl20;
|
2022-02-20 05:27:41 +00:00
|
|
|
platforms = if (supportedPlatforms != null) then supportedPlatforms else platforms.unix;
|
2021-12-26 17:43:05 +00:00
|
|
|
maintainers = with maintainers; [ lorenzleutgeb liff ];
|
2021-12-06 16:07:01 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
# NOTE: Default JDKs are LTS versions and according to
|
|
|
|
# https://docs.gradle.org/current/userguide/compatibility.html
|
2020-07-18 16:06:22 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
gradle_7 = gen {
|
2022-04-03 18:54:34 +00:00
|
|
|
version = "7.4.2";
|
2022-02-20 05:27:41 +00:00
|
|
|
nativeVersion = "0.22-milestone-23";
|
2022-04-03 18:54:34 +00:00
|
|
|
sha256 = "1nkz9gn1vb5l94dkf9yzb1j3hkll5x2vrl5p320msn2fk089pr19";
|
2021-12-06 16:07:01 +00:00
|
|
|
defaultJava = jdk17;
|
2022-02-20 05:27:41 +00:00
|
|
|
# Gradle 7 ships some binaries that are only available for some platforms
|
|
|
|
# See https://github.com/gradle/native-platform#supported-platforms
|
|
|
|
supportedPlatforms = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" "x86_64-cygwin" "x86_64-windows" "i686-windows" ];
|
2021-12-06 16:07:01 +00:00
|
|
|
};
|
2020-07-18 16:06:22 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
gradle_6 = gen {
|
2021-12-24 04:21:11 +00:00
|
|
|
version = "6.9.2";
|
2021-12-06 16:07:01 +00:00
|
|
|
nativeVersion = "0.22-milestone-20";
|
2021-12-24 04:21:11 +00:00
|
|
|
sha256 = "13qyk3f6namw27ynh6nxljxpk9r3l12vxl3f0qpglprdf3c6ydcb";
|
2021-12-06 16:07:01 +00:00
|
|
|
defaultJava = jdk11;
|
2022-02-20 05:27:41 +00:00
|
|
|
# Gradle 6 ships some binaries that are only available for some platforms
|
|
|
|
# See https://github.com/gradle/native-platform#supported-platforms
|
|
|
|
supportedPlatforms = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" "x86_64-cygwin" "x86_64-windows" "i686-windows" ];
|
2021-12-06 16:07:01 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
# NOTE: No GitHub Release for the following versions. `update.sh` will not work.
|
|
|
|
gradle_5 = gen {
|
2021-04-08 16:26:57 +00:00
|
|
|
version = "5.6.4";
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeVersion = "0.18";
|
2021-12-06 16:07:01 +00:00
|
|
|
sha256 = "03d86bbqd19h9xlanffcjcy3vg1k5905vzhf9mal9g21603nfc0z";
|
|
|
|
defaultJava = jdk11;
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
gradle_4 = gen {
|
2021-04-08 16:26:57 +00:00
|
|
|
version = "4.10.3";
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeVersion = "0.14";
|
2021-04-08 16:26:57 +00:00
|
|
|
sha256 = "0vhqxnk0yj3q9jam5w4kpia70i4h0q4pjxxqwynh3qml0vrcn9l6";
|
2021-12-06 16:07:01 +00:00
|
|
|
defaultJava = jdk8;
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|