Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/agilevisionorganization/graalvm-workshop
https://github.com/agilevisionorganization/graalvm-workshop
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/agilevisionorganization/graalvm-workshop
- Owner: AgileVisionOrganization
- Created: 2021-12-08T18:25:32.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-12-05T22:39:56.000Z (about 1 year ago)
- Last Synced: 2024-11-30T15:10:41.987Z (about 1 month ago)
- Language: Handlebars
- Size: 12.7 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GraalVM Workshop
## Prepare development environment
### Local GraalVM
1. Install [SDKMAN](https://sdkman.io/install)
2. Install GraalVM 21.2 r11 `sdk install java 21.2.0.r11-grl`
3. Use GraalVm `sdk use java 21.2.0.r11-grl`
4. Install native-image extensions `gu install native-image`### Docker Compose
Execute `docker-compose run --rm --service-ports graalvm` in the project root directory### Docker
1. ```docker run -it --rm -v `pwd`:/root/project ghcr.io/graalvm/graalvm-ce:java11-21.2 bash```
2. `cd /root/project/`
3. `gu install native-image`
4. Install [Maven](https://maven.apache.org/install.html)## "Vanilla" Java project
### Compile and run using JDK
1. `mvn clean package`
2. `time java -jar target/generate-html-email-1.0-SNAPSHOT-jar-with-dependencies.jar`### Compile and run native-image
1. `native-image -jar target/generate-html-email-1.0-SNAPSHOT-jar-with-dependencies.jar --no-fallback target/generate-html-email`
2. `java -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image -jar target/generate-html-email-1.0-SNAPSHOT-jar-with-dependencies.jar`
3. `time [email protected] ./target/generate-html-email`
4. Configure maven to generate native image
```xml
0.9.7.1
generate-html-email
java_agent
org.codehaus.mojo
exec-maven-plugin
1.2
java
-agentlib:native-image-agent=config-output-dir=./src/main/resources/META-INF/native-image/
-classpath
${app.main.class}
native
org.graalvm.buildtools
native-maven-plugin
${native.maven.plugin.version}
true
build-native
build
package
false
${exe.file.name}
${app.main.class}
--no-fallback
--report-unsupported-elements-at-runtime
--allow-incomplete-classpath
```
5. `mvn clean package exec:exec -Pjava_agent`
6. `mvn clean package -Pnative`## Spring Boot application
### Generate base spring boot project
1. Generate base project `spring-generate-html` using [Spring Initializr](https://start.spring.io/) or use intellij idea.
2. Select `spring-boot-starter-web` and `lombok` as dependency with spring boot `2.5.6`, java 11
3. Build java application `mvn clean package`
4. Run application `java -jar target/spring-generate-html-0.0.1-SNAPSHOT.jar`### Build to native image with Native Build Tools
1. Add to pom.xnl:```xml
0.10.5
org.springframework.experimental
spring-native
${spring.native}
native
org.springframework.experimental
spring-aot-maven-plugin
${spring.native}
test-generate
test-generate
generate
generate
org.graalvm.buildtools
native-maven-plugin
0.9.4
test-native
test
test
build-native
build
package
org.springframework.boot
spring-boot-maven-plugin
exec
spring-release
Spring release
https://repo.spring.io/release
spring-release
Spring release
https://repo.spring.io/release
```
2. Build to native `mvn clean -Pnative -DskipTests package`
3. Run native application `./target/spring-generate-html`
4. Use NativeHint or `java -DspringAot=true -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image -jar target/spring-generate-html-0.0.1-SNAPSHOT-exec.jar`### Build to native image with Buildpacks
```xml
native-build-image
org.springframework.experimental
spring-aot-maven-plugin
${spring.native}
test-generate
test-generate
generate
generate
org.springframework.boot
spring-boot-maven-plugin
paketobuildpacks/builder:tiny
true
gcr.io/paketo-buildpacks/java-native-image:5.5.0
```