Skip to content

Commit 79a0530

Browse files
committed
Set up build to use Paketo build packs for Spring Native.
Use buildpack based native image builds. Remove offending libraries: both Spring Boot DevTools and the Thin Launcher are not native-ready yet. Added NativeConfiguration to capture a few manual hints still needed.
1 parent ce43467 commit 79a0530

File tree

2 files changed

+114
-2
lines changed

2 files changed

+114
-2
lines changed

server/pom.xml

+61-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
1717

1818
<properties>
1919
<java.version>11</java.version>
20+
<spring-native.version>0.10.0</spring-native.version>
2021
</properties>
2122

2223
<dependencyManagement>
@@ -70,7 +71,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
7071
<dependency>
7172
<groupId>org.springframework.data</groupId>
7273
<artifactId>spring-data-rest-hal-explorer</artifactId>
73-
<scope>runtime</scope>
74+
<!--<scope>runtime</scope>-->
7475
</dependency>
7576

7677
<dependency>
@@ -123,11 +124,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
123124

124125
<!-- Misc -->
125126

127+
<!--
126128
<dependency>
127129
<groupId>org.springframework.boot</groupId>
128130
<artifactId>spring-boot-devtools</artifactId>
129131
<optional>true</optional>
130132
</dependency>
133+
-->
131134

132135
<dependency>
133136
<groupId>org.javamoney.moneta</groupId>
@@ -145,6 +148,20 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
145148
<artifactId>json-path</artifactId>
146149
</dependency>
147150

151+
<!-- Spring native -->
152+
153+
<dependency>
154+
<groupId>org.springframework.experimental</groupId>
155+
<artifactId>spring-native</artifactId>
156+
<version>${spring-native.version}</version>
157+
</dependency>
158+
159+
<dependency>
160+
<groupId>org.springframework.experimental</groupId>
161+
<artifactId>spring-native-configuration</artifactId>
162+
<version>${spring-native.version}</version>
163+
</dependency>
164+
148165
</dependencies>
149166

150167
<build>
@@ -155,13 +172,21 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
155172
<artifactId>spring-boot-maven-plugin</artifactId>
156173
<configuration>
157174
<executable>true</executable>
175+
<image>
176+
<builder>paketobuildpacks/builder:tiny</builder>
177+
<env>
178+
<BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
179+
</env>
180+
</image>
158181
</configuration>
159182
<dependencies>
183+
<!--
160184
<dependency>
161185
<groupId>org.springframework.boot.experimental</groupId>
162186
<artifactId>spring-boot-thin-layout</artifactId>
163-
<version>1.0.27.BUILD-SNAPSHOT</version>
187+
<version>1.0.27.RELEASE</version>
164188
</dependency>
189+
-->
165190
</dependencies>
166191
</plugin>
167192

@@ -185,6 +210,26 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
185210
</dependencies>
186211
</plugin>
187212

213+
<plugin>
214+
<groupId>org.springframework.experimental</groupId>
215+
<artifactId>spring-aot-maven-plugin</artifactId>
216+
<version>${spring-native.version}</version>
217+
<executions>
218+
<execution>
219+
<id>generate</id>
220+
<goals>
221+
<goal>generate</goal>
222+
</goals>
223+
</execution>
224+
<execution>
225+
<id>test-generate</id>
226+
<goals>
227+
<goal>test-generate</goal>
228+
</goals>
229+
</execution>
230+
</executions>
231+
</plugin>
232+
188233
</plugins>
189234
</build>
190235

@@ -200,6 +245,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
200245
<enabled>false</enabled>
201246
</snapshots>
202247
</repository>
248+
<repository>
249+
<id>spring-release</id>
250+
<url>https://repo.spring.io/release</url>
251+
<snapshots>
252+
<enabled>false</enabled>
253+
</snapshots>
254+
</repository>
203255
</repositories>
204256

205257
<pluginRepositories>
@@ -214,6 +266,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
214266
<enabled>false</enabled>
215267
</snapshots>
216268
</pluginRepository>
269+
<pluginRepository>
270+
<id>spring-release</id>
271+
<url>https://repo.spring.io/release</url>
272+
<snapshots>
273+
<enabled>false</enabled>
274+
</snapshots>
275+
</pluginRepository>
217276
</pluginRepositories>
218277

219278
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springsource.restbucks;
17+
18+
import org.springframework.context.annotation.Configuration;
19+
import org.springframework.context.event.EventListener;
20+
import org.springframework.core.annotation.SynthesizedAnnotation;
21+
import org.springframework.nativex.hint.AccessBits;
22+
import org.springframework.nativex.hint.AotProxyHint;
23+
import org.springframework.nativex.hint.JdkProxyHint;
24+
import org.springframework.nativex.hint.NativeHint;
25+
import org.springframework.nativex.hint.ProxyBits;
26+
import org.springframework.nativex.hint.TypeHint;
27+
import org.springframework.transaction.event.TransactionalEventListener;
28+
import org.springsource.restbucks.drinks.Drink;
29+
30+
/**
31+
* Additional configuration needed to produce Graal metadata to let some application properly work on it.
32+
*
33+
* @author Oliver Drotbohm
34+
*/
35+
@Configuration
36+
// Standard user component requiring proxying due to @Async
37+
@AotProxyHint(targetClassName = "org.springsource.restbucks.engine.Engine", proxyFeatures = ProxyBits.IS_STATIC)
38+
39+
// Due to DrinksOptions.BY_NAME (i.e. the usage of a domain type with Spring Data's TypedSort)
40+
@AotProxyHint(targetClass = Drink.class, proxyFeatures = ProxyBits.IS_STATIC)
41+
42+
// Referred to by a custom AttributeConverter
43+
// https://github.com/spring-projects-experimental/spring-native/issues/829
44+
@TypeHint(types = { org.javamoney.moneta.Money.class }, access = AccessBits.LOAD_AND_CONSTRUCT)
45+
46+
// Needed to get @TransactionalEventListener on Engine.process(…) working
47+
// https://github.com/spring-projects-experimental/spring-native/issues/828
48+
@TypeHint(types = { EventListener.class, TransactionalEventListener.class }, access = AccessBits.ANNOTATION)
49+
// Additional wrapping needed due to https://github.com/spring-projects-experimental/spring-native/issues/830
50+
@NativeHint( //
51+
jdkProxies = @JdkProxyHint(types = { TransactionalEventListener.class, SynthesizedAnnotation.class }) //
52+
)
53+
class NativeConfiguration {}

0 commit comments

Comments
 (0)