Skip to content

Commit

Permalink
chore(deps): update micronaut.gradle.plugin to v4.3.6 (#2436)
Browse files Browse the repository at this point in the history
* chore(deps): update micronaut.gradle.plugin to v4.3.6

* Fix functional test for new Gradle plugin

We were (unnecessarily) overwriting the base image for Java 21 DockerFiles.
Instead we can use the base image supplied by the plugin.

The plugin has also changed so that the base image is now 21-jre or 17-jre.
Not -jammy or -focal as before.

See micronaut-projects/micronaut-gradle-plugin#979

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Tim Yates <tim.yates@gmail.com>
  • Loading branch information
renovate[bot] and timyates committed Apr 17, 2024
1 parent 41a25c7 commit f1677f3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion gradle/templates.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ log4j = "2.23.0"
log4j-slf4j = "2.17.2"
micronaut-aot = "2.2.0"
micronaut-build-plugins = "6.6.4"
micronaut-gradle-plugin = "4.3.5"
micronaut-gradle-plugin = "4.3.6"
mockserver-client-java = "5.15.0"
mockk = "1.9.3"
protobuf-gradle-plugin = "0.9.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import jakarta.inject.Singleton;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
Expand All @@ -62,10 +61,6 @@ public class MicronautBuildPlugin implements BuildPluginFeature, DefaultFeature
public static final String AOT_KEY_SECURITY_JWKS = "micronaut.security.jwks.enabled";
public static final String AOT_KEY_SECURITY_OPENID = "micronaut.security.openid-configuration.enabled";

public static final Map<JdkVersion, String> BASE_IMAGES = Map.of(
JdkVersion.JDK_21, "eclipse-temurin:21-jre-jammy"
);

protected final CoordinateResolver coordinateResolver;

public MicronautBuildPlugin(CoordinateResolver coordinateResolver) {
Expand Down Expand Up @@ -212,10 +207,6 @@ protected MicronautApplicationGradlePlugin.Builder micronautGradleApplicationPlu
.arg("-Dio.netty.noPreferDirect=true")
.build());
} else if (generatorContext.getJdkVersion() != JdkVersion.JDK_17) {
String baseImageForJdkVersion = BASE_IMAGES.get(generatorContext.getJdkVersion());
if (baseImageForJdkVersion != null) {
builder.docker(Dockerfile.builder().baseImage(baseImageForJdkVersion).build());
}
builder.dockerNative(Dockerfile.builder().javaVersion(generatorContext.getJdkVersion().asString()).build());
}
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import io.micronaut.starter.test.CommandSpec

class GradleDockerConfigSpec extends CommandSpec {

void "basic dockerfile creation"(BuildTool buildTool, Integer javaVersion) {
void "basic dockerfile creation as expected for #buildTool and Java #javaVersion"(BuildTool buildTool, Integer javaVersion) {
when:
generateProjectForVersion(Language.JAVA, JdkVersion.valueOf(javaVersion), buildTool)

Expand All @@ -24,22 +24,23 @@ class GradleDockerConfigSpec extends CommandSpec {
BuildTool.valuesGradle(),
[17, 21]
].combinations()
dockerBaseImage = javaVersion == 17 ? "eclipse-temurin:17-jre-focal" : "eclipse-temurin:21-jre-jammy"
dockerBaseImage = javaVersion == 17 ? "eclipse-temurin:17-jre" : "eclipse-temurin:21-jre"
}

void "test dockerfiles can be built"(BuildTool buildTool, String command) {
void "test #command works for #buildTool under java #javaVersion"(BuildTool buildTool, String command, Integer javaVersion) {
when:
generateProject(Language.JAVA, buildTool)
generateProjectForVersion(Language.JAVA, JdkVersion.valueOf(javaVersion), buildTool)

def result = executeGradle(command)

then:
result.output.contains("BUILD SUCCESS")

where:
[buildTool, command] << [
[buildTool, command, javaVersion] << [
BuildTool.valuesGradle(),
['dockerBuild', 'dockerBuildNative']
['dockerBuild', 'dockerBuildNative'],
[17] + (Runtime.version().feature() >= 21 ? [21] : [])
].combinations()
}

Expand Down

0 comments on commit f1677f3

Please sign in to comment.