Skip to content

Commit 644caf2

Browse files
committed
GH-1449 - Register SQL schemas as native image resources.
1 parent 7771254 commit 644caf2

32 files changed

+86
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2025 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.springframework.modulith.events.jdbc;
17+
18+
import org.jspecify.annotations.Nullable;
19+
import org.springframework.aot.hint.RuntimeHints;
20+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
21+
22+
/**
23+
* AOT resource hints for the database schemas.
24+
*
25+
* @author Oliver Drotbohm
26+
*/
27+
class DatabaseSchemaHints implements RuntimeHintsRegistrar {
28+
29+
/*
30+
* (non-Javadoc)
31+
* @see org.springframework.aot.hint.RuntimeHintsRegistrar#registerHints(org.springframework.aot.hint.RuntimeHints, java.lang.ClassLoader)
32+
*/
33+
@Override
34+
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
35+
hints.resources().registerPattern(DatabaseType.SCHEMA_ROOT + "/**");
36+
}
37+
}

spring-modulith-events/spring-modulith-events-jdbc/src/main/java/org/springframework/modulith/events/jdbc/DatabaseType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ String getLimitClause(long limit) {
118118
};
119119

120120
static final String SCHEMA_NOT_SUPPORTED = "Setting the schema name is not supported!";
121+
static final String SCHEMA_ROOT = "org/springframework/modulith/events/jdbc/schemas";
121122

122123
static DatabaseType from(String productName) {
123124

@@ -158,7 +159,7 @@ String getLimitClause(long limit) {
158159
}
159160

160161
private String getSchemaBase(boolean legacy) {
161-
return "/schemas/" + (legacy ? "v1" : "v2") + "/schema-" + value;
162+
return SCHEMA_ROOT + "/" + (legacy ? "v1" : "v2") + "/schema-" + value;
162163
}
163164

164165
boolean isSchemaSupported() {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
org.springframework.aot.hint.RuntimeHintsRegistrar=\
2+
org.springframework.modulith.events.jdbc.DatabaseSchemaHints

spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/schemas/v1/schema-h2-archive.sql renamed to spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/org/springframework/modulith/events/jdbc/schemas/v1/schema-h2-archive.sql

File renamed without changes.

spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/schemas/v1/schema-h2.sql renamed to spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/org/springframework/modulith/events/jdbc/schemas/v1/schema-h2.sql

File renamed without changes.

spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/schemas/v1/schema-hsqldb-archive.sql renamed to spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/org/springframework/modulith/events/jdbc/schemas/v1/schema-hsqldb-archive.sql

File renamed without changes.

spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/schemas/v1/schema-hsqldb.sql renamed to spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/org/springframework/modulith/events/jdbc/schemas/v1/schema-hsqldb.sql

File renamed without changes.

spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/schemas/v1/schema-mariadb-archive.sql renamed to spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/org/springframework/modulith/events/jdbc/schemas/v1/schema-mariadb-archive.sql

File renamed without changes.

spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/schemas/v1/schema-mariadb.sql renamed to spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/org/springframework/modulith/events/jdbc/schemas/v1/schema-mariadb.sql

File renamed without changes.

spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/schemas/v1/schema-mysql-archive.sql renamed to spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/org/springframework/modulith/events/jdbc/schemas/v1/schema-mysql-archive.sql

File renamed without changes.

0 commit comments

Comments
 (0)