build: centralize active app boot packaging
This commit is contained in:
@@ -66,17 +66,6 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<jvmArguments>--sun-misc-unsafe-memory-access=allow</jvmArguments>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
<goal>build-info</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -66,17 +66,6 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<jvmArguments>--sun-misc-unsafe-memory-access=allow</jvmArguments>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
<goal>build-info</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -58,17 +58,6 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<jvmArguments>--sun-misc-unsafe-memory-access=allow</jvmArguments>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
<goal>build-info</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -62,17 +62,6 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<jvmArguments>--sun-misc-unsafe-memory-access=allow</jvmArguments>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
<goal>build-info</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -16,6 +16,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class MavenModuleProfileTest {
|
||||
|
||||
private static final List<String> ACTIVE_APP_POMS = List.of(
|
||||
"modules/apps/gb32960-ingest-app/pom.xml",
|
||||
"modules/apps/jt808-ingest-app/pom.xml",
|
||||
"modules/apps/yutong-mqtt-app/pom.xml",
|
||||
"modules/apps/vehicle-history-app/pom.xml",
|
||||
"modules/apps/vehicle-analytics-app/pom.xml");
|
||||
|
||||
@Test
|
||||
void commandGatewayIsOutsideDefaultProductionReactor() throws Exception {
|
||||
Document pom = rootPom();
|
||||
@@ -228,6 +235,34 @@ class MavenModuleProfileTest {
|
||||
.isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void activeAppBootPackagingConfigurationIsManagedOnceInRootPom() throws Exception {
|
||||
Document pom = rootPom();
|
||||
Element managedBootPlugin = managedPlugin(pom, "org.springframework.boot", "spring-boot-maven-plugin");
|
||||
|
||||
assertThat(managedBootPlugin).isNotNull();
|
||||
assertThat(managedBootPlugin.getTextContent())
|
||||
.contains("${spring-boot.version}")
|
||||
.contains("--sun-misc-unsafe-memory-access=allow")
|
||||
.contains("repackage")
|
||||
.contains("build-info");
|
||||
|
||||
for (String appPom : ACTIVE_APP_POMS) {
|
||||
Document app = modulePom(appPom);
|
||||
Element bootPlugin = buildPlugin(app, "org.springframework.boot", "spring-boot-maven-plugin");
|
||||
|
||||
assertThat(bootPlugin)
|
||||
.as(appPom)
|
||||
.isNotNull();
|
||||
assertThat(firstDirectChild(bootPlugin, "configuration"))
|
||||
.as(appPom + " should inherit shared JVM arguments from root pluginManagement")
|
||||
.isNull();
|
||||
assertThat(firstDirectChild(bootPlugin, "executions"))
|
||||
.as(appPom + " should inherit repackage/build-info executions from root pluginManagement")
|
||||
.isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void observabilityBuildSurfaceUsesMicrometerWithoutUnusedOpenTelemetryBom() throws Exception {
|
||||
Document pom = rootPom();
|
||||
@@ -526,6 +561,39 @@ class MavenModuleProfileTest {
|
||||
return List.copyOf(artifacts);
|
||||
}
|
||||
|
||||
private static Element managedPlugin(Document pom, String groupId, String artifactId) {
|
||||
Element build = firstDirectChild(pom.getDocumentElement(), "build");
|
||||
Element pluginManagement = build == null ? null : firstDirectChild(build, "pluginManagement");
|
||||
return plugin(pluginManagement, groupId, artifactId);
|
||||
}
|
||||
|
||||
private static Element buildPlugin(Document pom, String groupId, String artifactId) {
|
||||
Element build = firstDirectChild(pom.getDocumentElement(), "build");
|
||||
return plugin(build, groupId, artifactId);
|
||||
}
|
||||
|
||||
private static Element plugin(Element owner, String groupId, String artifactId) {
|
||||
Element plugins = owner == null ? null : firstDirectChild(owner, "plugins");
|
||||
if (plugins == null) {
|
||||
return null;
|
||||
}
|
||||
NodeList children = plugins.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
if (!(children.item(i) instanceof Element plugin) || !"plugin".equals(plugin.getTagName())) {
|
||||
continue;
|
||||
}
|
||||
Element currentGroupId = firstDirectChild(plugin, "groupId");
|
||||
Element currentArtifactId = firstDirectChild(plugin, "artifactId");
|
||||
if (currentGroupId != null
|
||||
&& currentArtifactId != null
|
||||
&& groupId.equals(currentGroupId.getTextContent().trim())
|
||||
&& artifactId.equals(currentArtifactId.getTextContent().trim())) {
|
||||
return plugin;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean hasDependency(Document pom, String groupId, String artifactId) {
|
||||
Element owner = pom.getDocumentElement();
|
||||
Element dependencyManagement = firstDirectChild(owner, "dependencyManagement");
|
||||
|
||||
@@ -62,17 +62,6 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<jvmArguments>--sun-misc-unsafe-memory-access=allow</jvmArguments>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
<goal>build-info</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
Reference in New Issue
Block a user