daemontus / gradle-graal-truffle-plugins

Defines several Gradle plugins for interacting with Graal compiler and development of Truffle languages.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

org.graalvm.plugin.compiler no longer published in Gradle Plugin repository

ridango-taavi opened this issue · comments

Hi!

Starting from today (or perhaps a couple of days ago), the compiler plugin seems to have been taken down from Gradle Plugin repository (https://plugins.gradle.org/plugin/org.graalvm.plugin.compiler).

Could it be that this plugin no longer recommended and if not, then what are the possible alternatives?

We were using it for running Javascript with stock JDK (https://github.com/graalvm/graal-js-jdk11-gradle-demo)

It seems that the only issue is that the compiler still needs to be added to upgrade module path.

There is a new demo, where instead of a plugin, this is performed manually: https://github.com/graalvm/polyglot-embedding-demo/blob/main/build.gradle.kts

I didnt manage to get it working exactly like it was done in this new demo (its possible because I use Groovy, but the demo uses Kotlin Script - or it might just be related to my poor Gradle skills), but I did manage to make it work like this:

ext.graalVersion = '22.3.3'
ext.graalCompilerPath = "${buildDir}/graalCompiler".toString()

configurations {
    compilerClasspath {
        description = "Graal compiler and its dependencies."
        canBeResolved = true
    }
}

dependencies {
    compilerClasspath "org.graalvm.compiler:compiler:$graalVersion"
}

tasks.register('prepareCompiler', Copy) {
    group = 'graal'
}

afterEvaluate {
    tasks.named('prepareCompiler', Copy, {
        from(configurations.named('compilerClasspath', Configuration).get().getFiles())
        into(graalCompilerPath)
    })
}

tasks.matching { it instanceof JavaForkOptions }.configureEach { task ->
    task.dependsOn('prepareCompiler')

    (task as JavaForkOptions).jvmArgs = [
        "-XX:+UnlockExperimentalVMOptions",
        "-XX:+EnableJVMCI",
        "--upgrade-module-path=${graalCompilerPath}"
    ]
}

I did it with an extra task because I need this same output for building a Docker image (otherwise probably not needed).

I guess we can consider this closed as it seems that there arent a lot of people using this plugin and this workaround is good enough for me.

Great, thank you for sorting it out!