Skip to content

Commit f98e584

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. Declare Money as the type being returned from MonetaryAmountAttributeConverter.convertToEntityAttribute(…) so that it is automatically added to the reflection configuration (makes spring-attic/spring-native#826 obsolete). $ Conflicts: $ server/pom.xml
1 parent 5f35672 commit f98e584

File tree

3 files changed

+102
-3
lines changed

3 files changed

+102
-3
lines changed

server/pom.xml

+69-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
2020
<java.version>17</java.version>
2121
<jmolecules.version>2021.2.3</jmolecules.version>
2222
<moduliths.version>1.3.0-RC1</moduliths.version>
23+
<spring-native.version>0.11.4</spring-native.version>
2324
</properties>
2425

2526
<dependencyManagement>
@@ -82,7 +83,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
8283
<dependency>
8384
<groupId>org.springframework.data</groupId>
8485
<artifactId>spring-data-rest-hal-explorer</artifactId>
85-
<scope>runtime</scope>
86+
<!--<scope>runtime</scope>-->
8687
</dependency>
8788

8889
<dependency>
@@ -162,7 +163,21 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
162163
<artifactId>spring-boot-configuration-processor</artifactId>
163164
<optional>true</optional>
164165
</dependency>
165-
166+
167+
<!-- Spring native -->
168+
169+
<dependency>
170+
<groupId>org.springframework.experimental</groupId>
171+
<artifactId>spring-native</artifactId>
172+
<version>${spring-native.version}</version>
173+
</dependency>
174+
175+
<dependency>
176+
<groupId>org.springframework.experimental</groupId>
177+
<artifactId>spring-native-configuration</artifactId>
178+
<version>${spring-native.version}</version>
179+
</dependency>
180+
166181
</dependencies>
167182

168183
<profiles>
@@ -206,6 +221,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
206221

207222
</dependencies>
208223
</profile>
224+
225+
<profile>
226+
<id>native</id>
227+
<build>
228+
<defaultGoal>spring-boot:build-image</defaultGoal>
229+
</build>
230+
</profile>
231+
209232
</profiles>
210233

211234
<build>
@@ -216,13 +239,21 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
216239
<artifactId>spring-boot-maven-plugin</artifactId>
217240
<configuration>
218241
<executable>true</executable>
242+
<image>
243+
<builder>paketobuildpacks/builder:tiny</builder>
244+
<env>
245+
<BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
246+
</env>
247+
</image>
219248
</configuration>
220249
<dependencies>
250+
<!--
221251
<dependency>
222252
<groupId>org.springframework.boot.experimental</groupId>
223253
<artifactId>spring-boot-thin-layout</artifactId>
224254
<version>1.0.28.RELEASE</version>
225255
</dependency>
256+
-->
226257
</dependencies>
227258
</plugin>
228259

@@ -246,6 +277,28 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
246277
</dependencies>
247278
</plugin>
248279

280+
<plugin>
281+
<groupId>org.springframework.experimental</groupId>
282+
<artifactId>spring-aot-maven-plugin</artifactId>
283+
<version>${spring-native.version}</version>
284+
<executions>
285+
<execution>
286+
<id>generate</id>
287+
<goals>
288+
<goal>generate</goal>
289+
</goals>
290+
</execution>
291+
<!--
292+
<execution>
293+
<id>test-generate</id>
294+
<goals>
295+
<goal>test-generate</goal>
296+
</goals>
297+
</execution>
298+
-->
299+
</executions>
300+
</plugin>
301+
249302
</plugins>
250303
</build>
251304

@@ -264,6 +317,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
264317
<enabled>false</enabled>
265318
</snapshots>
266319
</repository>
320+
<repository>
321+
<id>spring-release</id>
322+
<url>https://repo.spring.io/release</url>
323+
<snapshots>
324+
<enabled>false</enabled>
325+
</snapshots>
326+
</repository>
267327
</repositories>
268328

269329
<pluginRepositories>
@@ -281,6 +341,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
281341
<enabled>false</enabled>
282342
</snapshots>
283343
</pluginRepository>
344+
<pluginRepository>
345+
<id>spring-release</id>
346+
<url>https://repo.spring.io/release</url>
347+
<snapshots>
348+
<enabled>false</enabled>
349+
</snapshots>
350+
</pluginRepository>
284351
</pluginRepositories>
285352

286353
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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.nativex.hint.AotProxyHint;
20+
import org.springframework.nativex.hint.ProxyBits;
21+
import org.springsource.restbucks.drinks.Drink;
22+
23+
/**
24+
* Additional configuration needed to produce Graal metadata to let some application properly work on it.
25+
*
26+
* @author Oliver Drotbohm
27+
*/
28+
@Configuration
29+
30+
// Due to DrinksOptions.BY_NAME (i.e. the usage of a domain type with Spring Data's TypedSort)
31+
@AotProxyHint(targetClass = Drink.class, proxyFeatures = ProxyBits.IS_STATIC)
32+
class NativeConfiguration {}

server/src/main/java/org/springsource/restbucks/core/MonetaryAmountAttributeConverter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public String convertToDatabaseColumn(MonetaryAmount amount) {
4545
}
4646

4747
@Override
48-
public MonetaryAmount convertToEntityAttribute(String source) {
48+
public Money convertToEntityAttribute(String source) {
4949

5050
if (source == null) {
5151
return null;

0 commit comments

Comments
 (0)