|
3 | 3 |
|
4 | 4 | This section covers how to build a Spring Shell application.
|
5 | 5 |
|
| 6 | +== Starters |
| 7 | + |
| 8 | +. Spring Shell Starters |
| 9 | +[] |
| 10 | +|=== |
| 11 | +|Name |Description |
| 12 | + |
| 13 | +|spring-shell-starter| Basic Spring Shell modules |
| 14 | +|spring-shell-starter-jansi| With JLine jansi provider |
| 15 | +|spring-shell-starter-jni| With JLine jni provider |
| 16 | +|spring-shell-starter-jna| With JLine jna provider |
| 17 | +|spring-shell-starter-ffm| With JLine ffm provider (requires JDK22+) |
| 18 | +|spring-shell-starter-test| Spring Shell testing support |
| 19 | +|=== |
| 20 | + |
| 21 | +== Terminal Providers |
| 22 | + |
| 23 | +Interacting with an underlying terminal where your program is running has |
| 24 | +traditionally been relatively complex process while it may look like |
| 25 | +there's not that much happening as it's all just text. |
| 26 | + |
| 27 | +Remember all those old manual typewriters or matrix printers? |
| 28 | +A character is printed where a cursor is which then need to be moved |
| 29 | +if printing in a different position. In a nutshell that's how current |
| 30 | +terminal emulators work. |
| 31 | + |
| 32 | +To access and understand existing terminal emulator environment better |
| 33 | +JLine can use native code via its own shared libraries. JLine detects |
| 34 | +which providers are present and then makes a choice which one to use. |
| 35 | +Traditionally there's been 3 providers, `jansi`, `jni` and `jna` which |
| 36 | +should all provide same functionalities. |
| 37 | + |
| 38 | +Our starters can be used to spesifically pick some of these JLine |
| 39 | +providers. |
| 40 | + |
| 41 | +== FFM |
| 42 | + |
| 43 | +With `JDK22` a _Foreign Function and Memory API_ came out from a preview |
| 44 | +which is supposed to be a replacement for `JNI` providing much better |
| 45 | +and safer native API. |
| 46 | + |
| 47 | +Starting from `3.4.x` we've added a support to compile Spring Shell |
| 48 | +application with `JLine` `ffm` terminal provider. This obviously mean |
| 49 | +that application needs to be run with `JDK22+`. There is a new JDK |
| 50 | +intermediate release every 6 months and long term support(LTS) release |
| 51 | +every 2 years. Until there's an existing LTS release Spring Shell can |
| 52 | +align with Spring Framework we will use latest JDK release. Obviously |
| 53 | +this means that you may need to upgrade your JDK in an inconvenient |
| 54 | +time if you choose to use `ffm`. We're also bound to JDK version |
| 55 | +`JLine` itself uses to compile its `ffm` parts. |
| 56 | + |
| 57 | +FFM itself will cause jvm to print warnings when some part of it are |
| 58 | +used. These warnings are obviously annoying with terminal applications |
| 59 | +as it may interfere and cause a little bit of a mess. In future JDK |
| 60 | +versions these warnings will also be added for an older JNI modules and |
| 61 | +at some point these warnings will be changed into hard errors. User will |
| 62 | +be required to enable these native "unsafe" parts manually. |
| 63 | + |
| 64 | +JVM option for this in a command line is: |
| 65 | + |
| 66 | +[source, bash] |
| 67 | +---- |
| 68 | +--enable-native-access=ALL-UNNAMED |
| 69 | +---- |
| 70 | + |
| 71 | +If you have a jar file you can have this setting in its `META-INF/MANIFEST.MF`. |
| 72 | + |
| 73 | +[source] |
| 74 | +---- |
| 75 | +Enable-Native-Access: ALL-UNNAMED |
| 76 | +---- |
| 77 | + |
| 78 | +Which can be added during a build i.e. if using gradle: |
| 79 | + |
| 80 | +[source, groovy] |
| 81 | +---- |
| 82 | +tasks.named("bootJar") { |
| 83 | + manifest { |
| 84 | + attributes 'Enable-Native-Access': 'ALL-UNNAMED' |
| 85 | + } |
| 86 | +} |
| 87 | +---- |
| 88 | + |
| 89 | +IMPORTANT: What comes for enabling native parts in a JDK, JLine has been |
| 90 | +proactive and already has a check for this and will throw error if |
| 91 | +native access is not enabled. |
| 92 | + |
6 | 93 | [[native]]
|
7 | 94 | == Native Support
|
8 | 95 |
|
|
0 commit comments