nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at netboot-syslinux-multiplatform 149 lines 5.4 kB view raw
1{ jdk8, jdk11, jdk17 }: 2 3rec { 4 gen = 5 6 { version, nativeVersion, sha256, 7 8 # The default JDK/JRE that will be used for derived Gradle packages. 9 # A current LTS version of a JDK is a good choice. 10 defaultJava ? jdk8, 11 12 # The platforms supported by this Gradle package. 13 # Gradle Native-Platform ships some binaries that 14 # are compatible only with specific platforms. 15 # As of 2022-04 this affects platform compatibility 16 # of multiple Gradle releases, so this is used as default. 17 # See https://github.com/gradle/native-platform#supported-platforms 18 platforms ? [ 19 "aarch64-darwin" 20 "aarch64-linux" 21 "i686-windows" 22 "x86_64-cygwin" 23 "x86_64-darwin" 24 "x86_64-linux" 25 "x86_64-windows" 26 ] 27 }: 28 29 { lib, stdenv, fetchurl, makeWrapper, unzip, ncurses5, ncurses6, 30 31 # The JDK/JRE used for running Gradle. 32 java ? defaultJava, 33 34 # Additional JDK/JREs to be registered as toolchains. 35 # See https://docs.gradle.org/current/userguide/toolchains.html 36 javaToolchains ? [ ] 37 }: 38 39 stdenv.mkDerivation rec { 40 pname = "gradle"; 41 inherit version; 42 43 src = fetchurl { 44 inherit sha256; 45 url = 46 "https://services.gradle.org/distributions/gradle-${version}-bin.zip"; 47 }; 48 49 dontBuild = true; 50 51 nativeBuildInputs = [ makeWrapper unzip ]; 52 buildInputs = [ java ]; 53 54 installPhase = with builtins; 55 let 56 toolchain = rec { 57 prefix = x: "JAVA_TOOLCHAIN_NIX_${toString x}"; 58 varDefs = (lib.imap0 (i: x: "${prefix i} ${x}") javaToolchains); 59 varNames = lib.imap0 (i: x: prefix i) javaToolchains; 60 property = " -Porg.gradle.java.installations.fromEnv='${ 61 concatStringsSep "," varNames 62 }'"; 63 }; 64 varDefs = concatStringsSep "\n" (map (x: " --set ${x} \\") 65 ([ "JAVA_HOME ${java}" ] ++ toolchain.varDefs)); 66 in '' 67 mkdir -pv $out/lib/gradle/ 68 cp -rv lib/ $out/lib/gradle/ 69 70 gradle_launcher_jar=$(echo $out/lib/gradle/lib/gradle-launcher-*.jar) 71 test -f $gradle_launcher_jar 72 makeWrapper ${java}/bin/java $out/bin/gradle \ 73 ${varDefs} 74 --add-flags "-classpath $gradle_launcher_jar org.gradle.launcher.GradleMain${toolchain.property}" 75 ''; 76 77 dontFixup = !stdenv.isLinux; 78 79 fixupPhase = let arch = if stdenv.is64bit then "amd64" else "i386"; 80 in '' 81 for variant in "" "-ncurses5" "-ncurses6"; do 82 mkdir "patching$variant" 83 pushd "patching$variant" 84 jar xf $out/lib/gradle/lib/native-platform-linux-${arch}$variant-${nativeVersion}.jar 85 patchelf \ 86 --set-rpath "${stdenv.cc.cc.lib}/lib64:${lib.makeLibraryPath [ stdenv.cc.cc ncurses5 ncurses6 ]}" \ 87 net/rubygrapefruit/platform/linux-${arch}$variant/libnative-platform*.so 88 jar cf native-platform-linux-${arch}$variant-${nativeVersion}.jar . 89 mv native-platform-linux-${arch}$variant-${nativeVersion}.jar $out/lib/gradle/lib/ 90 popd 91 done 92 93 # The scanner doesn't pick up the runtime dependency in the jar. 94 # Manually add a reference where it will be found. 95 mkdir $out/nix-support 96 echo ${stdenv.cc.cc} > $out/nix-support/manual-runtime-dependencies 97 # Gradle will refuse to start without _both_ 5 and 6 versions of ncurses. 98 echo ${ncurses5} >> $out/nix-support/manual-runtime-dependencies 99 echo ${ncurses6} >> $out/nix-support/manual-runtime-dependencies 100 ''; 101 102 meta = with lib; { 103 inherit platforms; 104 description = "Enterprise-grade build system"; 105 longDescription = '' 106 Gradle is a build system which offers you ease, power and freedom. 107 You can choose the balance for yourself. It has powerful multi-project 108 build support. It has a layer on top of Ivy that provides a 109 build-by-convention integration for Ivy. It gives you always the choice 110 between the flexibility of Ant and the convenience of a 111 build-by-convention behavior. 112 ''; 113 homepage = "https://www.gradle.org/"; 114 changelog = "https://docs.gradle.org/${version}/release-notes.html"; 115 downloadPage = "https://gradle.org/next-steps/?version=${version}"; 116 sourceProvenance = with sourceTypes; [ 117 binaryBytecode 118 binaryNativeCode 119 ]; 120 license = licenses.asl20; 121 maintainers = with maintainers; [ lorenzleutgeb liff ]; 122 }; 123 }; 124 125 # NOTE: Default JDKs that are hardcoded below must be LTS versions 126 # and respect the compatibility matrix at 127 # https://docs.gradle.org/current/userguide/compatibility.html 128 129 gradle_8 = gen { 130 version = "8.0.1"; 131 nativeVersion = "0.22-milestone-24"; 132 sha256 = "02g9i1mrpdydj8d6395cv6a4ny9fw3z7sjzr7n6l6a9zx65masqv"; 133 defaultJava = jdk17; 134 }; 135 136 gradle_7 = gen { 137 version = "7.6.1"; 138 nativeVersion = "0.22-milestone-24"; 139 sha256 = "11qz1xjfihnlvsblqqnd49kmvjq86pzqcylj6k1zdvxl4dd60iv1"; 140 defaultJava = jdk17; 141 }; 142 143 gradle_6 = gen { 144 version = "6.9.4"; 145 nativeVersion = "0.22-milestone-20"; 146 sha256 = "16iqh4bn7ndch51h2lgkdqyyhnd91fdfjx55fa3z3scdacl0491y"; 147 defaultJava = jdk11; 148 }; 149}