Skip to content
Open
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
42 changes: 42 additions & 0 deletions .github/workflows/graalwasm-micronaut-excelize.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Test GraalWasm Micronaut Excelize Demo

on:
push:
paths:
- 'graalwasm/graalwasm-micronaut-excelice/**'
- '.github/workflows/graalwasm-micronaut-excelice.yml'
pull_request:
paths:
- 'graalwasm/graalwasm-micronaut-excelice/**'
- '.github/workflows/graalwasm-micronaut-excelice.yml'
workflow_dispatch:

permissions:
contents: read

jobs:
run:
name: 'graalwasm-micronaut-excelice'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4

- uses: graalvm/setup-graalvm@v1
with:
java-version: '24.0.0'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
cache: 'maven'

- name: Package 'graalwasm-micronaut-excelice'
run: |
cd graalwasm/graalwasm-micronaut-excelice
./mvnw --no-transfer-progress clean package

- name: Run and Test Excelize App
run: |
cd graalwasm/graalwasm-micronaut-excelice
./mvnw test &
sleep 10
curl --fail-with-body --silent --dump-header - -o /dev/null http://localhost:8080
15 changes: 15 additions & 0 deletions graalwasm/graalwasm-micronaut-excelize/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Thumbs.db
.DS_Store
.gradle
build/
target/
out/
.micronaut/
.idea
*.iml
*.ipr
*.iws
.project
.settings
.classpath
.factorypath
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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
#
# https://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.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
39 changes: 39 additions & 0 deletions graalwasm/graalwasm-micronaut-excelize/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Excelize with GraalWasm Micronaut Demo

This demo illustrates how GraalWasm can be used to embed [excelize-wasm](https://github.com/xuri/excelize-wasm/), a WebAssembly build of the Go [Excelize](https://github.com/xuri/excelize) library for reading and writing Microsoft Excel™ spreadsheets.
The demo also uses GraalJS to access the Excelize module through the WebAssembly JavaScript API.

## Preparation

Install GraalVM for JDK 24 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 24-graal
```

## Run the Application

To start the demo, simply run:

```bash
./mvnw package mn:run
```

When the demo runs, open the following URLs in a browser:

- http://localhost:8080/


This interface offers two core features:

Import Excel to Database – Upload an Excel (.xlsx) file to parse and store its contents in the backend database.
Export Database to Excel – Retrieve data from the database and download it as a structured Excel (.xlsx) file.
Ideal for seamless data management via the browser.




## Implementation Details

The [`Controller`](src/main/java/com/example/Controller.java) uses a [`Service`](src/main/java/com/example/ExcelizeService.java) That integrates the Excelize library with Micronaut and GraalVM to generate and read Excel files using WebAssembly (WASM) and JavaScript. It loads necessary JS and WASM files, executes JavaScript to manipulate Excel data, and reads the content back into a Java application. The results are saved as Excel files or processed into Java objects.

37 changes: 37 additions & 0 deletions graalwasm/graalwasm-micronaut-excelize/aot-jar.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# AOT configuration properties for jar packaging
# Please review carefully the optimizations enabled below
# Check https://micronaut-projects.github.io/micronaut-aot/latest/guide/ for more details

# Caches environment property values: environment properties will be deemed immutable after application startup.
cached.environment.enabled=true

# Precomputes Micronaut configuration property keys from the current environment variables
precompute.environment.properties.enabled=true

# Replaces logback.xml with a pure Java configuration
logback.xml.to.java.enabled=true

# Converts YAML configuration files to Java configuration
yaml.to.java.config.enabled=true

# Scans for service types ahead-of-time, avoiding classpath scanning at startup
serviceloading.jit.enabled=true

# Scans reactive types at build time instead of runtime
scan.reactive.types.enabled=true

# Deduces the environment at build time instead of runtime
deduce.environment.enabled=true

# Checks for the existence of some types at build time instead of runtime
known.missing.types.enabled=true

# Precomputes property sources at build time
sealed.property.source.enabled=true

# The list of service types to be scanned (comma separated)
service.types=io.micronaut.context.env.PropertySourceLoader,io.micronaut.inject.BeanConfiguration,io.micronaut.inject.BeanDefinitionReference,io.micronaut.http.HttpRequestFactory,io.micronaut.http.HttpResponseFactory,io.micronaut.core.beans.BeanIntrospectionReference,io.micronaut.core.convert.TypeConverterRegistrar,io.micronaut.context.env.PropertyExpressionResolver

# A list of types that the AOT analyzer needs to check for existence (comma separated)
known.missing.types.list=io.reactivex.Observable,reactor.core.publisher.Flux,kotlinx.coroutines.flow.Flow,io.reactivex.rxjava3.core.Flowable,io.reactivex.rxjava3.core.Observable,io.reactivex.Single,reactor.core.publisher.Mono,io.reactivex.Maybe,io.reactivex.rxjava3.core.Single,io.reactivex.rxjava3.core.Maybe,io.reactivex.Completable,io.reactivex.rxjava3.core.Completable,io.methvin.watchservice.MacOSXListeningWatchService,io.micronaut.core.async.publisher.CompletableFuturePublisher,io.micronaut.core.async.publisher.Publishers.JustPublisher,io.micronaut.core.async.subscriber.Completable

233 changes: 233 additions & 0 deletions graalwasm/graalwasm-micronaut-excelize/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>micronaut-parent</artifactId>
<groupId>io.micronaut.platform</groupId>
<version>4.7.6</version>
<relativePath>../pom.xml/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>micronautdemo</artifactId>
<packaging>${packaging}</packaging>
<version>0.1</version>
<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer>
<mainClass>org.openjdk.jmh.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.micronaut.maven</groupId>
<artifactId>micronaut-maven-plugin</artifactId>
<configuration>
<configFile>aot-${packaging}.properties</configFile>
</configuration>
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject-java</artifactId>
<version>${micronaut.core.version}</version>
</path>
<path>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.37</version>
</path>
<path>
<groupId>io.micronaut.data</groupId>
<artifactId>micronaut-data-processor</artifactId>
<version>${micronaut.data.version}</version>
<exclusions>
<exclusion>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject</artifactId>
</exclusion>
</exclusions>
</path>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-graal</artifactId>
<version>${micronaut.core.version}</version>
</path>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-http-validation</artifactId>
<version>${micronaut.core.version}</version>
</path>
<path>
<groupId>io.micronaut.serde</groupId>
<artifactId>micronaut-serde-processor</artifactId>
<version>${micronaut.serialization.version}</version>
<exclusions>
<exclusion>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject</artifactId>
</exclusion>
</exclusions>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-Amicronaut.processing.group=com.example</arg>
<arg>-Amicronaut.processing.module=micronautdemo</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>software.xdev</groupId>
<artifactId>music-maven-plugin</artifactId>
<version>1.0.3</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>music</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<musicSource>
<uri>https://incompetech.com/music/royalty-free/mp3-royaltyfree/Corncob.mp3</uri>
</musicSource>
</sources>
<shuffle>true</shuffle>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-http-client</artifactId>
<version>4.7.14</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>micronaut-http-client-core</artifactId>
<groupId>io.micronaut</groupId>
</exclusion>
<exclusion>
<artifactId>micronaut-websocket</artifactId>
<groupId>io.micronaut</groupId>
</exclusion>
<exclusion>
<artifactId>netty-handler-proxy</artifactId>
<groupId>io.netty</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.micronaut.test</groupId>
<artifactId>micronaut-test-junit5</artifactId>
<version>4.6.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>micronaut-test-core</artifactId>
<groupId>io.micronaut.test</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.11.3</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>opentest4j</artifactId>
<groupId>org.opentest4j</groupId>
</exclusion>
<exclusion>
<artifactId>junit-platform-commons</artifactId>
<groupId>org.junit.platform</groupId>
</exclusion>
<exclusion>
<artifactId>apiguardian-api</artifactId>
<groupId>org.apiguardian</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.11.3</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>junit-platform-engine</artifactId>
<groupId>org.junit.platform</groupId>
</exclusion>
<exclusion>
<artifactId>apiguardian-api</artifactId>
<groupId>org.apiguardian</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.graalvm.polyglot</groupId>
<artifactId>wasm</artifactId>
<version>24.2.1</version>
<type>pom</type>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>wasm</artifactId>
<groupId>org.graalvm.wasm</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.graalvm.polyglot</groupId>
<artifactId>js</artifactId>
<version>24.2.1</version>
<type>pom</type>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>js</artifactId>
<groupId>org.graalvm.js</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<properties>
<micronaut.aot.enabled>false</micronaut.aot.enabled>
<exec.mainClass>com.example.Application</exec.mainClass>
<micronaut.aot.packageName>com.example.aot.generated</micronaut.aot.packageName>
<packaging>jar</packaging>
<micronaut.runtime>netty</micronaut.runtime>
<micronaut.version>4.7.6</micronaut.version>
<release.version>21</release.version>
<jdk.version>21</jdk.version>
</properties>
</project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
begin_compilation
name " TruffleHotSpotCompilation-9712[wasm-function:7257]"
method "TruffleHotSpotCompilation-9712[wasm-function:7257]"
date 1750173782634
end_compilation
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading