Skip to content

Commit f9de693

Browse files
committed
Add graal build instructions
- Relates #527
1 parent 0ef394c commit f9de693

File tree

1 file changed

+52
-15
lines changed

1 file changed

+52
-15
lines changed

spring-shell-docs/src/main/asciidoc/using-shell-building.adoc

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,67 @@ This section covers how to build a Spring Shell application.
66
[[native]]
77
=== Native Support
88

9-
Version 2.1.x includes experimental support for compiling Spring Shell applications
10-
into native applications with GraalVM and Spring Native. Because the underlying JLine
11-
library works with GraalVM, most things should just work.
9+
Support for compiling _Spring Shell_ application into a _GraalVM_ binary
10+
mostly comes from _Spring Framework_ and _Spring Boot_ where feature is
11+
called _AOT_. Ahead of Time means that application context is prepared
12+
during the compilation time to being ready for _GraalVM_ generation.
1213

13-
You can compile the project with a native profile to get a native application:
14+
Building atop of _AOT_ features from a framework _Spring Shell_ has its
15+
own _GraalVM_ configuration providing hints what should exist in
16+
a binary. Usually trouble comes from a 3rd party libraries which doesn't
17+
yet contain _GraalVM_ related configurations or those configurations
18+
are incomplete.
19+
20+
IMPORTANT: It is requred to use _GraalVM Reachability Metadata Repository_ which
21+
provides some missing hints for 3rd party libraries. Also you need to have
22+
_GraalVM_ installed and `JAVA_HOME` pointing to that.
23+
24+
For _gradle_ add graalvm's native plugin and configure metadata repository.
1425

1526
====
27+
[source, groovy, subs=attributes+]
1628
----
17-
$ ./mvnw clean package -Pnative
29+
plugins {
30+
id 'org.graalvm.buildtools.native' version '0.9.13'
31+
}
32+
33+
graalvmNative {
34+
metadataRepository {
35+
version = "0.1.2"
36+
}
37+
}
1838
----
1939
====
2040

21-
You can then run the application in either interactive or non-interactive mode:
41+
When gradle build is run with `./gradlew nativeCompile` you should get binary
42+
under `build/native/nativeCompile` directory.
43+
44+
For `maven` use `spring-boot-starter-parent` as parent and you'll get `native`
45+
profile which can be used to do a compilation. You need to configure metadata repository
2246

2347
====
48+
[source, xml, subs=attributes+]
2449
----
25-
$ ./spring-shell-samples/target/spring-shell-samples help
26-
AVAILABLE COMMANDS
27-
28-
Built-In Commands
29-
completion bash: Generate bash completion script
30-
help: Display help about available commands.
31-
history: Display or save the history of previously run commands
32-
script: Read and execute commands from a file.
33-
...
50+
<build>
51+
<pluginManagement>
52+
<plugins>
53+
<plugin>
54+
<groupId>org.graalvm.buildtools</groupId>
55+
<artifactId>native-maven-plugin</artifactId>
56+
<configuration>
57+
<metadataRepository>
58+
<version>0.1.2</version>
59+
</metadataRepository>
60+
</configuration>
61+
</plugin>
62+
</plugins>
63+
</pluginManagement>
64+
</build>
3465
----
3566
====
67+
68+
When maven build is run with `./mvnw package -Pnative` you should get binary
69+
under `target` directory.
70+
71+
If everything went well this binary can be run as is instead of executing
72+
boot application jar via jvm.

0 commit comments

Comments
 (0)