generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,086 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Test GraalWasm Starter | ||
on: | ||
push: | ||
paths: | ||
- 'graalwasm/graalwasm-starter/**' | ||
- '.github/workflows/graalwasm-starter.yml' | ||
pull_request: | ||
paths: | ||
- 'graalwasm/graalwasm-starter/**' | ||
- '.github/workflows/graalwasm-starter.yml' | ||
workflow_dispatch: | ||
permissions: | ||
contents: read | ||
jobs: | ||
run: | ||
name: 'graalwasm-starter' | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: graalvm/setup-graalvm@v1 | ||
with: | ||
java-version: '23.0.0' | ||
distribution: 'graalvm' | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
cache: 'maven' | ||
native-image-job-reports: 'true' | ||
- name: Build, test, and run 'graalwasm-starter' using Maven | ||
run: | | ||
cd graalwasm/graalwasm-starter | ||
./mvnw --no-transfer-progress test | ||
./mvnw --no-transfer-progress exec:java | ||
- name: Build, test, and run 'graalwasm-starter' using Gradle | ||
run: | | ||
cd graalwasm/graalwasm-starter | ||
./gradlew test | ||
./gradlew run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# GraalWasm Demos and Guides | ||
|
||
This directory contains demo applications and guides for [GraalWasm](https://www.graalvm.org/webassembly/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# | ||
# https://help.github.com/articles/dealing-with-line-endings/ | ||
# | ||
# Linux start script should use lf | ||
/gradlew text eol=lf | ||
|
||
# These are Windows script files and should use crlf | ||
*.bat text eol=crlf | ||
|
||
# Binary files should be left untouched | ||
*.jar binary | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Ignore Gradle project-specific cache directory | ||
.gradle | ||
|
||
# Ignore Gradle build output directory | ||
build | ||
|
||
# Ignore maven build output directory | ||
target |
19 changes: 19 additions & 0 deletions
19
graalwasm/graalwasm-starter/.mvn/wrapper/maven-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
wrapperVersion=3.3.2 | ||
distributionType=only-script | ||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# GraalWasm Quick Start | ||
|
||
A minimal Java application that embeds a WebAssembly module with GraalWasm. | ||
|
||
## Preparation | ||
|
||
Install GraalVM for JDK 23 and set the value of `JAVA_HOME` accordingly. | ||
We recommend using [SDKMAN!](https://sdkman.io/). (For other download options, see [GraalVM Downloads](https://www.graalvm.org/downloads/).) | ||
|
||
```bash | ||
sdk install java 23-graal | ||
``` | ||
|
||
## Run the Application Using Maven | ||
|
||
To build and test the demo, run: | ||
|
||
```bash | ||
./mvnw test | ||
``` | ||
|
||
To execute the main method, run: | ||
|
||
```bash | ||
./mvnw exec:java | ||
``` | ||
|
||
## Run the Application Using Gradle | ||
|
||
To build and test the demo, run: | ||
|
||
```bash | ||
./gradlew test | ||
``` | ||
|
||
To execute the main method, run: | ||
|
||
```bash | ||
./gradlew run | ||
``` | ||
|
||
## Implementation Details | ||
|
||
The WebAssembly is stored in the resource file `add-two.wasm`. | ||
You can examine its textual representation in the resource file `add-two.wat`. | ||
If you want to experiment with and tweak the WebAssembly module, you will need to rebuild the `add-two.wasm` file from the `add-two.wat` file. | ||
For that, you can use the `wat2wasm` tool from the [wabt toolkit](https://github.com/WebAssembly/wabt). | ||
You can also use [this web app](https://webassembly.github.io/wabt/demo/wat2wasm/) to run `wat2wasm` in your browser instead of installing `wabt`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
plugins { | ||
// Apply the application plugin to add support for building a CLI application in Java. | ||
application | ||
} | ||
|
||
repositories { | ||
// Use Maven Central for resolving dependencies. | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation("org.graalvm.polyglot:polyglot:24.1.0") | ||
implementation("org.graalvm.polyglot:wasm:24.1.0") | ||
|
||
// Use JUnit Jupiter for testing. | ||
testImplementation("org.junit.jupiter:junit-jupiter:5.11.0") | ||
|
||
testRuntimeOnly("org.junit.platform:junit-platform-launcher") | ||
} | ||
|
||
application { | ||
// Define the main class for the application. | ||
mainClass = "com.example.App" | ||
} | ||
|
||
tasks.named<Test>("test") { | ||
// Use JUnit Platform for unit tests. | ||
useJUnitPlatform() | ||
} |
Binary file not shown.
7 changes: 7 additions & 0 deletions
7
graalwasm/graalwasm-starter/gradle/wrapper/gradle-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.