Skip to content

Commit b576e64

Browse files
committed
Set up build to use Paketo build packs for Spring Native.
Move dependency to the native JAR into the common build as we have code to compile to tweak the native image. That code needs to be compilable in non-native scenarios as well. 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).
1 parent cc17ec3 commit b576e64

File tree

3 files changed

+88
-1
lines changed

3 files changed

+88
-1
lines changed

server/pom.xml

+58
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,64 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
262262

263263
</profile>
264264

265+
<!-- To build native images -->
266+
<profile>
267+
268+
<id>nativeBP</id>
269+
270+
<build>
271+
<defaultGoal>spring-boot:build-image</defaultGoal>
272+
<plugins>
273+
<plugin>
274+
<groupId>org.springframework.boot</groupId>
275+
<artifactId>spring-boot-maven-plugin</artifactId>
276+
<configuration>
277+
<executable>true</executable>
278+
<image>
279+
<builder>paketobuildpacks/builder:tiny</builder>
280+
<env>
281+
<BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
282+
</env>
283+
</image>
284+
</configuration>
285+
<executions>
286+
<execution>
287+
<id>aot-generate</id>
288+
<goals>
289+
<goal>aot-generate</goal>
290+
</goals>
291+
</execution>
292+
</executions>
293+
</plugin>
294+
</plugins>
295+
</build>
296+
297+
</profile>
298+
299+
<!-- Activate in addition to 'native' if you're building on an ARM machine (such as an M1 MacBook) -->
300+
301+
<profile>
302+
<id>arm64</id>
303+
<activation>
304+
<os>
305+
<arch>aarch64</arch>
306+
</os>
307+
</activation>
308+
<build>
309+
<plugins>
310+
<plugin>
311+
<groupId>org.springframework.boot</groupId>
312+
<artifactId>spring-boot-maven-plugin</artifactId>
313+
<configuration >
314+
<image>
315+
<builder>dashaun/java-native-builder-arm64:7.19.0</builder>
316+
</image>
317+
</configuration>
318+
</plugin>
319+
</plugins>
320+
</build>
321+
</profile>
322+
265323
</profiles>
266324

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

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

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

4848
@Override
49-
public MonetaryAmount convertToEntityAttribute(String source) {
49+
public Money convertToEntityAttribute(String source) {
5050

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

0 commit comments

Comments
 (0)