Skip to content

Commit

Permalink
Make sample to work with spring-native
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
jvalkeal committed Dec 24, 2021
1 parent d879b7d commit b4d59c9
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 168 deletions.
88 changes: 85 additions & 3 deletions spring-shell-samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>org.springframework.shell.samples.SpringShellSample</mainClass>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell-starter</artifactId>
Expand All @@ -36,4 +37,85 @@
<artifactId>jcommander</artifactId>
</dependency>
</dependencies>

<profiles>
<profile>
<id>native</id>
<!-- needs GRAALVM_HOME to point to graal tools -->
<properties>
<spring-native.version>0.11.1</spring-native.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.experimental</groupId>
<artifactId>spring-native</artifactId>
<version>${spring-native.version}</version>
</dependency>
<!-- Required with Maven Surefire 2.x -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.experimental</groupId>
<artifactId>spring-aot-maven-plugin</artifactId>
<version>${spring-native.version}</version>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.9.9</version>
<extensions>true</extensions>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>build</goal>
</goals>
<phase>package</phase>
</execution>
<execution>
<id>test-native</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
<configuration>
<!-- ... -->
</configuration>
</plugin>
<!-- Avoid a clash between Spring Boot repackaging and native-maven-plugin -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<name>Spring Releasess</name>
<url>https://repo.spring.io/release</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -34,7 +34,7 @@
import org.springframework.shell.jline.InteractiveShellApplicationRunner;
import org.springframework.util.StringUtils;

@Configuration
@Configuration(proxyBeanMethods = false)
public class ExampleApplicationRunnerConfiguration {

@Autowired
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

6 changes: 3 additions & 3 deletions spring-shell-samples/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
spring:
main:
allow-circular-references: false
logging:
level:
root: error
5 changes: 0 additions & 5 deletions spring-shell-samples/src/main/resources/logback.xml

This file was deleted.

0 comments on commit b4d59c9

Please sign in to comment.