A POC of writing Gradle tasks using wasm as implementation
This project is a proof-of-concept of Gradle tasks implemented via WASM libraries. In short, this allows writing a Gradle task implementation in any language which supports compiling to WebAssembly.
The project consists of different modules:
The core modules are:
wasm-base-tasks
is a support library providing the base tasks which support WASM binarieswasm-invoker
is a helper library which abstracts the WASM runtime, which can be either wasmer or GraalVMAn annotation processor consists of 2 modules:
wasm-gradle-annotations
defines the annotations of the processorwasm-gradle-processor
is an annotation processor which automatically generates a Gradle task implementation from a "protocol"Then the following modules are there for demo purposes:
rust-lib
is a sample library written in Rust and compiling to WASMassemblyscript-lib
is another library written in AssemblyScript (TypeScript) and compiled to WASMplugin
is a plugin which loads the both sample libraries and uses them in a taskBecause of the rough integration with Rust, this project assumes that you have rust
installed with the proper wasm bindings:
$ rustup target add wasm32-unknown-unknown
% cargo install wasm-gc
The graalFunctionalTest
task also assumes that you have GraalVM installed with the wasm
extension.
The wasm-base-tasks
project defines a class called me.champeau.gradle.wasm.tasks.AbstractWasmTask
which allows declaring a wasm binary as an input and provides a convenience for calling the binary.
It uses wasmer-java or GraalVM to execute the code.
To test the wasmer version, execute ./gradlew functionalTest
To test the GraalVM version, execute ./gradlew graalFunctionalTest