Skip to content

Commit 2d6d1ef

Browse files
committed
Refactor fortune-demo and move under native-image/antive-build-tools subdirectory
1 parent 3b93e72 commit 2d6d1ef

File tree

27 files changed

+752
-215
lines changed

27 files changed

+752
-215
lines changed
Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
name: fortune-demo
1+
name: native-build-tools-gradle
22
on:
33
push:
44
paths:
5-
- 'fortune-demo/**'
6-
- '.github/workflows/fortune-demo.yml'
5+
- 'native-image/native-build-tools/gradle-plugin/**'
6+
- '.github/workflows/native-build-tools-gradle.yml'
77
pull_request:
88
paths:
9-
- 'fortune-demo/**'
10-
- '.github/workflows/fortune-demo.yml'
9+
- 'native-image/native-build-tools/gradle-plugin/**'
10+
- '.github/workflows/native-build-tools-gradle.yml'
1111
schedule:
1212
- cron: "0 0 1 * *" # run every month
1313
workflow_dispatch:
1414
permissions:
1515
contents: read
1616
jobs:
1717
run:
18-
name: Run 'fortune-demo'
18+
name: Run 'native-build-tools-gradle'
1919
runs-on: ubuntu-latest
2020
timeout-minutes: 30
2121
steps:
@@ -25,11 +25,7 @@ jobs:
2525
java-version: '21'
2626
distribution: 'graalvm'
2727
github-token: ${{ secrets.GITHUB_TOKEN }}
28-
- name: Run 'fortune'
28+
- name: Run 'native-build-tools-gradle'
2929
run: |
30-
cd fortune-demo/fortune-maven
31-
./build.sh
32-
- name: Run 'fortune-gradle'
33-
run: |
34-
cd fortune-demo/fortune-gradle
35-
./build.sh
30+
cd native-image/native-build-tools/gradle-plugin
31+
./run.sh
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: native-build-tools-maven
2+
on:
3+
push:
4+
paths:
5+
- 'native-image/native-build-tools/maven-plugin/**'
6+
- '.github/workflows/native-build-tools-maven.yml'
7+
pull_request:
8+
paths:
9+
- 'native-image/native-build-tools/maven-plugin/**'
10+
- '.github/workflows/native-build-tools-maven.yml'
11+
schedule:
12+
- cron: "0 0 1 * *" # run every month
13+
workflow_dispatch:
14+
permissions:
15+
contents: read
16+
jobs:
17+
run:
18+
name: Run 'native-build-tools-maven'
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 30
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: graalvm/setup-graalvm@v1
24+
with:
25+
java-version: '24-ea'
26+
distribution: 'graalvm'
27+
github-token: ${{ secrets.GITHUB_TOKEN }}
28+
- name: Run 'native-build-tools-maven'
29+
run: |
30+
cd native-image/native-build-tools/maven-plugin
31+
./run.sh

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ cd graalvm-demos
5151
<td align="left" width="30%"><a href="/streams/">streams</a><br><a href="https://github.com/graalvm/graalvm-demos/actions/workflows/streams.yml"><img alt="streams" src="https://github.com/graalvm/graalvm-demos/actions/workflows/streams.yml/badge.svg" /></a></td>
5252
<td align="left" width="70%">Demonstrates how GraalVM efficiently optimizes the Java Streams API application and how to apply PGO<br><strong>Technologies: </strong>Native Image, Native Build Tools Maven Plugin <br><strong>Reference: </strong><a href="https://www.graalvm.org/latest/reference-manual/native-image/guides/optimize-native-executable-with-pgo/">Optimize a Native Executable with Profile-Guided Optimizations</a></td>
5353
</tr>
54-
<tr>
55-
<td align="left" width="30%"><a href="/fortune-demo/">fortune-demo</a><br><a href="https://github.com/graalvm/graalvm-demos/actions/workflows/fortune-demo.yml"><img alt="fortune-demo" src="https://github.com/graalvm/graalvm-demos/actions/workflows/fortune-demo.yml/badge.svg" /></a></td>
56-
<td align="left" width="70%">A fortune teller Unix program. Build a native executable using Gradle or Maven Native Image plugins.<br><strong>Technologies: </strong>Native Image, Native Build Tools Maven plugin <br><strong>Reference: </strong><a href="https://graalvm.github.io/native-build-tools/latest/maven-plugin-quickstart.html">Getting Started with Maven Plugin for GraalVM Native Image</a></td>
57-
</tr>
5854
<tr>
5955
<td align="left" width="30%"><a href="/multithreading-demo/">multithreading-demo</a><br><a href="https://github.com/graalvm/graalvm-demos/actions/workflows/streams.yml"><img alt="streams" src="https://github.com/graalvm/graalvm-demos/actions/workflows/streams.yml/badge.svg" /></a></td>
6056
<td align="left" width="70%">Demonstrates how to optimize a Java application that does synchronous and asynchronous threads execution<br><strong>Technologies: </strong>Native Image Build Reports, Native Build Tools Maven plugin <br><strong>Reference: </strong><a href="https://medium.com/graalvm/making-sense-of-native-image-contents-741a688dab4d">Making sense of Native Image contents</a></td>

fortune-demo/README.md

Lines changed: 0 additions & 64 deletions
This file was deleted.

fortune-demo/fortune-gradle/build.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

fortune-demo/fortune-maven/build.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.

fortune-demo/fortune-maven/pom.xml

Lines changed: 0 additions & 77 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Use Gradle to Build a Java Application from a Java Application
2+
3+
The demo application simulates the traditional [fortune](https://en.wikipedia.org/wiki/Fortune_(Unix)) Unix program.
4+
The data for the fortune phrases is provided by [YourFortune](https://github.com/your-fortune).
5+
6+
The project uses the [Gradle plugin for GraalVM Native Image building](https://graalvm.github.io/native-build-tools/latest/gradle-plugin.html).
7+
8+
## Run the Demo
9+
10+
1. Run the application on JVM:
11+
```bash
12+
./gradlew run
13+
```
14+
2. Build a native executable:
15+
```bash
16+
./gradlew nativeRun
17+
```
18+
The `nativeRun` task compiles the application, invokes `nativeCompile`, and then runs the executable.
19+
3. Re-run the application from the native executable:
20+
```bash
21+
./build/native/nativeCompile/fortune
22+
```
23+
Alternatively, you can execute `./run.sh` to build and run the application.

fortune-demo/fortune-gradle/fortune/build.gradle renamed to native-image/native-build-tools/gradle-plugin/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
plugins {
1010
// Apply the application plugin to add support for building a CLI application in Java.
1111
id 'application'
12-
id 'org.graalvm.buildtools.native' version '0.10.2'
12+
id 'org.graalvm.buildtools.native' version '0.10.3'
1313
}
1414

1515
repositories {
@@ -36,6 +36,7 @@ graalvmNative {
3636
binaries {
3737
main {
3838
imageName.set('fortune')
39+
buildArgs.add("-Ob")
3940
}
4041
}
4142
toolchainDetection = false
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
# Run the application on the JVM
5+
./gradlew clean run
6+
# Build and run a native executable (`nativeRun` compiles the application, invokes `nativeCompile`, and then runs the executable)
7+
./gradlew nativeRun
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip
18+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Use Maven to Build a Java Application from a Java Application
2+
3+
The demo application simulates the traditional [fortune](https://en.wikipedia.org/wiki/Fortune_(Unix)) Unix program.
4+
The data for the fortune phrases is provided by [YourFortune](https://github.com/your-fortune).
5+
6+
The project uses the [Maven plugin for GraalVM Native Image building](https://graalvm.github.io/native-build-tools/latest/maven-plugin.html).
7+
8+
You can find the steps to run this demo in the [Optimize a Native Executable for File Size guide](https://www.graalvm.org/latest/reference-manual/native-image/guides/optimize-for-file-size/).

0 commit comments

Comments
 (0)