Maven nutzte das io.fabric8:docker-maven-plugin, Gradle kopierte das JAR
in ein target/-Verzeichnis für dasselbe Dockerfile.
Beide Build-Systeme nutzen jetzt bootBuildImage, das über Cloud Native
Buildpacks direkt aus dem Spring Boot Plugin heraus ein OCI-Image erzeugt:
Maven: mvn spring-boot:build-image
Gradle: ./gradlew bootBuildImage
Vorteile:
- Kein Dockerfile nötig
- Beide Build-Systeme verwenden dieselbe Methode
- Image folgt automatisch Best Practices (non-root, layered JAR)
- jib-maven-plugin und gradle-git-properties waren bereits durch Rebase
vorhanden; jib entfällt zugunsten des Spring-Boot-eigenen build-image
Außerdem: springBoot { buildInfo() } in Gradle ergänzt, analog zum
build-info-Goal des spring-boot-maven-plugin (bereits in Maven konfiguriert).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
id 'org.springframework.boot' version '4.0.6'
id 'io.spring.dependency-management' version '1.1.7'
id 'com.gorylenko.gradle-git-properties' version '2.4.2'
- id 'com.google.cloud.tools.jib' version '3.4.5'
}
group = 'de.juplo.kafka'
useJUnitPlatform()
}
-tasks.named('test') {
- useJUnitPlatform()
+springBoot {
+ buildInfo()
}
-jib {
- from { image = 'eclipse-temurin:21-jre' }
- to { image = "juplo/${project.name}:${project.version}" }
- container { mainClass = 'de.juplo.kafka.ExampleProducer' }
+bootBuildImage {
+ imageName = "juplo/${project.name}:${project.version}"
}
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
+ <configuration>
+ <image>
+ <name>juplo/${project.artifactId}:${project.version}</name>
+ </image>
+ </configuration>
<executions>
<execution>
<goals>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
</plugin>
- <plugin>
- <groupId>com.google.cloud.tools</groupId>
- <artifactId>jib-maven-plugin</artifactId>
- <version>3.4.5</version>
- <configuration>
- <from>
- <image>eclipse-temurin:21-jre</image>
- </from>
- <to>
- <image>juplo/${project.artifactId}:${project.version}</image>
- </to>
- <container>
- <mainClass>de.juplo.kafka.ExampleProducer</mainClass>
- </container>
- </configuration>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>dockerBuild</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>