Skip to content

Commit 9961248

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

File tree

29 files changed

+780
-228
lines changed

29 files changed

+780
-228
lines changed

.github/workflows/fortune-demo.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: native-build-tools-gradle
2+
on:
3+
push:
4+
paths:
5+
- 'native-image/native-build-tools/gradle-plugin/**'
6+
- '.github/workflows/native-build-tools-gradle.yml'
7+
pull_request:
8+
paths:
9+
- 'native-image/native-build-tools/gradle-plugin/**'
10+
- '.github/workflows/native-build-tools-gradle.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-gradle'
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 30
21+
strategy:
22+
matrix:
23+
java-version: ['21', '24-ea']
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: graalvm/setup-graalvm@v1
27+
with:
28+
java-version: ${{ matrix.java-version }}
29+
distribution: 'graalvm'
30+
github-token: ${{ secrets.GITHUB_TOKEN }}
31+
- name: Run 'native-build-tools-gradle'
32+
run: |
33+
cd native-image/native-build-tools/gradle-plugin
34+
./run.sh
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
strategy:
22+
matrix:
23+
java-version: ['21', '24-ea']
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: graalvm/setup-graalvm@v1
27+
with:
28+
java-version: ${{ matrix.java-version }}
29+
distribution: 'graalvm'
30+
github-token: ${{ secrets.GITHUB_TOKEN }}
31+
- name: Run 'native-build-tools-maven'
32+
run: |
33+
cd native-image/native-build-tools/maven-plugin
34+
./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/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

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

File renamed without changes.

0 commit comments

Comments
 (0)