Skip to content

Commit b4d59c9

Browse files
committed
Make sample to work with spring-native
- While project uses jdk8, you can do native build with jdk11 `./mvnw clean package -Pnative` - You can then run these spring-shell-samples/target/spring-shell-samples java -jar spring-shell-samples/target/spring-shell-samples-3.0.0-SNAPSHOT-exec.jar - Remove logback.xml in favour of spring config to workaround for spring-attic/spring-native#625 - For now remove jcommander command sample to get support for it spring-projects#340 - Relates spring-projects#323
1 parent d879b7d commit b4d59c9

File tree

7 files changed

+90
-168
lines changed

7 files changed

+90
-168
lines changed

spring-shell-samples/pom.xml

+85-3
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
<plugin>
2020
<groupId>org.springframework.boot</groupId>
2121
<artifactId>spring-boot-maven-plugin</artifactId>
22-
<configuration>
23-
<mainClass>org.springframework.shell.samples.SpringShellSample</mainClass>
24-
</configuration>
2522
</plugin>
2623
</plugins>
2724
</build>
2825

2926
<dependencies>
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter</artifactId>
30+
</dependency>
3031
<dependency>
3132
<groupId>org.springframework.shell</groupId>
3233
<artifactId>spring-shell-starter</artifactId>
@@ -36,4 +37,85 @@
3637
<artifactId>jcommander</artifactId>
3738
</dependency>
3839
</dependencies>
40+
41+
<profiles>
42+
<profile>
43+
<id>native</id>
44+
<!-- needs GRAALVM_HOME to point to graal tools -->
45+
<properties>
46+
<spring-native.version>0.11.1</spring-native.version>
47+
</properties>
48+
<dependencies>
49+
<dependency>
50+
<groupId>org.springframework.experimental</groupId>
51+
<artifactId>spring-native</artifactId>
52+
<version>${spring-native.version}</version>
53+
</dependency>
54+
<!-- Required with Maven Surefire 2.x -->
55+
<dependency>
56+
<groupId>org.junit.platform</groupId>
57+
<artifactId>junit-platform-launcher</artifactId>
58+
<scope>test</scope>
59+
</dependency>
60+
</dependencies>
61+
<build>
62+
<plugins>
63+
<plugin>
64+
<groupId>org.springframework.experimental</groupId>
65+
<artifactId>spring-aot-maven-plugin</artifactId>
66+
<version>${spring-native.version}</version>
67+
<executions>
68+
<execution>
69+
<id>generate</id>
70+
<goals>
71+
<goal>generate</goal>
72+
</goals>
73+
</execution>
74+
</executions>
75+
</plugin>
76+
<plugin>
77+
<groupId>org.graalvm.buildtools</groupId>
78+
<artifactId>native-maven-plugin</artifactId>
79+
<version>0.9.9</version>
80+
<extensions>true</extensions>
81+
<executions>
82+
<execution>
83+
<id>build-native</id>
84+
<goals>
85+
<goal>build</goal>
86+
</goals>
87+
<phase>package</phase>
88+
</execution>
89+
<execution>
90+
<id>test-native</id>
91+
<goals>
92+
<goal>test</goal>
93+
</goals>
94+
<phase>test</phase>
95+
</execution>
96+
</executions>
97+
<configuration>
98+
<!-- ... -->
99+
</configuration>
100+
</plugin>
101+
<!-- Avoid a clash between Spring Boot repackaging and native-maven-plugin -->
102+
<plugin>
103+
<groupId>org.springframework.boot</groupId>
104+
<artifactId>spring-boot-maven-plugin</artifactId>
105+
<configuration>
106+
<classifier>exec</classifier>
107+
</configuration>
108+
</plugin>
109+
</plugins>
110+
</build>
111+
<pluginRepositories>
112+
<pluginRepository>
113+
<id>spring-releases</id>
114+
<name>Spring Releasess</name>
115+
<url>https://repo.spring.io/release</url>
116+
</pluginRepository>
117+
</pluginRepositories>
118+
</profile>
119+
</profiles>
120+
39121
</project>

spring-shell-samples/src/main/java/org/springframework/shell/samples/ExampleApplicationRunnerConfiguration.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* You may obtain a copy of the License at
77
*
88
* https://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -34,7 +34,7 @@
3434
import org.springframework.shell.jline.InteractiveShellApplicationRunner;
3535
import org.springframework.util.StringUtils;
3636

37-
@Configuration
37+
@Configuration(proxyBeanMethods = false)
3838
public class ExampleApplicationRunnerConfiguration {
3939

4040
@Autowired

spring-shell-samples/src/main/java/org/springframework/shell/samples/jcommander/Args.java

-55
This file was deleted.

spring-shell-samples/src/main/java/org/springframework/shell/samples/jcommander/JCommanderCommands.java

-37
This file was deleted.

spring-shell-samples/src/main/java/org/springframework/shell/samples/noautoconf/NoAutoConf.java

-63
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
spring:
2-
main:
3-
allow-circular-references: false
1+
logging:
2+
level:
3+
root: error

spring-shell-samples/src/main/resources/logback.xml

-5
This file was deleted.

0 commit comments

Comments
 (0)