Skip to content

Commit

Permalink
4.0.7 release (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
burtbeckwith authored Oct 16, 2023
1 parent 4ef52a6 commit 5a87ebf
Show file tree
Hide file tree
Showing 16 changed files with 2,076 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package cloud.graal.gcn.command;

import cloud.graal.gcn.GcnVersionInfo;
import io.micronaut.core.annotation.ReflectiveAccess;
import io.micronaut.starter.util.VersionInfo;
import picocli.CommandLine.Command;
import picocli.CommandLine.IVersionProvider;
import picocli.CommandLine.Option;
Expand Down Expand Up @@ -50,7 +50,7 @@ public class GcnCommonOptionsMixin {
*/
public static class GcnVersionProvider implements IVersionProvider {
public String[] getVersion() {
return new String[]{"GCN Version: " + VersionInfo.getMicronautVersion()};
return new String[]{"GCN Version: " + GcnVersionInfo.getMicronautVersion()};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import io.micronaut.starter.template.Template;
import io.micronaut.starter.template.URLTemplate;
import io.micronaut.starter.util.NameUtils;
import io.micronaut.starter.util.VersionInfo;

import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -77,6 +76,7 @@
import java.util.stream.Collectors;

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.model.GcnCloud.AWS;
import static cloud.graal.gcn.model.GcnCloud.NONE;
Expand Down Expand Up @@ -110,17 +110,16 @@ public class GcnGeneratorContext extends GeneratorContext {
private static final String PLUGIN_MAVEN_AZUREFUNCTIONS = "azure-functions-maven-plugin";
private static final Map<String, String> PLUGIN_GAVS = Map.of(
"com.github.johnrengelman.shadow:8.1.1", "com.github.johnrengelman:shadow:8.1.1",
"io.micronaut.application:4.0.2", "io.micronaut.gradle:micronaut-gradle-plugin:4.0.2",
"io.micronaut.library:4.0.2", "io.micronaut.gradle:micronaut-gradle-plugin:4.0.2",
"io.micronaut.test-resources:4.0.2", "io.micronaut.gradle:micronaut-test-resources-plugin:4.0.2",
"io.micronaut.application:4.0.3", "io.micronaut.gradle:micronaut-gradle-plugin:4.0.3",
"io.micronaut.library:4.0.3", "io.micronaut.gradle:micronaut-gradle-plugin:4.0.3",
"io.micronaut.test-resources:4.0.3", "io.micronaut.gradle:micronaut-test-resources-plugin:4.0.3",
"org.jetbrains.kotlin.jvm:1.8.22", "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.22",
"org.jetbrains.kotlin.kapt:1.8.22", "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.22",
"org.jetbrains.kotlin.plugin.allopen:1.8.22", "org.jetbrains.kotlin:kotlin-allopen:1.8.22",
"com.google.cloud.tools.jib:2.8.0", "com.google.cloud.tools.jib:com.google.cloud.tools.jib.gradle.plugin:2.8.0",
"io.micronaut.aot:4.0.2", "io.micronaut.gradle:micronaut-aot-plugin:4.0.2",
"com.google.devtools.ksp:1.8.22-1.0.11", "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:1.8.22-1.0.11"
);
private static final String ORACLE_REPOSITORY_VERSION = "-oracle-00001";

private GcnCloud cloud = NONE;
private boolean hideLibFeatures;
Expand Down Expand Up @@ -163,7 +162,7 @@ public GcnGeneratorContext(Project project,
clouds = new HashSet<>(cloudFeatures.keySet());
clouds.add(NONE); // for lib module
buildProperties = new GcnBuildProperties(this, clouds);
buildProperties.put(key, VersionInfo.getMicronautVersion() + ORACLE_REPOSITORY_VERSION);
buildProperties.put(key, GcnVersionInfo.getMicronautVersion() + BOM_VERSION_SUFFIX);
}

private static Map<GcnCloud, GcnFeatures> splitFeatures(Set<Feature> allFeatures,
Expand Down
3 changes: 1 addition & 2 deletions gcn/gcn-core/src/main/java/cloud/graal/gcn/GcnUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package cloud.graal.gcn;

import io.micronaut.starter.options.JdkVersion;
import io.micronaut.starter.util.VersionInfo;

import java.util.List;

Expand Down Expand Up @@ -66,6 +65,6 @@ private GcnUtils() {
* @return the version of Micronaut
*/
public static String getMicronautVersion() {
return VersionInfo.getMicronautVersion();
return GcnVersionInfo.getMicronautVersion();
}
}
48 changes: 48 additions & 0 deletions gcn/gcn-core/src/main/java/cloud/graal/gcn/GcnVersionInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2023 Oracle and/or its affiliates
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cloud.graal.gcn;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.util.Properties;

import static java.nio.charset.StandardCharsets.UTF_8;

public class GcnVersionInfo {

private static final Properties VERSIONS = new Properties();

static {
URL resource = GcnVersionInfo.class.getResource("/gcn-platform-versions.properties");
if (resource != null) {
try (Reader reader = new InputStreamReader(resource.openStream(), UTF_8)) {
VERSIONS.load(reader);
} catch (IOException ignored) {
// ignore
}
}
}

public static String getMicronautVersion() {
Object micronautVersion = VERSIONS.get("micronaut.platform.version");
if (micronautVersion != null) {
return micronautVersion.toString();
}
return "2.0.0";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public class GcnBom implements DefaultFeature, RequiresRepository {
private static final Dependency BOM = Dependency.builder()
.groupId("cloud.graal.gcn")
.artifactId("gcn-bom")
.version("2.0")
//.version("2.0")
.version("2.1")
.pom()
.compile()
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.util.List;
import java.util.stream.Collectors;


/**
* Extends MavenBuildCreator to add the Oracle Maven repo.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2023 Oracle and/or its affiliates
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cloud.graal.gcn.feature.create.app;

import cloud.graal.gcn.GcnGeneratorContext;
import cloud.graal.gcn.feature.GcnFeatureContext;
import cloud.graal.gcn.feature.create.AbstractGcnCreateFeature;
import cloud.graal.gcn.model.GcnCloud;
import cloud.graal.gcn.model.GcnProjectType;
import io.micronaut.core.annotation.NonNull;
import io.micronaut.starter.feature.lang.java.JavaApplication;
import jakarta.inject.Singleton;

import static cloud.graal.gcn.model.GcnCloud.NONE;
import static cloud.graal.gcn.model.GcnProjectType.SPRING_BOOT_APPLICATION;

/**
* Base class for Spring Boot create-app features.
*
* @since 4.0.0
*/
@Singleton
public class GcnSpringBootCloudApp extends AbstractGcnCreateFeature {

@NonNull
@Override
public GcnProjectType getProjectType() {
return SPRING_BOOT_APPLICATION;
}

@Override
public GcnCloud getCloud() {
return NONE;
}

@NonNull
@Override
public String getName() {
return "gcn-spring-boot-app";
}

@Override
public void processSelectedFeatures(GcnFeatureContext featureContext) {
// exclude default Application and ApplicationTest classes
featureContext.exclude(feature -> feature instanceof JavaApplication);
}

@Override
public void apply(GcnGeneratorContext generatorContext) {
// Do nothing
// gradle or maven files and Application file are copied
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@import io.micronaut.starter.feature.database.JpaFeature
@import io.micronaut.starter.feature.Features
@import io.micronaut.starter.util.VersionInfo
@import cloud.graal.gcn.GcnVersionInfo

@args (Project project, Features features, MavenBuild mavenBuild)

Expand All @@ -22,7 +23,7 @@
<parent>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-parent</artifactId>
<version>@VersionInfo.getMicronautVersion()</version>
<version>@GcnVersionInfo.getMicronautVersion()</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ public enum GcnProjectType {
/**
* A gateway function project.
*/
GATEWAY_FUNCTION(ApplicationType.DEFAULT, "Gateway Function", "create-gateway-function");
GATEWAY_FUNCTION(ApplicationType.DEFAULT, "Gateway Function", "create-gateway-function"),

/**
* A Spring boot application project.
*/
SPRING_BOOT_APPLICATION(ApplicationType.DEFAULT, "Spring Boot Application", "create-spring-boot-app");

/**
* The default type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,31 @@
*/
package cloud.graal.gcn.template;

import cloud.graal.gcn.GcnVersionInfo;
import io.micronaut.core.annotation.NonNull;
import io.micronaut.starter.util.VersionInfo;

import java.util.regex.Pattern;

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

/**
* MavenPlatformIndependentPostProcessor fixes parent element in platform idependent pom.xml and multimodule root pom.xml
* Fixes parent element in platform independent pom.xml and multi-module root pom.xml.
*/
public class MavenPlatformPostProcessor implements TemplatePostProcessor {

private static final String PARENT_END = " </parent>";
private static final String PARENT_START = " <parent>";
private static final Pattern VERSION_PATTERN = Pattern.compile("<version>.+</version>");

public MavenPlatformPostProcessor() {
}

@NonNull
@Override
public String process(@NonNull String pom) {
pom = fixParent(pom);
return pom;
}

@NonNull
private String fixParent(@NonNull String pom) {
int start = pom.indexOf(PARENT_START);
int end = pom.indexOf(PARENT_END, start) + PARENT_END.length();
String top = pom.substring(0, start);
String bottom = pom.substring(end);
String parent = pom.substring(start, end);
parent = VERSION_PATTERN.matcher(parent).replaceAll(String.format("<version>%s</version>", VersionInfo.getMicronautVersion() + BOM_VERSION_SUFFIX));
parent = VERSION_PATTERN.matcher(parent).replaceAll(String.format("<version>%s</version>", GcnVersionInfo.getMicronautVersion() + BOM_VERSION_SUFFIX));
return top + parent + bottom;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private String fixProcessingModule(@NonNull String pom) {
}

@NonNull
// TODO: remove when base image is updated inside maven plugin
// TODO remove when base image is updated inside maven plugin
private String fixDefaultBaseImage(@NonNull String pom) {
int start = pom.indexOf("micronaut-maven-plugin");
if (start == -1) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
micronaut.platform.version=4.0.7
Loading

0 comments on commit 5a87ebf

Please sign in to comment.