diff --git a/.github/gradle-cache/action.yml b/.github/gradle-cache/action.yml
new file mode 100644
index 00000000..d6fd28cb
--- /dev/null
+++ b/.github/gradle-cache/action.yml
@@ -0,0 +1,21 @@
+name: "Gradle Cache Action"
+description: "Sets up Gradle Cache"
+
+inputs:
+ key:
+ required: true
+ description: "The cache key"
+
+runs:
+ using: composite
+ steps:
+ # Adapted from https://github.com/actions/cache/blob/v3/examples.md#java---gradle
+ - name: Cache Gradle local repository
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/.gradle/caches
+ ~/.gradle/wrapper
+ key: ${{ runner.os }}-${{ inputs.key }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
+ restore-keys: |
+ ${{ runner.os }}-${{ inputs.key }}-
\ No newline at end of file
diff --git a/.github/prepare-cache-action/action.yml b/.github/prepare-cache-action/action.yml
new file mode 100644
index 00000000..feab0385
--- /dev/null
+++ b/.github/prepare-cache-action/action.yml
@@ -0,0 +1,17 @@
+name: "Prepare Cache Action"
+description: "Prevents local published artifacts from be added to GH Actions cache"
+
+runs:
+ using: composite
+ steps:
+ - name: "Clean local artifacts"
+ if: contains(runner.os, 'win') == false
+ run: rm -rvf ~/.m2/repository/gg/jte
+ shell: bash
+
+ # `rm` syntax for Windows is different. Needs to use `-Force` since `-f`
+ # is ambiguous (possible matches include: -Filter -Force).
+ - name: "[Windows]: Clean local artifacts"
+ if: contains(runner.os, 'win')
+ run: rm -r -Force ~/.m2/repository/gg/jte
+ shell: pwsh
\ No newline at end of file
diff --git a/.github/workflows/graalvm.yml b/.github/workflows/graalvm.yml
deleted file mode 100644
index 9ad9440c..00000000
--- a/.github/workflows/graalvm.yml
+++ /dev/null
@@ -1,68 +0,0 @@
-name: Test native builds
-
-# No need to run when only the docs are changing. There is
-# a workflow to validate the docs.
-# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore
-on:
- pull_request:
- paths-ignore:
- - 'docs/**'
- - 'mkdocs.yml'
- push:
- branches:
- - main
-
-jobs:
- build:
- runs-on: ${{ matrix.os }}
- strategy:
- fail-fast: false
- matrix:
- java_version: [17]
- os: [windows-2022, macOS-latest, ubuntu-latest]
-
- steps:
- - uses: actions/checkout@v4
- - uses: graalvm/setup-graalvm@v1
- with:
- distribution: 'graalvm'
- java-version: ${{ matrix.java_version }}
- components: 'native-image'
- github-token: ${{ secrets.GITHUB_TOKEN }}
- cache: 'maven'
-
- # Adapted from https://github.com/actions/cache/blob/v3/examples.md#java---gradle
- - name: Cache local Gradle
- id: gradleCache
- uses: actions/cache@v4
- with:
- path: |
- ~/.gradle/caches
- ~/.gradle/wrapper
- key: ${{ runner.os }}-gradle-graalvm-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
- restore-keys: |
- ${{ runner.os }}-gradle-graalvm-
-
- - name: Make Maven Wrapper executable
- if: contains(matrix.os, 'win') == false
- run: chmod +x ./mvnw
- - name: Build with Maven
- run: ./mvnw install --file pom.xml -DskipTests=true
- - name: Build Gradle Plugin
- run: cd jte-gradle-plugin && ./gradlew publishToMavenLocal
- - name: Test Gradle Plugin Generate with conventions
- run: cd test/jte-runtime-cp-test-gradle-convention && ./gradlew check nativeTest
- - name: Stop Gradle Daemon
- if: ${{ always() }}
- run: cd test/jte-runtime-cp-test-gradle-convention && ./gradlew --stop
-
- # This prevents local published artifacts from be added to GH Actions cache
- - name: Clean local artifacts
- if: contains(matrix.os, 'win') == false
- run: rm -rvf ~/.m2/repository/gg/jte
-
- # `rm` syntax for Windows is different. Needs to use `-Force` since `-f`
- # is ambiguous (possible matches include: -Filter -Force).
- - name: "[Windows]: Clean local artifacts"
- if: contains(matrix.os, 'win')
- run: rm -r -Force ~/.m2/repository/gg/jte
\ No newline at end of file
diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml
index db364432..0d92b6f3 100644
--- a/.github/workflows/gradle-wrapper-validation.yml
+++ b/.github/workflows/gradle-wrapper-validation.yml
@@ -18,4 +18,4 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- - uses: gradle/wrapper-validation-action@v3
+ - uses: gradle/actions/wrapper-validation@v4
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index da56c2c6..24c76997 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -13,13 +13,23 @@ on:
- main
jobs:
+ # From https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions#example-returning-a-json-object
+ build-matrix:
+ runs-on: ubuntu-latest
+ outputs:
+ matrix: ${{ steps.set-matrix.outputs.matrix }}
+ steps:
+ - id: set-matrix
+ run: |
+ echo "matrix={ \"os\": [\"windows-2022\", \"macOS-latest\", \"ubuntu-latest\"], \"java_version\": [17] }" >> $GITHUB_OUTPUT
+
build:
+ name: Build / JDK ${{ matrix.java_version }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
+ needs: build-matrix
strategy:
fail-fast: false
- matrix:
- java_version: [17]
- os: [windows-2022, macOS-latest, ubuntu-latest]
+ matrix: ${{ fromJson(needs.build-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
@@ -29,26 +39,37 @@ jobs:
java-version: ${{ matrix.java_version }}
distribution: 'temurin'
cache: 'maven'
+ - name: Make Maven Wrapper executable
+ if: contains(matrix.os, 'win') == false
+ run: chmod +x ./mvnw
+ - name: Build with Maven
+ run: ./mvnw verify --file pom.xml
- # Adapted from https://github.com/actions/cache/blob/v3/examples.md#java---gradle
- - name: Cache local Gradle
- id: gradleCache
- uses: actions/cache@v4
+ test-gradle-plugin:
+ name: Test / Gradle / JDK ${{ matrix.java_version }} / ${{ matrix.os }}
+ runs-on: ${{ matrix.os }}
+ needs:
+ - build-matrix
+ - build
+ strategy:
+ fail-fast: false
+ matrix: ${{ fromJson(needs.build-matrix.outputs.matrix) }}
+ steps:
+ - uses: actions/checkout@v4
+ - name: Set up JDK ${{ matrix.java_version }}
+ uses: actions/setup-java@v4
with:
- path: |
- ~/.gradle/caches
- ~/.gradle/wrapper
- key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
- restore-keys: |
- ${{ runner.os }}-gradle-
-
+ java-version: ${{ matrix.java_version }}
+ distribution: 'temurin'
+ cache: 'maven'
+ - uses: ./.github/gradle-cache
+ with:
+ key: "gradle"
- name: Make Maven Wrapper executable
if: contains(matrix.os, 'win') == false
run: chmod +x ./mvnw
- name: Build with Maven
- run: ./mvnw install --file pom.xml
- - name: Test Kotlin 2.0
- run: ./mvnw test --file pom.xml --projects jte-kotlin --also-make --activate-profiles kotlin-2.0
+ run: ./mvnw install --file pom.xml -DskipTests=true
- name: Build Gradle Plugin
run: cd jte-gradle-plugin && ./gradlew publishToMavenLocal
- name: Run all the Gradle Plugin tests
@@ -63,25 +84,80 @@ jobs:
with:
name: failing-test-report
path: test/gradle-test-wrapper/build/reports/tests/test/**/*
+ - uses: ./.github/prepare-cache-action
- # This prevents local published artifacts from be added to GH Actions cache
- - name: Clean local artifacts
- if: contains(matrix.os, 'win') == false
- run: rm -rvf ~/.m2/repository/gg/jte
+ test-graal:
+ name: Test / Graal / JDK ${{ matrix.java_version }} / ${{ matrix.os }}
+ runs-on: ${{ matrix.os }}
+ needs:
+ - build-matrix
+ - build
+ strategy:
+ fail-fast: false
+ matrix: ${{ fromJson(needs.build-matrix.outputs.matrix) }}
- # `rm` syntax for Windows is different. Needs to use `-Force` since `-f`
- # is ambiguous (possible matches include: -Filter -Force).
- - name: "[Windows]: Clean local artifacts"
- if: contains(matrix.os, 'win')
- run: rm -r -Force ~/.m2/repository/gg/jte
+ steps:
+ - uses: actions/checkout@v4
+ - uses: graalvm/setup-graalvm@v1
+ with:
+ distribution: 'graalvm'
+ java-version: ${{ matrix.java_version }}
+ components: 'native-image'
+ github-token: ${{ secrets.GITHUB_TOKEN }}
+ cache: 'maven'
+ - uses: ./.github/gradle-cache
+ with:
+ key: "gradle-graalvm"
+ - name: Make Maven Wrapper executable
+ if: contains(matrix.os, 'win') == false
+ run: chmod +x ./mvnw
+ - name: Build with Maven
+ run: ./mvnw install --file pom.xml -DskipTests=true
+ - name: Build Gradle Plugin
+ run: cd jte-gradle-plugin && ./gradlew publishToMavenLocal
+ - name: Test Gradle Plugin Generate with conventions
+ run: cd test/jte-runtime-cp-test-gradle-convention && ./gradlew check nativeTest
+ - name: Stop Gradle Daemon
+ if: ${{ always() }}
+ run: cd test/jte-runtime-cp-test-gradle-convention && ./gradlew --stop
+ - uses: ./.github/prepare-cache-action
+ test-kotlin:
+ name: Test / Kotlin / ${{ matrix.kotlin-profile }}
+ runs-on: ubuntu-latest
+ needs:
+ - build
+ strategy:
+ fail-fast: false
+ matrix:
+ kotlin-profile: ["kotlin-1.9", "kotlin-2.0", "kotlin-2.1"]
+ steps:
+ - uses: actions/checkout@v4
+ - name: Set up JDK 17
+ uses: actions/setup-java@v4
+ with:
+ java-version: 17
+ distribution: 'temurin'
+ cache: 'maven'
+ - name: Make Maven Wrapper executable
+ run: chmod +x ./mvnw
+ - name: Build with Maven
+ run: ./mvnw install --file pom.xml -DskipTests=true
+ - name: Test Kotlin Profile ${{ matrix.kotlin-profile }}
+ run: ./mvnw test --file pom.xml --projects jte-kotlin --also-make --activate-profiles ${{ matrix.kotlin-profile }}
+ - uses: ./.github/prepare-cache-action
coverage:
+ name: Test / Coverage
# Do not run coverage for forks since they cannot upload
# the results to codecov. For reference, see:
# https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution#example-only-run-job-for-specific-repository
if: github.repository == 'casid/jte'
runs-on: ubuntu-latest
+ needs:
+ - test-gradle-plugin
+ - test-kotlin
+ - test-graal
steps:
- uses: actions/checkout@v4
- name: Set up JDK
@@ -94,7 +170,7 @@ jobs:
if: contains(matrix.os, 'win') == false
run: chmod +x ./mvnw
- name: Build with Maven
- run: ./mvnw verify --file pom.xml -Pcoverage
+ run: ./mvnw verify --file pom.xml -Pcoverage,kotlin-1.9
- name: Upload coverage report
uses: codecov/codecov-action@v4
env:
diff --git a/jte-kotlin/pom.xml b/jte-kotlin/pom.xml
index 59a0fede..9ab1eeac 100644
--- a/jte-kotlin/pom.xml
+++ b/jte-kotlin/pom.xml
@@ -16,7 +16,6 @@
false
false
- 1.9.10
@@ -50,12 +49,27 @@
+
+ kotlin-1.9
+
+ true
+
+
+ 1.9.10
+
+
kotlin-2.0
2.0.20
+
+ kotlin-2.1
+
+ 2.1.0
+
+
\ No newline at end of file
diff --git a/jte-kotlin/src/main/java/gg/jte/compiler/kotlin/KotlinClassCompiler.java b/jte-kotlin/src/main/java/gg/jte/compiler/kotlin/KotlinClassCompiler.java
index 58f4d3a7..74ff6c67 100644
--- a/jte-kotlin/src/main/java/gg/jte/compiler/kotlin/KotlinClassCompiler.java
+++ b/jte-kotlin/src/main/java/gg/jte/compiler/kotlin/KotlinClassCompiler.java
@@ -39,7 +39,7 @@ public void compile(String[] files, List classPath, TemplateConfig confi
K2JVMCompiler compiler = new K2JVMCompiler();
SimpleKotlinCompilerMessageCollector messageCollector = new SimpleKotlinCompilerMessageCollector(templateByClassName, config.packageName);
- ExitCode exitCode = compiler.exec(messageCollector, new Services.Builder().build(), compilerArguments);
+ ExitCode exitCode = compiler.exec(messageCollector, Services.EMPTY, compilerArguments);
if (exitCode != ExitCode.OK && exitCode != ExitCode.COMPILATION_ERROR) {
throw new TemplateException(messageCollector.getErrorMessage());
diff --git a/test/jte-runtime-test-kotlin/pom.xml b/test/jte-runtime-test-kotlin/pom.xml
index 205f4595..68e1d039 100644
--- a/test/jte-runtime-test-kotlin/pom.xml
+++ b/test/jte-runtime-test-kotlin/pom.xml
@@ -14,7 +14,6 @@
true
true
0.8.10
- 1.9.10
@@ -69,6 +68,28 @@
+
+
+ kotlin-1.9
+
+ true
+
+
+ 1.9.10
+
+
+
+ kotlin-2.0
+
+ 2.0.20
+
+
+
+ kotlin-2.1
+
+ 2.1.0
+
+