Skip to content

Commit

Permalink
update to 4.0 (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
burtbeckwith authored Sep 18, 2023
1 parent 13b4f9b commit 914d3d9
Show file tree
Hide file tree
Showing 121 changed files with 4,247 additions and 2,012 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ build/
dev.properties
out/
target/
gen/
mdguides/
mdinfo/
Thumbs.db
2,878 changes: 1,605 additions & 1,273 deletions THIRD_PARTY_LICENSES.txt

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions gcn/buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ repositories {
}

dependencies {
implementation libs.micronaut.application
implementation libs.micronaut.library
implementation libs.nohttp
implementation libs.rocker
implementation libs.shadow
implementation libs.spotless
implementation libs.test.logger
}

gradlePlugin {
Expand Down
6 changes: 3 additions & 3 deletions gcn/buildSrc/src/main/groovy/gcn-base.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ repositories {
dependencies {
compileOnly mnLibs.jsr305 // for 'warning: unknown enum constant When.MAYBE'
implementation mnLibs.jakarta.annotation.api
runtimeOnly mnLibs.logback
runtimeOnly libs.logback.classic
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

java {
Expand Down
10 changes: 7 additions & 3 deletions gcn/gcn-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

plugins {
id 'gcn-module'
alias libs.plugins.micronaut.application
alias libs.plugins.shadow
id 'io.micronaut.application'
id 'com.github.johnrengelman.shadow'
}

dependencies {
Expand All @@ -26,7 +26,7 @@ dependencies {
compileOnly mnLibs.graal

// not in libs.versions.toml to keep Micronaut version in 1 place (micronautVersion.txt)
implementation("io.micronaut.starter:micronaut-micronaut-cli:$micronautVersion") {
implementation("io.micronaut.starter:micronaut-cli:$micronautVersion") {
exclude group: 'io.micronaut', module: 'micronaut-buffer-netty'
exclude group: 'io.micronaut', module: 'micronaut-http-client'
exclude group: 'io.micronaut', module: 'micronaut-http-client-core'
Expand Down Expand Up @@ -59,6 +59,10 @@ dependencies {
implementation projects.gcnCore
}

configurations.all {
exclude module: 'logback-classic'
}

application {
mainClass.set 'cloud.graal.gcn.GcnStarter'
}
Expand Down
2 changes: 1 addition & 1 deletion gcn/gcn-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
plugins {
id 'gcn-module'
id 'gcn.rocker'
alias libs.plugins.micronaut.library
id 'io.micronaut.library'
}

dependencies {
Expand Down
53 changes: 38 additions & 15 deletions gcn/gcn-core/src/main/java/cloud/graal/gcn/GcnGeneratorContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import cloud.graal.gcn.feature.GcnFeatureContext;
import cloud.graal.gcn.feature.GcnFeatures;
import cloud.graal.gcn.model.GcnCloud;
import cloud.graal.gcn.template.GcnYamlTemplate;
import cloud.graal.gcn.template.GcnPropertiesTemplate;
import cloud.graal.gcn.template.TemplatePostProcessor;
import com.fizzed.rocker.RockerModel;
import io.micronaut.core.annotation.NonNull;
Expand All @@ -39,6 +39,7 @@
import io.micronaut.starter.feature.DefaultFeature;
import io.micronaut.starter.feature.Feature;
import io.micronaut.starter.feature.RequireEagerSingletonInitializationFeature;
import io.micronaut.starter.feature.aws.AwsCloudFeature;
import io.micronaut.starter.feature.build.BuildFeature;
import io.micronaut.starter.feature.build.BuildPluginFeature;
import io.micronaut.starter.feature.config.ApplicationConfiguration;
Expand All @@ -54,6 +55,7 @@
import io.micronaut.starter.options.DefaultTestRockerModelProvider;
import io.micronaut.starter.options.Language;
import io.micronaut.starter.options.TestRockerModelProvider;
import io.micronaut.starter.template.PropertiesTemplate;
import io.micronaut.starter.template.RockerTemplate;
import io.micronaut.starter.template.Template;
import io.micronaut.starter.template.URLTemplate;
Expand All @@ -74,7 +76,9 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import static cloud.graal.gcn.GcnUtils.APP_MODULE;
import static cloud.graal.gcn.GcnUtils.LIB_MODULE;
import static cloud.graal.gcn.model.GcnCloud.AWS;
import static cloud.graal.gcn.model.GcnCloud.NONE;
import static io.micronaut.context.env.Environment.DEVELOPMENT;
import static io.micronaut.context.env.Environment.FUNCTION;
Expand Down Expand Up @@ -105,15 +109,18 @@ public class GcnGeneratorContext extends GeneratorContext {
private static final String PLUGIN_GRADLE_AZUREFUNCTIONS = "com.microsoft.azure.azurefunctions";
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:7.1.2", "gradle.plugin.com.github.johnrengelman:shadow:7.1.2",
"io.micronaut.application:3.7.2", "io.micronaut.gradle:micronaut-gradle-plugin:3.7.2",
"io.micronaut.library:3.7.2", "io.micronaut.gradle:micronaut-gradle-plugin:3.7.2",
"io.micronaut.test-resources:3.7.2", "io.micronaut.gradle:micronaut-test-resources-plugin:3.7.2",
"org.jetbrains.kotlin.jvm:1.6.21", "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21",
"org.jetbrains.kotlin.kapt:1.6.21", "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21",
"org.jetbrains.kotlin.plugin.allopen:1.6.21", "org.jetbrains.kotlin:kotlin-allopen:1.6.21",
"com.google.cloud.tools.jib:2.8.0", "com.google.cloud.tools.jib:com.google.cloud.tools.jib.gradle.plugin:2.8.0"
"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",
"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 @@ -156,7 +163,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());
buildProperties.put(key, VersionInfo.getMicronautVersion() + ORACLE_REPOSITORY_VERSION);
}

private static Map<GcnCloud, GcnFeatures> splitFeatures(Set<Feature> allFeatures,
Expand All @@ -169,7 +176,21 @@ private static Map<GcnCloud, GcnFeatures> splitFeatures(Set<Feature> allFeatures
Set<Feature> defaultFeatures = new HashSet<>();
Set<Feature> specifiedFeatures = new HashSet<>();

Collection<GcnCloud> initialClouds = new HashSet<>();
for (Feature feature : allFeatures) {
if (feature instanceof GcnFeature) {
initialClouds.add(((GcnFeature) feature).getCloud());
}
}

for (Feature feature : allFeatures) {

if (feature instanceof AwsCloudFeature && !initialClouds.contains(AWS)) {
// AwsLambda implements DefaultFeature but causes problems when generating for non-AWS apps,
// and brings in other AWS features that implement AwsCloudFeature.
continue;
}

if (feature instanceof DefaultFeature &&
!(feature instanceof AwsLambda) &&
!(feature instanceof BuildFeature)) {
Expand Down Expand Up @@ -665,10 +686,10 @@ public void addTemplate(String name, Template template) {
}

if (!template.getModule().equals(ROOT)) {
if (template instanceof GcnYamlTemplate) {
if (isPlatformIndependent() && template.getModule().equals(LIB_MODULE)) {
if (template instanceof GcnPropertiesTemplate) {
if (isPlatformIndependent() && (template.getModule().equals(LIB_MODULE) || template.getModule().equals(APP_MODULE))) {
// for platform independent, re-route non-root templates to root
template = new GcnYamlTemplate(ROOT, template.getPath(), ((GcnYamlTemplate) template).getOriginalConfig());
template = new GcnPropertiesTemplate(ROOT, template.getPath(), ((GcnPropertiesTemplate) template).getOriginalConfig());
}
} else if (template instanceof RockerTemplate) {

Expand Down Expand Up @@ -734,11 +755,11 @@ private boolean isIgnoredAppTemplate(String name, Template template) {
return false;
}

if (template instanceof GcnYamlTemplate &&
if (template instanceof PropertiesTemplate &&
template.getModule().equals("lib") &&
"application-config".equals(name)) {

return true; // application.yml
return true; // application.properties
}

if (!(template instanceof RockerTemplate)) {
Expand Down Expand Up @@ -936,6 +957,8 @@ private Set<Feature> libFeatures() {
* Workaround for <a href="https://github.com/gradle/gradle/issues/17559">this Gradle bug</a>.
* This is called from the buildSrc/build.gradle template to lookup the Maven G/A/V
* coordinates for all plugins in all modules.
*
* @return the GAV strings, e.g. "io.micronaut.gradle:micronaut-test-resources-plugin:3.7.7"
*/
public Set<String> getBuildPluginsGAV() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
@Replaces(ProjectGenerator.class)
public class GcnProjectGenerator implements ProjectGenerator {

private final GcnContextFactory contextFactory;
private final List<Feature> features;
private final GcnContextFactory contextFactory;

/**
* @param contextFactory context factory
Expand Down Expand Up @@ -91,7 +91,6 @@ public void generate(ApplicationType applicationType,
GcnGeneratorContext generatorContext = (GcnGeneratorContext) gc;

addMicronautCli(generatorContext, applicationType);

generatorContext.applyFeatures();

try (GcnTemplateRenderer templateRenderer = new GcnTemplateRenderer(project, outputHandler,
Expand All @@ -105,6 +104,15 @@ public void generate(ApplicationType applicationType,
}
}

/**
* Add a feature; only used in test project generation.
*
* @param feature the feature
*/
public void addFeature(Feature feature) {
features.add(feature);
}

private void addMicronautCli(GcnGeneratorContext generatorContext,
ApplicationType applicationType) {

Expand Down
2 changes: 2 additions & 0 deletions gcn/gcn-core/src/main/java/cloud/graal/gcn/GcnUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public final class GcnUtils {
*/
public static final String LIB_MODULE = "lib";

public static final String APP_MODULE = "app";

/**
* The default JDK version if none is specified.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@
import io.micronaut.starter.application.generator.GeneratorContext;
import io.micronaut.starter.build.dependencies.Dependency;

/**
* Implemented by OCI features that need Netty client dependencies.
*/
public interface OracleCloudNettyClientDependencies {

/**
* Adds the dependencies.
*
* @param generatorContext the context
*/
default void addNettyDependencies(GeneratorContext generatorContext) {
generatorContext.addDependency(Dependency.builder()
.groupId("io.micronaut.oraclecloud")
.artifactId("micronaut-oraclecloud-httpclient-netty")
.compile());

if (!generatorContext.getBuildTool().isGradle() && generatorContext.getFeatures().hasGraalvm()) {
generatorContext.addDependency(Dependency.builder()
.groupId("com.oracle.oci.sdk")
.artifactId("oci-java-sdk-addons-graalvm")
.compile());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public class GcnGradleBuild extends GradleBuild {

private final List<GradleRepository> repositories;

/**
* @param gradleDsl Gradle DSL
* @param dependencies dependencies
* @param plugins plugins
* @param repositories repos
*/
public GcnGradleBuild(@NonNull GradleDsl gradleDsl,
@NonNull List<GradleDependency> dependencies,
@NonNull List<GradlePlugin> plugins,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import io.micronaut.core.annotation.NonNull;
import io.micronaut.starter.build.Property;
import io.micronaut.starter.build.dependencies.Coordinate;
import io.micronaut.starter.build.dependencies.DependencyCoordinate;
import io.micronaut.starter.build.maven.MavenBuild;
import io.micronaut.starter.build.maven.MavenCombineAttribute;
import io.micronaut.starter.build.maven.MavenDependency;
Expand All @@ -37,18 +37,31 @@ public class GcnMavenBuild extends MavenBuild {

private final List<MavenRepository> repositories;

/**
* @param artifactId artifact ID
* @param annotationProcessors annotation processors
* @param testAnnotationProcessors test annotation processors
* @param dependencies dependencies
* @param properties properties
* @param plugins plugins
* @param repositories repos
* @param annotationProcessorCombineAttribute MavenCombineAttribute for annotation processors
* @param testAnnotationProcessorCombineAttribute MavenCombineAttribute for test annotation processors
* @param profiles profiles
*/
public GcnMavenBuild(String artifactId,
List<Coordinate> annotationProcessors,
List<Coordinate> testAnnotationProcessors,
List<DependencyCoordinate> annotationProcessors,
List<DependencyCoordinate> testAnnotationProcessors,
List<MavenDependency> dependencies,
List<Property> properties,
List<MavenPlugin> plugins,
List<MavenRepository> repositories,
MavenCombineAttribute annotationProcessorCombineAttribute,
MavenCombineAttribute testAnnotationProcessorCombineAttribute,
Collection<Profile> profiles) {
Collection<Profile> profiles,
List<DependencyCoordinate> aotDependencies) {
super(artifactId, annotationProcessors, testAnnotationProcessors, dependencies, properties, plugins,
repositories, annotationProcessorCombineAttribute, testAnnotationProcessorCombineAttribute, profiles);
repositories, annotationProcessorCombineAttribute, testAnnotationProcessorCombineAttribute, profiles, aotDependencies);
this.repositories = repositories;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import io.micronaut.starter.build.dependencies.Dependency;
import io.micronaut.starter.build.maven.MavenDependency;
import io.micronaut.starter.options.Language;

/**
* Renders a project dependency in a Maven build.
Expand All @@ -29,12 +30,13 @@ public class MavenProjectDependency extends MavenDependency {
* @param groupId group id
* @param projectName project name (used as artifact id)
*/
public MavenProjectDependency(String groupId, String projectName) {
public MavenProjectDependency(String groupId, String projectName, Language language) {
super(Dependency.builder()
.groupId(groupId)
.artifactId(projectName)
.version("1.0-SNAPSHOT")
.compile()
.build());
.groupId(groupId)
.artifactId(projectName)
.version("1.0-SNAPSHOT")
.compile()
.build(),
language);
}
}
Loading

0 comments on commit 914d3d9

Please sign in to comment.