From 49ed70b022b0030c9258c36a61db968dca916a4a Mon Sep 17 00:00:00 2001 From: Burt Beckwith Date: Tue, 23 Apr 2024 10:07:05 -0400 Subject: [PATCH] 4.3.7.2 release (#22) --- .../cloud/graal/gcn/GcnGeneratorContext.java | 17 +++------ .../graal/gcn/feature/replaced/GcnMaven.java | 16 +++++---- .../metrics/AbstractMetricsFeature.java | 10 ++++++ .../service/objectstore/AzureObjectStore.java | 4 +-- .../service/objectstore/GcpObjectStore.java | 9 +++-- .../gcn/template/GcnPropertiesTemplate.java | 36 +++++++++++-------- gcn/gradle.properties | 2 +- 7 files changed, 53 insertions(+), 41 deletions(-) diff --git a/gcn/gcn-core/src/main/java/cloud/graal/gcn/GcnGeneratorContext.java b/gcn/gcn-core/src/main/java/cloud/graal/gcn/GcnGeneratorContext.java index 929dbac..bf50741 100644 --- a/gcn/gcn-core/src/main/java/cloud/graal/gcn/GcnGeneratorContext.java +++ b/gcn/gcn-core/src/main/java/cloud/graal/gcn/GcnGeneratorContext.java @@ -278,10 +278,10 @@ private static Map splitFeatures(Set allFeatures public void setCloud(GcnCloud cloud) { this.cloud = cloud; if (cloud != NONE) { - applicationConfigurations.putIfAbsent(cloud, new ApplicationConfiguration()); - cloudApplicationConfigurations.putIfAbsent(cloud, new ApplicationConfiguration()); - bootstrapConfigurations.putIfAbsent(cloud, new BootstrapConfiguration()); - cloudBootstrapConfigurations.putIfAbsent(cloud, new BootstrapConfiguration()); + applicationConfigurations.putIfAbsent(cloud, new ApplicationConfiguration(cloud.getModuleName())); + cloudApplicationConfigurations.putIfAbsent(cloud, new ApplicationConfiguration(cloud.getModuleName())); + bootstrapConfigurations.putIfAbsent(cloud, new BootstrapConfiguration(cloud.getModuleName())); + cloudBootstrapConfigurations.putIfAbsent(cloud, new BootstrapConfiguration(cloud.getModuleName())); cloudDependencyContexts.putIfAbsent(cloud, new DependencyContextImpl(coordinateResolver)); cloudProjects.putIfAbsent(cloud, createProject(cloud)); } @@ -1057,21 +1057,12 @@ public Set getBuildPluginsGAV() { gavs.add(JTE_GROUP_ID + ":" + JTE_NATIVE_RESOURCES + ":" + plugin.getVersion()); } - gav = updateVersion(gav); gavs.add(gav); } return gavs; } - // TODO remove this once we upgrade to a version of Micronaut that uses these plugin versions or higher - private String updateVersion(String gav) { - if (gav.startsWith("io.micronaut.gradle:") && gav.endsWith(":3.7.2")) { - gav = gav.replace("3.7.2", "3.7.7"); - } - return gav; - } - @Override public String toString() { StringBuilder sb = new StringBuilder("GcnGeneratorContext:\n"); diff --git a/gcn/gcn-core/src/main/java/cloud/graal/gcn/feature/replaced/GcnMaven.java b/gcn/gcn-core/src/main/java/cloud/graal/gcn/feature/replaced/GcnMaven.java index b4e15ed..69162a4 100644 --- a/gcn/gcn-core/src/main/java/cloud/graal/gcn/feature/replaced/GcnMaven.java +++ b/gcn/gcn-core/src/main/java/cloud/graal/gcn/feature/replaced/GcnMaven.java @@ -101,23 +101,26 @@ public void apply(GeneratorContext generatorContext) { private void addMavenBuild(GcnGeneratorContext generatorContext) { - GcnCloud reset = generatorContext.getCloud(); + GcnCloud currentCloud = generatorContext.getCloud(); - generatorContext.getClouds().forEach(x -> cloudPom(generatorContext, x)); + for (GcnCloud cloud : generatorContext.getClouds()) { + cloudPom(generatorContext, cloud); + } + + generatorContext.setCloud(currentCloud); - generatorContext.setCloud(reset); + String templateName = generatorContext.getModuleNames().size() > 1 ? "multi-module-pom" : "mavenPom"; // this is called for each cloud, but the templates are stored in a Map, so it's idempotent - generatorContext.addTemplate("multi-module-pom", new RockerTemplate(ROOT, generatorContext.getBuildTool().getBuildFileName(), + generatorContext.addTemplate(templateName, new RockerTemplate(ROOT, generatorContext.getBuildTool().getBuildFileName(), multimodule.template(MavenRepository.listOf(repositoryResolver.resolveRepositories(generatorContext)), generatorContext.getLibProject(), generatorContext.getModuleNames()) )); - generatorContext.addPostProcessor("multi-module-pom", new MavenPlatformPostProcessor()); + generatorContext.addPostProcessor(templateName, new MavenPlatformPostProcessor()); if (generatorContext.getClouds().size() > 1) { - // this is called for each cloud, but the post processors are stored in a Set, so it's idempotent generatorContext.addPostProcessor("mavenPom", new MavenPomPostProcessor( generatorContext.getLibProject().getName(), @@ -142,7 +145,6 @@ private void cloudPom(GcnGeneratorContext generatorContext, GcnCloud gcnCloud) { MavenBuild mavenBuild = mavenBuildCreator.create(generatorContext, repositoryResolver.resolveRepositories(generatorContext)); String templateKey = "mavenPom-" + gcnCloud.getModuleName(); - if (templateKey.equals("mavenPom-")) { templateKey = "mavenPom"; } diff --git a/gcn/gcn-core/src/main/java/cloud/graal/gcn/feature/service/metrics/AbstractMetricsFeature.java b/gcn/gcn-core/src/main/java/cloud/graal/gcn/feature/service/metrics/AbstractMetricsFeature.java index 0977cc3..023c115 100644 --- a/gcn/gcn-core/src/main/java/cloud/graal/gcn/feature/service/metrics/AbstractMetricsFeature.java +++ b/gcn/gcn-core/src/main/java/cloud/graal/gcn/feature/service/metrics/AbstractMetricsFeature.java @@ -91,6 +91,16 @@ public final void apply(GcnGeneratorContext generatorContext) { } }); + generatorContext.getConfiguration().addNested(Map.of( + "micronaut.metrics.enabled", "true", + "micronaut.metrics.binders.files.enabled", "true", + "micronaut.metrics.binders.jvm.enabled", "true", + "micronaut.metrics.binders.logback.enabled", "true", + "micronaut.metrics.binders.processor.enabled", "true", + "micronaut.metrics.binders.uptime.enabled", "true", + "micronaut.metrics.binders.web.enabled", "true" + )); + if (generatorContext.generateExampleCode() && generatorContext.getApplicationType() == DEFAULT) { generatorContext.getTestConfiguration().addNested(Map.of( diff --git a/gcn/gcn-core/src/main/java/cloud/graal/gcn/feature/service/objectstore/AzureObjectStore.java b/gcn/gcn-core/src/main/java/cloud/graal/gcn/feature/service/objectstore/AzureObjectStore.java index 2967891..a312d00 100644 --- a/gcn/gcn-core/src/main/java/cloud/graal/gcn/feature/service/objectstore/AzureObjectStore.java +++ b/gcn/gcn-core/src/main/java/cloud/graal/gcn/feature/service/objectstore/AzureObjectStore.java @@ -53,8 +53,8 @@ protected void addConfig(GcnGeneratorContext generatorContext) { generatorContext.getCloudConfiguration().addNested(Map.of( "micronaut.object-storage.azure.default.bucket", "true", - "micronaut.object-storage.azure.default.container", "${OBJECT_STORAGE_CONTAINER}", - "micronaut.object-storage.azure.default.endpoint", "${OBJECT_STORAGE_ENDPOINT}" + "micronaut.object-storage.azure.default.container", "", + "micronaut.object-storage.azure.default.endpoint", "" )); generatorContext.getTestConfiguration().addNested("micronaut.object-storage.azure.default.enabled", "false"); } diff --git a/gcn/gcn-core/src/main/java/cloud/graal/gcn/feature/service/objectstore/GcpObjectStore.java b/gcn/gcn-core/src/main/java/cloud/graal/gcn/feature/service/objectstore/GcpObjectStore.java index dd876e9..1203edc 100644 --- a/gcn/gcn-core/src/main/java/cloud/graal/gcn/feature/service/objectstore/GcpObjectStore.java +++ b/gcn/gcn-core/src/main/java/cloud/graal/gcn/feature/service/objectstore/GcpObjectStore.java @@ -22,6 +22,8 @@ import io.micronaut.starter.feature.objectstorage.ObjectStorageGcp; import jakarta.inject.Singleton; +import java.util.Map; + import static cloud.graal.gcn.model.GcnCloud.GCP; /** @@ -53,10 +55,11 @@ protected void addConfig(GcnGeneratorContext generatorContext) { // gcp: // default: // bucket: - generatorContext.getCloudConfiguration().addNested("micronaut.object-storage.gcp.default.bucket", ""); - generatorContext.getCloudConfiguration().addNested("micronaut.object-storage.gcp.default.enabled", "true"); + generatorContext.getCloudConfiguration().addNested(Map.of( + "micronaut.object-storage.gcp.default.bucket", "", + "micronaut.object-storage.gcp.default.enabled", "true" + )); generatorContext.getTestConfiguration().addNested("micronaut.object-storage.gcp.default.enabled", "false"); - } @NonNull diff --git a/gcn/gcn-core/src/main/java/cloud/graal/gcn/template/GcnPropertiesTemplate.java b/gcn/gcn-core/src/main/java/cloud/graal/gcn/template/GcnPropertiesTemplate.java index 11e8fa3..bba9417 100644 --- a/gcn/gcn-core/src/main/java/cloud/graal/gcn/template/GcnPropertiesTemplate.java +++ b/gcn/gcn-core/src/main/java/cloud/graal/gcn/template/GcnPropertiesTemplate.java @@ -42,25 +42,31 @@ public GcnPropertiesTemplate(String module, String path, Map con @Override public void write(OutputStream outputStream) throws IOException { - OutputStream outputStream1 = new OutputStream() { - private final StringBuilder string = new StringBuilder(); - @Override + final StringBuilder buffer = new StringBuilder(); + + properties.store(new OutputStream() { public void write(int b) { - this.string.append((char) b); + buffer.append((char) b); } + }, null); - public String toString() { - return this.string.toString(); - } - }; - - properties.store(outputStream1, null); - String string = outputStream1.toString(); - string = string.substring(string.indexOf('\n') + 1); - List lines = Stream.of(string.split("\n")).sorted().toList(); - string = String.join("\n", lines); - outputStream.write(string.getBytes()); + String renderedProperties = buffer.toString(); + + // remove date comment + String cleanedProperties; + if (renderedProperties.startsWith("#")) { + cleanedProperties = renderedProperties.substring(renderedProperties.indexOf(System.lineSeparator()) + 1); + } else { + cleanedProperties = renderedProperties; + } + + // sort the properties + List lines = Stream.of(cleanedProperties.split(System.lineSeparator())).sorted().toList(); + + cleanedProperties = String.join(System.lineSeparator(), lines); + + outputStream.write(cleanedProperties.getBytes()); } public Map getOriginalConfig() { diff --git a/gcn/gradle.properties b/gcn/gradle.properties index 2863eb3..51771d9 100644 --- a/gcn/gradle.properties +++ b/gcn/gradle.properties @@ -1,3 +1,3 @@ org.gradle.parallel=true org.gradle.caching=true -version=4.3.7.1 +version=4.3.7.2