Commit 90da7eb1 authored by Hugo Lageneste's avatar Hugo Lageneste
Browse files

pkl: init at 0.28.2

parent 0169a2ff
Loading
Loading
Loading
Loading
+1495 −0

File added.

Preview size limit exceeded, changes collapsed.

+12 −0
Original line number Diff line number Diff line
diff --git i/pkl-cli/src/test/kotlin/org/pkl/cli/CliEvaluatorTest.kt w/pkl-cli/src/test/kotlin/org/pkl/cli/CliEvaluatorTest.kt
index df88c423..ae1db500 100644
--- i/pkl-cli/src/test/kotlin/org/pkl/cli/CliEvaluatorTest.kt
+++ w/pkl-cli/src/test/kotlin/org/pkl/cli/CliEvaluatorTest.kt
@@ -1497,6 +1497,7 @@ result = someLib.x
     assertThat(output).isEqualTo("result = 1\n")
   }
 
+  @Disabled
   @Test
   fun `eval file with non-ASCII name`() {
     val tempDirUri = tempDir.toUri()
+65 −0
Original line number Diff line number Diff line
diff --git a/pkl-gradle/src/test/kotlin/org/pkl/gradle/JavaCodeGeneratorsTest.kt b/pkl-gradle/src/test/kotlin/org/pkl/gradle/JavaCodeGeneratorsTest.kt
index 68a5b533..84fe66df 100644
--- a/pkl-gradle/src/test/kotlin/org/pkl/gradle/JavaCodeGeneratorsTest.kt
+++ b/pkl-gradle/src/test/kotlin/org/pkl/gradle/JavaCodeGeneratorsTest.kt
@@ -18,9 +18,11 @@ package org.pkl.gradle
 import kotlin.io.path.listDirectoryEntries
 import kotlin.io.path.readText
 import org.assertj.core.api.Assertions.assertThat
+import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test
 
 class JavaCodeGeneratorsTest : AbstractTest() {
+  @Disabled("runTask doesn't use the MITM cache")
   @Test
   fun `generate code`() {
     writeBuildFile()
@@ -68,6 +70,7 @@ class JavaCodeGeneratorsTest : AbstractTest() {
     )
   }
 
+  @Disabled("runTask doesn't use the MITM cache")
   @Test
   fun `compile generated code`() {
     writeBuildFile()
@@ -84,6 +87,7 @@ class JavaCodeGeneratorsTest : AbstractTest() {
     assertThat(addressClassFile).exists()
   }
 
+  @Disabled("runTask doesn't use the MITM cache")
   @Test
   fun `no source modules`() {
     writeFile(
diff --git a/pkl-gradle/src/test/kotlin/org/pkl/gradle/KotlinCodeGeneratorsTest.kt b/pkl-gradle/src/test/kotlin/org/pkl/gradle/KotlinCodeGeneratorsTest.kt
index 2b9ffc88..99b91893 100644
--- a/pkl-gradle/src/test/kotlin/org/pkl/gradle/KotlinCodeGeneratorsTest.kt
+++ b/pkl-gradle/src/test/kotlin/org/pkl/gradle/KotlinCodeGeneratorsTest.kt
@@ -18,9 +18,11 @@ package org.pkl.gradle
 import kotlin.io.path.listDirectoryEntries
 import kotlin.io.path.readText
 import org.assertj.core.api.Assertions.assertThat
+import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test
 
 class KotlinCodeGeneratorsTest : AbstractTest() {
+  @Disabled("runTask doesn't use the MITM cache")
   @Test
   fun `generate code`() {
     writeBuildFile()
@@ -69,6 +71,7 @@ class KotlinCodeGeneratorsTest : AbstractTest() {
     )
   }
 
+  @Disabled("runTask doesn't use the MITM cache")
   @Test
   fun `compile generated code`() {
     writeBuildFile()
@@ -84,6 +87,7 @@ class KotlinCodeGeneratorsTest : AbstractTest() {
     assertThat(addressClassFile).exists()
   }
 
+  @Disabled("runTask doesn't use the MITM cache")
   @Test
   fun `no source modules`() {
     writeFile(
+14 −0
Original line number Diff line number Diff line
diff --git a/pkl-gradle/pkl-gradle.gradle.kts b/pkl-gradle/pkl-gradle.gradle.kts
index 08f0e8ca..a16c7073 100644
--- a/pkl-gradle/pkl-gradle.gradle.kts
+++ b/pkl-gradle/pkl-gradle.gradle.kts
@@ -58,7 +58,7 @@ sourceSets {
     // if `compileClasspath` is filtered, causing "unresolved reference" errors in IntelliJ.
     // As a workaround, don't perform filtering for IntelliJ (import).
     if (System.getProperty("idea.sync.active") == null) {
-      compileClasspath = compileClasspath.filter { !(it.path.contains("dists")) }
+      compileClasspath = compileClasspath.filter { !(it.path.contains("@gradle@") || it.path.contains("generated-gradle-jars/gradle-api-")) }
     }
   }
 }
+101 −0
Original line number Diff line number Diff line
{
  stdenv,
  lib,
  fetchFromGitHub,
  gradle,
  temurin-bin-21,
  kotlin,
  nix-update-script,
  replaceVars,
  makeWrapper,
}:
let
  jdk = temurin-bin-21;
  gradleOverlay = gradle.override { java = jdk; };
  kotlinOverlay = kotlin.override { jre = jdk; };
in
stdenv.mkDerivation (finalAttrs: {
  pname = "pkl";
  version = "0.28.2";

  src = fetchFromGitHub {
    owner = "apple";
    repo = "pkl";
    tag = finalAttrs.version;
    hash = "sha256-ay3V3EWqZHncLH6UR4JOCChkweNcilDeskXzaeAFTR8=";
    leaveDotGit = true;
    postFetch = ''
      pushd $out
      git rev-parse HEAD | tr -d '\n' > .commit-hash
      rm -rf .git
      popd
    '';
  };

  patches = [
    (replaceVars ./fix_kotlin_classpath.patch { gradle = gradle.unwrapped; })
    ./disable_gradle_codegen_tests.patch
    ./disable_bad_tests.patch
  ];

  nativeBuildInputs = [
    gradleOverlay
    jdk
    kotlinOverlay
    makeWrapper
  ];

  mitmCache = gradle.fetchDeps {
    inherit (finalAttrs) pname;
    data = ./deps.json;
  };

  doCheck = !(stdenv.hostPlatform.isDarwin);

  gradleFlags = [
    "-x"
    "spotlessCheck"
    "-DreleaseBuild=true"
    "-Dorg.gradle.java.home=${jdk}"
    "-Porg.gradle.java.installations.auto-download=false"
    "-Porg.gradle.java.installations.auto-detect=false"
  ];

  preBuild = ''
    gradleFlagsArray+=(-DcommitId=$(cat .commit-hash))
  '';

  JAVA_TOOL_OPTIONS = "-Dfile.encoding=utf-8";
  __darwinAllowLocalNetworking = true;

  preCheck = ''
    export LANG=C.UTF-8
    export LC_ALL=C.UTF-8
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p "$out/bin" "$out/opt/pkl"
    cp ./pkl-cli/build/executable/jpkl "$out/opt/pkl/jpkl.jar"

    makeWrapper ${lib.getExe jdk} $out/bin/pkl --add-flags "-jar $out/opt/pkl/jpkl.jar"

    runHook postInstall
  '';

  passthru.updateScript = nix-update-script { };

  meta = {
    description = "Configuration-as-code language with rich validation and tooling";
    homepage = "https://pkl-lang.org";
    license = lib.licenses.asl20;
    platforms = lib.platforms.all;
    maintainers = with lib.maintainers; [ hugolgst ];
    mainProgram = "pkl";
    sourceProvenance = with lib.sourceTypes; [
      fromSource
      binaryBytecode # mitm cache
    ];
  };
})