query
On this page

wrapGradle

pkgs.gradle-packages.wrapGradle

Docs pulled from | This Revision | 31 minutes ago


Contribute
Enhance the ecosystem with your expertise! Contribute to fill the gaps in documentation. Your input can make a difference.

Noogle detected

Implementation

The following is the current implementation of this function.

{
      lib,
      callPackage,
      mitm-cache,
      replaceVars,
      symlinkJoin,
      concatTextFile,
      makeSetupHook,
      gradle-unwrapped,
      runCommand,
      ...
    }@args:
    let
      gradle = gradle-unwrapped.override args;
    in
    symlinkJoin {
      pname = "gradle";
      inherit (gradle) version;

      paths = [
        (makeSetupHook { name = "gradle-setup-hook"; } (concatTextFile {
          name = "setup-hook.sh";
          files = [
            (mitm-cache.setupHook)
            (replaceVars ./setup-hook.sh {
              # jdk used for keytool
              inherit (gradle) jdk;
              init_script = "${./init-build.gradle}";
            })
          ];
        }))
        gradle
        mitm-cache
      ];

      passthru = {
        fetchDeps = callPackage ./fetch-deps.nix { inherit mitm-cache; };
        inherit (gradle) jdk;
        unwrapped = gradle;
        tests = {
          toolchains =
            let
              javaVersion = lib.getVersion jdk11;
              javaMajorVersion = lib.versions.major javaVersion;
            in
            runCommand "detects-toolchains-from-nix-env"
              {
                # Use JDKs that are not the default for any of the gradle versions
                nativeBuildInputs = [
                  (gradle.override {
                    javaToolchains = [
                      jdk11
                    ];
                  })
                ];
                src = ./tests/toolchains;
              }
              ''
                cp -a $src/* .
                substituteInPlace ./build.gradle --replace-fail '@JAVA_VERSION@' '${javaMajorVersion}'
                env GRADLE_USER_HOME=$TMPDIR/gradle GRADLE_OPTS=-Dorg.gradle.native.dir=$TMPDIR/native \
                  gradle run --no-daemon --quiet --console plain > $out
                actual="$(<$out)"
                if [[ "${javaVersion}" != "$actual"* ]]; then
                  echo "Error: Expected '${javaVersion}', to start with '$actual'" >&2
                  exit 1
                fi
              '';
        }
        // gradle.tests;
      };

      meta = gradle.meta // {
        # prefer normal gradle/mitm-cache over this wrapper, this wrapper only provides the setup hook
        # and passthru
        priority = (gradle.meta.priority or lib.meta.defaultPriority) + 1;
      };
    }