Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add support to Kotlin 2.1 #411

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/gradle-cache/action.yml
Original file line number Diff line number Diff line change
@@ -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 }}-
17 changes: 17 additions & 0 deletions .github/prepare-cache-action/action.yml
Original file line number Diff line number Diff line change
@@ -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
68 changes: 0 additions & 68 deletions .github/workflows/graalvm.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
130 changes: 103 additions & 27 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down
16 changes: 15 additions & 1 deletion jte-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<properties>
<maven.deploy.skip>false</maven.deploy.skip>
<skipNexusStagingDeployMojo>false</skipNexusStagingDeployMojo>
<kotlin.version>1.9.10</kotlin.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -50,12 +49,27 @@
</build>

<profiles>
<profile>
<id>kotlin-1.9</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<kotlin.version>1.9.10</kotlin.version>
</properties>
</profile>
<profile>
<id>kotlin-2.0</id>
<properties>
<kotlin.version>2.0.20</kotlin.version>
</properties>
</profile>
<profile>
<id>kotlin-2.1</id>
<properties>
<kotlin.version>2.1.0</kotlin.version>
</properties>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void compile(String[] files, List<String> 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());
Expand Down
23 changes: 22 additions & 1 deletion test/jte-runtime-test-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<maven.deploy.skip>true</maven.deploy.skip>
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
<jacoco.version>0.8.10</jacoco.version>
<kotlin.version>1.9.10</kotlin.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -69,6 +68,28 @@
</plugins>
</build>
</profile>
<!-- Kotlin versions -->
<profile>
<id>kotlin-1.9</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<kotlin.version>1.9.10</kotlin.version>
</properties>
</profile>
<profile>
<id>kotlin-2.0</id>
<properties>
<kotlin.version>2.0.20</kotlin.version>
</properties>
</profile>
<profile>
<id>kotlin-2.1</id>
<properties>
<kotlin.version>2.1.0</kotlin.version>
</properties>
</profile>
</profiles>

<build>
Expand Down
Loading