Skip to content

Commit 00027ff

Browse files
committed
Use new Native Image Maven plugin properties to configure the build process.
1 parent 1e7e987 commit 00027ff

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ in Rosetta.
125125
## Building the Native Image Playground
126126

127127
The project's Maven configuration is split into multiple profiles, allowing you to pick the type of image you would
128-
like. The list of profiles are:
128+
like. The list of profiles is:
129129

130130
* native-image: A standalone executable written in Java
131131
* native-library: A shared library written in Java
@@ -136,12 +136,24 @@ like. The list of profiles are:
136136
* benchmark-setup: Fetches and builds the Google Benchmark library for running benchmarks
137137
* benchmark: Runs benchmarks comparing `@CEntryPoint` and JNI Invocation API calls
138138

139+
Additionally, the project uses some configuration values that allow you to customize the Native Image invocation. They
140+
can be configured at invocation time via the `-D` flag to the `mvn` command. The list of properties is:
141+
142+
* native.image.debug: Build a native image with debug symbols (Boolean; default: false)
143+
* native.image.verbose: Build a native image verbosely (Boolean; default: false)
144+
139145
To build any of these profiles, you run:
140146

141147
```
142148
$ mvn -P <profile_name> -D skipTests=true clean package
143149
```
144150

151+
To build a profile with verbose logging from Native Image, you run:
152+
153+
```
154+
$ mvn -P <profile_name> -D skipTests=true -D native.image.verbose=true clean package
155+
```
156+
145157
Maven stores the compiled artifacts in the `target/` directory. The `clean` option in the build command will delete
146158
the `target/` directory before building the new package with _native-image_. This will avoid any leftover artifacts
147159
from other profiles conflicting with your latest build. But, if you need to keep the old `target/` around for some

pom.xml

+12
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
<native.maven.plugin.version>0.9.20</native.maven.plugin.version>
1919
<graalvm.version>22.3.1</graalvm.version>
2020
<sis.version>1.0</sis.version>
21+
<native.image.debug>false</native.image.debug>
22+
<native.image.verbose>false</native.image.verbose>
2123
</properties>
2224

2325
<dependencies>
@@ -117,6 +119,8 @@
117119
</executions>
118120
<configuration>
119121
<mainClass>com.nirvdrum.truffleruby.NativeImage</mainClass>
122+
<debug>${native.image.debug}</debug>
123+
<verbose>${native.image.verbose}</verbose>
120124
<imageName>native-image-playground</imageName>
121125
</configuration>
122126
</plugin>
@@ -156,7 +160,9 @@
156160
<configuration>
157161
<mainClass>com.nirvdrum.truffleruby.NativeLibrary</mainClass>
158162
<imageName>lib${launcher.name}</imageName>
163+
<debug>${native.image.debug}</debug>
159164
<sharedLibrary>true</sharedLibrary>
165+
<verbose>${native.image.verbose}</verbose>
160166
<buildArgs>-H:+ParseRuntimeOptions</buildArgs>
161167
</configuration>
162168
</plugin>
@@ -223,7 +229,9 @@
223229
<configuration>
224230
<mainClass>com.nirvdrum.truffleruby.NativeLibraryRuby</mainClass>
225231
<imageName>lib${launcher.name}</imageName>
232+
<debug>${native.image.debug}</debug>
226233
<sharedLibrary>true</sharedLibrary>
234+
<verbose>${native.image.verbose}</verbose>
227235
<buildArgs>--language:ruby</buildArgs>
228236
</configuration>
229237
</plugin>
@@ -378,7 +386,9 @@
378386
<configuration>
379387
<mainClass>com.nirvdrum.truffleruby.NativeLibraryRuby</mainClass>
380388
<imageName>lib${launcher.name}</imageName>
389+
<debug>${native.image.debug}</debug>
381390
<sharedLibrary>true</sharedLibrary>
391+
<verbose>${native.image.verbose}</verbose>
382392
<buildArgs>--language:js --language:ruby -H:JNIConfigurationFiles=${project.build.sourceDirectory}/../resources/native-jni-config.json</buildArgs>
383393
</configuration>
384394
</plugin>
@@ -485,7 +495,9 @@
485495
<configuration>
486496
<mainClass>com.nirvdrum.truffleruby.NativeLibraryRuby</mainClass>
487497
<imageName>lib${launcher.name}</imageName>
498+
<debug>${native.image.debug}</debug>
488499
<sharedLibrary>true</sharedLibrary>
500+
<verbose>${native.image.verbose}</verbose>
489501
<buildArgs>--language:js --language:ruby -H:JNIConfigurationFiles=${project.build.sourceDirectory}/../resources/native-jni-config.json</buildArgs>
490502
</configuration>
491503
</plugin>

0 commit comments

Comments
 (0)