Skip to content

Commit

Permalink
4.2.1-2 release (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
burtbeckwith authored Feb 29, 2024
1 parent 3bb79ff commit e6f5284
Show file tree
Hide file tree
Showing 17 changed files with 77 additions and 63 deletions.
2 changes: 1 addition & 1 deletion gcn/buildSrc/src/main/groovy/gcn-base.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ plugins {
id 'maven-publish'
}

version = new File(rootProject.projectDir, 'version.txt').text.trim()
version = new File(rootProject.projectDir, 'gcn-core/src/main/resources/version.txt').text.trim()
group = 'gcn'

ext.micronautVersion = new File(rootProject.projectDir, 'gcn-core/src/main/resources/micronautVersion.txt').text.trim()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class GcnCommonOptionsMixin {
*/
public static class GcnVersionProvider implements IVersionProvider {
public String[] getVersion() {
return new String[]{"GCN Version: " + GcnUtils.getMicronautVersion()};
return new String[]{"GCN Version: " + GcnUtils.getVersion()};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
import static cloud.graal.gcn.GcnUtils.APP_MODULE;
import static cloud.graal.gcn.GcnUtils.BOM_VERSION_SUFFIX;
import static cloud.graal.gcn.GcnUtils.LIB_MODULE;
import static cloud.graal.gcn.GcnUtils.MICRONAUT_MAVEN_DEFAULT_DOCKER_IMAGE;
import static cloud.graal.gcn.GcnUtils.MICRONAUT_MAVEN_PLUGIN_VERSION;
import static cloud.graal.gcn.GcnUtils.TEST_RESOURCES_VERSION;
import static cloud.graal.gcn.feature.replaced.GcnJTE.JTE_GROUP_ID;
import static cloud.graal.gcn.feature.replaced.GcnJTE.JTE_NATIVE_RESOURCES;
import static cloud.graal.gcn.model.GcnCloud.AWS;
Expand Down Expand Up @@ -118,14 +118,14 @@ public class GcnGeneratorContext extends GeneratorContext {

private static final Map<String, String> PLUGIN_GAVS = Map.ofEntries(
Map.entry("com.github.johnrengelman.shadow:8.1.1", "com.github.johnrengelman:shadow:8.1.1"),
Map.entry("io.micronaut.application:4.2.1", "io.micronaut.gradle:micronaut-gradle-plugin:4.2.1"),
Map.entry("io.micronaut.library:4.2.1", "io.micronaut.gradle:micronaut-gradle-plugin:4.2.1"),
Map.entry("io.micronaut.test-resources:4.2.1", "io.micronaut.gradle:micronaut-test-resources-plugin:4.2.1"),
Map.entry("io.micronaut.application:4.3.2", "io.micronaut.gradle:micronaut-gradle-plugin:4.3.2"),
Map.entry("io.micronaut.library:4.3.2", "io.micronaut.gradle:micronaut-gradle-plugin:4.3.2"),
Map.entry("io.micronaut.test-resources:4.3.2", "io.micronaut.gradle:micronaut-test-resources-plugin:4.3.2"),
Map.entry("org.jetbrains.kotlin.jvm:1.9.21", "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.21"),
Map.entry("org.jetbrains.kotlin.kapt:1.9.21", "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.21"),
Map.entry("org.jetbrains.kotlin.plugin.allopen:1.9.21", "org.jetbrains.kotlin:kotlin-allopen:1.9.21"),
Map.entry("com.google.cloud.tools.jib:2.8.0", "com.google.cloud.tools.jib:com.google.cloud.tools.jib.gradle.plugin:2.8.0"),
Map.entry("io.micronaut.aot:4.2.1", "io.micronaut.gradle:micronaut-aot-plugin:4.2.1"),
Map.entry("io.micronaut.aot:4.3.2", "io.micronaut.gradle:micronaut-aot-plugin:4.3.2"),
Map.entry("com.google.devtools.ksp:1.9.21-1.0.15", "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:1.9.21-1.0.15"),
Map.entry(GG_JTE_GRADLE, "gg.jte:jte-gradle-plugin:3.0.3")
);
Expand Down Expand Up @@ -174,8 +174,10 @@ public GcnGeneratorContext(Project project,
buildProperties.put(key, GcnUtils.getMicronautVersion() + BOM_VERSION_SUFFIX);

// TODO check if can be removed in new version of micronaut
buildProperties.put("micronaut.native-image.base-image-run", MICRONAUT_MAVEN_DEFAULT_DOCKER_IMAGE);
buildProperties.put("micronaut-maven-plugin.version", MICRONAUT_MAVEN_PLUGIN_VERSION);
if (!featureContext.getBuildTool().isGradle()) {
buildProperties.put("micronaut-maven-plugin.version", MICRONAUT_MAVEN_PLUGIN_VERSION);
buildProperties.put("micronaut.test.resources.version", TEST_RESOURCES_VERSION);
}
}

private static Map<GcnCloud, GcnFeatures> splitFeatures(Set<Feature> allFeatures,
Expand Down
35 changes: 18 additions & 17 deletions gcn/gcn-core/src/main/java/cloud/graal/gcn/GcnUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package cloud.graal.gcn;

import io.micronaut.starter.options.JdkVersion;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
Expand Down Expand Up @@ -51,14 +49,9 @@ public final class GcnUtils {
public static final String MICRONAUT_MAVEN_PLUGIN_VERSION = "4.3.1";

/**
* The default docker image inside maven builds
*/
public static final String MICRONAUT_MAVEN_DEFAULT_DOCKER_IMAGE = "frolvlad/alpine-glibc:alpine-3.16";

/**
* The default JDK version if none is specified.
* The default version of test resources plugin
*/
public static final JdkVersion DEFAULT_JDK = JDK_17;
public static final String TEST_RESOURCES_VERSION = "2.3.3";

/**
* All supported JDK versions.
Expand All @@ -70,28 +63,36 @@ public final class GcnUtils {
*/
public static final String BOM_VERSION_SUFFIX = "-oracle-00001";

private static final String GCN_VERSION;
private static final String GCN_VERSION = loadVersion("version.txt");
private static final String MICRONAUT_VERSION = loadVersion("micronautPlatformVersion.txt");

private GcnUtils() {
}

static {
URL resource = GcnUtils.class.getResource("/micronautPlatformVersion.txt");
private static String loadVersion(String resourcePath) {
URL resource = GcnUtils.class.getResource("/" + resourcePath);
if (resource == null) {
throw new IllegalStateException("Resource /micronautPlatformVersion.txt not found");
throw new IllegalStateException("Resource /" + resourcePath + " not found");
}

try (InputStream inputStream = resource.openStream()) {
GCN_VERSION = new String(inputStream.readAllBytes(), UTF_8).trim();
return new String(inputStream.readAllBytes(), UTF_8).trim();
} catch (IOException e) {
throw new RuntimeException(e);
}
}

private GcnUtils() {
}

/**
* @return the version of Micronaut Platform
*/
public static String getMicronautVersion() {
return MICRONAUT_VERSION;
}

/**
* @return the GCN version
*/
public static String getVersion() {
return GCN_VERSION;
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Copyright (c) 2023, Oracle and/or its affiliates.
Copyright (c) 2024, Oracle and/or its affiliates.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
@Replaces(DefaultPomDependencyVersionResolver.class)
public class GcnDefaultPomDependencyVersionResolver extends DefaultPomDependencyVersionResolver {

public static final Coordinate MICRONAUT_GRADLE_PLUGIN = Dependency.builder().groupId("io.micronaut.gradle").artifactId("micronaut-gradle-plugin").version("4.2.1").pom(false).buildCoordinate();
public static final Coordinate MICRONAUT_CRAC_PLUGIN = Dependency.builder().groupId("io.micronaut.gradle").artifactId("micronaut-crac-plugin").version("4.2.1").pom(false).buildCoordinate();
public static final Coordinate MICRONAUT_TEST_RESOURCES_PLUGIN = Dependency.builder().groupId("io.micronaut.gradle").artifactId("micronaut-test-resources-plugin").version("4.2.1").pom(false).buildCoordinate();
public static final Coordinate MICRONAUT_GRADLE_PLUGIN = Dependency.builder().groupId("io.micronaut.gradle").artifactId("micronaut-gradle-plugin").version("4.3.2").pom(false).buildCoordinate();
public static final Coordinate MICRONAUT_CRAC_PLUGIN = Dependency.builder().groupId("io.micronaut.gradle").artifactId("micronaut-crac-plugin").version("4.3.2").pom(false).buildCoordinate();
public static final Coordinate MICRONAUT_TEST_RESOURCES_PLUGIN = Dependency.builder().groupId("io.micronaut.gradle").artifactId("micronaut-test-resources-plugin").version("4.3.2").pom(false).buildCoordinate();

private static final Map<String, Coordinate> COORDINATES;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class AwsStreaming extends AbstractStreamingFeature {
private static final Dependency AWS_IAM_AUTH_LIB = Dependency.builder()
.groupId("software.amazon.msk")
.artifactId("aws-msk-iam-auth")
.version("1.1.9")
.version("2.0.3")
.runtime()
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import io.micronaut.starter.feature.opentelemetry.OpenTelemetry;
import io.micronaut.starter.feature.opentelemetry.OpenTelemetryAnnotations;
import io.micronaut.starter.feature.opentelemetry.OpenTelemetryHttp;
import io.micronaut.starter.feature.other.HttpClient;

import static cloud.graal.gcn.model.GcnService.TRACING;
import static io.micronaut.starter.application.ApplicationType.DEFAULT;
Expand All @@ -54,6 +55,7 @@ public abstract class AbstractTracingFeature extends AbstractGcnServiceFeature {
private final OpenTelemetryHttp openTelemetryHttp;
private final OpenTelemetry openTelemetry;
private final OpenTelemetryAnnotations openTelemetryAnnotations;
private final HttpClient httpClient;

/**
* @param openTelemetry OpenTelemetry feature
Expand All @@ -62,10 +64,12 @@ public abstract class AbstractTracingFeature extends AbstractGcnServiceFeature {
*/
protected AbstractTracingFeature(OpenTelemetry openTelemetry,
OpenTelemetryHttp openTelemetryHttp,
OpenTelemetryAnnotations openTelemetryAnnotations) {
OpenTelemetryAnnotations openTelemetryAnnotations,
HttpClient httpClient) {
this.openTelemetry = openTelemetry;
this.openTelemetryHttp = openTelemetryHttp;
this.openTelemetryAnnotations = openTelemetryAnnotations;
this.httpClient = httpClient;
}

@Override
Expand All @@ -91,6 +95,7 @@ public final void apply(GcnGeneratorContext generatorContext) {
openTelemetryAnnotations.apply(generatorContext);

if (generatorContext.generateExampleCode() && generatorContext.getApplicationType() == DEFAULT) {
httpClient.apply(generatorContext);

generatorContext.addTemplate(getDefaultModule(), "InventoryService",
generatorContext.getSourcePath("/{packagePath}/InventoryService"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.micronaut.starter.feature.opentelemetry.OpenTelemetryExporterOtlp;
import io.micronaut.starter.feature.opentelemetry.OpenTelemetryHttp;
import io.micronaut.starter.feature.opentelemetry.OpenTelemetryXray;
import io.micronaut.starter.feature.other.HttpClient;
import jakarta.inject.Singleton;

import static cloud.graal.gcn.model.GcnCloud.AWS;
Expand All @@ -50,8 +51,9 @@ public AwsTracing(OpenTelemetry openTelemetry,
OpenTelemetryHttp openTelemetryHttp,
OpenTelemetryAnnotations openTelemetryAnnotations,
OpenTelemetryXray openTelemetryXray,
OpenTelemetryExporterOtlp openTelemetryExporterOtlp) {
super(openTelemetry, openTelemetryHttp, openTelemetryAnnotations);
OpenTelemetryExporterOtlp openTelemetryExporterOtlp,
HttpClient httpClient) {
super(openTelemetry, openTelemetryHttp, openTelemetryAnnotations, httpClient);
this.openTelemetryXray = openTelemetryXray;
this.openTelemetryExporterOtlp = openTelemetryExporterOtlp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.micronaut.starter.feature.opentelemetry.OpenTelemetryAnnotations;
import io.micronaut.starter.feature.opentelemetry.OpenTelemetryGoogleCloudTrace;
import io.micronaut.starter.feature.opentelemetry.OpenTelemetryHttp;
import io.micronaut.starter.feature.other.HttpClient;
import jakarta.inject.Singleton;

import static cloud.graal.gcn.model.GcnCloud.GCP;
Expand All @@ -47,8 +48,9 @@ public class GcpTracing extends AbstractTracingFeature {
public GcpTracing(OpenTelemetry openTelemetry,
OpenTelemetryHttp openTelemetryHttp,
OpenTelemetryAnnotations openTelemetryAnnotations,
OpenTelemetryGoogleCloudTrace openTelemetryGoogleCloudTrace) {
super(openTelemetry, openTelemetryHttp, openTelemetryAnnotations);
OpenTelemetryGoogleCloudTrace openTelemetryGoogleCloudTrace,
HttpClient httpClient) {
super(openTelemetry, openTelemetryHttp, openTelemetryAnnotations, httpClient);
this.openTelemetryGoogleCloudTrace = openTelemetryGoogleCloudTrace;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.micronaut.starter.feature.opentelemetry.OpenTelemetry;
import io.micronaut.starter.feature.opentelemetry.OpenTelemetryAnnotations;
import io.micronaut.starter.feature.opentelemetry.OpenTelemetryHttp;
import io.micronaut.starter.feature.other.HttpClient;
import jakarta.inject.Singleton;

import static cloud.graal.gcn.model.GcnCloud.NONE;
Expand All @@ -40,8 +41,9 @@ public class NonCloudTracing extends AbstractTracingFeature {
*/
public NonCloudTracing(OpenTelemetry openTelemetry,
OpenTelemetryHttp openTelemetryHttp,
OpenTelemetryAnnotations openTelemetryAnnotations) {
super(openTelemetry, openTelemetryHttp, openTelemetryAnnotations);
OpenTelemetryAnnotations openTelemetryAnnotations,
HttpClient httpClient) {
super(openTelemetry, openTelemetryHttp, openTelemetryAnnotations, httpClient);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.micronaut.starter.feature.opentelemetry.OpenTelemetry;
import io.micronaut.starter.feature.opentelemetry.OpenTelemetryAnnotations;
import io.micronaut.starter.feature.opentelemetry.OpenTelemetryHttp;
import io.micronaut.starter.feature.other.HttpClient;
import jakarta.inject.Singleton;

import static cloud.graal.gcn.model.GcnCloud.OCI;
Expand All @@ -41,8 +42,9 @@ public class OciTracing extends AbstractTracingFeature {
*/
public OciTracing(OpenTelemetry openTelemetry,
OpenTelemetryHttp openTelemetryHttp,
OpenTelemetryAnnotations openTelemetryAnnotations) {
super(openTelemetry, openTelemetryHttp, openTelemetryAnnotations);
OpenTelemetryAnnotations openTelemetryAnnotations,
HttpClient httpClient) {
super(openTelemetry, openTelemetryHttp, openTelemetryAnnotations, httpClient);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public class BuildGradlePostProcessor implements TemplatePostProcessor {
" images = [\"${rootProject.name}-${project.name}\"]\n" +
"}\n";

private static final String SHADOW_JAR_ZIP_64_GROOVY =
"\ntasks.named('shadowJar') {\n" +
" zip64 = true\n" +
"}\n";

private static final String DOCKER_IMAGE_NAME_KOTLIN =
"\ntasks.named<com.bmuschko.gradle.docker.tasks.image.DockerBuildImage>(\"dockerBuild\") {\n" +
" images.add(\"${rootProject.name}-${project.name}\")\n" +
Expand All @@ -62,6 +67,10 @@ public class BuildGradlePostProcessor implements TemplatePostProcessor {
"\ntasks.named<com.bmuschko.gradle.docker.tasks.image.DockerBuildImage>(\"dockerBuildNative\") {\n" +
" images.add(\"${rootProject.name}-${project.name}\")\n" +
"}\n";
private static final String SHADOW_JAR_ZIP_64_KOTLIN =
"\ntasks.shadowJar {\n" +
" setProperty(\"zip64\", true)\n" +
"}\n";

private static final Pattern VERSION = Pattern.compile(" version \".+\"");

Expand Down Expand Up @@ -104,6 +113,7 @@ public String process(@NonNull String buildGradle) {
}
if (forCloudModule && applicationType == ApplicationType.DEFAULT && !isGatewayFunction) {
buildGradle = configureDockerNativeImageName(buildGradle);
buildGradle = configureShadowJarZip64(buildGradle);
}
buildGradle = removePluginVersions(buildGradle);
buildGradle = makeBomEnforced(buildGradle);
Expand Down Expand Up @@ -135,6 +145,15 @@ private String configureDockerNativeImageName(@NonNull String buildGradle) {
}
}

@NonNull
private String configureShadowJarZip64(@NonNull String buildGradle) {
if (dsl == GROOVY) {
return buildGradle.contains(SHADOW_JAR_ZIP_64_GROOVY) ? buildGradle : buildGradle + SHADOW_JAR_ZIP_64_GROOVY;
} else {
return buildGradle.contains(SHADOW_JAR_ZIP_64_KOTLIN) ? buildGradle : buildGradle + SHADOW_JAR_ZIP_64_KOTLIN;
}
}

@NonNull
private String removePluginVersions(@NonNull String buildGradle) {
return VERSION.matcher(buildGradle).replaceAll("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,12 @@
import io.micronaut.core.annotation.NonNull;
import io.micronaut.starter.application.ApplicationType;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static cloud.graal.gcn.GcnUtils.BOM_VERSION_SUFFIX;
import static cloud.graal.gcn.GcnUtils.LIB_MODULE;
import static cloud.graal.gcn.GcnUtils.MICRONAUT_MAVEN_DEFAULT_DOCKER_IMAGE;

/**
* Fixes a few issues in Maven pom.xml files:
Expand Down Expand Up @@ -106,7 +101,6 @@ public String process(@NonNull String pom) {
if (libModule) {
pom = fixArtifactId(pom);
pom = fixProcessingModule(pom);
pom = fixProperties(pom);
} else {
if (applicationType == ApplicationType.DEFAULT && !isGatewayFunction) {
pom = addDefaultDockerImageName(pom);
Expand All @@ -119,21 +113,6 @@ public String process(@NonNull String pom) {
return pom;
}

private String fixProperties(String pom) {
Set<String> itemsToRemove = new HashSet<>();
itemsToRemove.add("<micronaut.native-image.base-image-run>%s</micronaut.native-image.base-image-run>".formatted(MICRONAUT_MAVEN_DEFAULT_DOCKER_IMAGE));
List<String> newPom = new ArrayList<>();
String[] split = pom.split("\n");

for (String part: split) {
if (!itemsToRemove.contains(part.trim())) {
newPom.add(part);
}
}

return String.join("\n", newPom) + "\n";
}

private String fixSourceDirectory(@NonNull String pom) {
if (libModule) {
pom = pom.replaceFirst(" <sourceDirectory>src/main/jte</sourceDirectory>", " <sourceDirectory>lib/src/main/jte</sourceDirectory>");
Expand Down
1 change: 1 addition & 0 deletions gcn/gcn-core/src/main/resources/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.2.1-2
2 changes: 1 addition & 1 deletion gcn/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
1 change: 0 additions & 1 deletion gcn/version.txt

This file was deleted.

0 comments on commit e6f5284

Please sign in to comment.