Skip to content

Commit

Permalink
4.6.0.6 release (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
burtbeckwith authored Dec 3, 2024
1 parent bdb9568 commit 56929d7
Show file tree
Hide file tree
Showing 28 changed files with 468 additions and 190 deletions.
64 changes: 64 additions & 0 deletions gdk/buildSrc/src/main/groovy/gdk-cli.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright 2024 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.
*/

plugins {
id 'gdk-module'
id 'io.micronaut.application'
id 'com.github.johnrengelman.shadow'
}

dependencies {
annotationProcessor mnLibs.picocli.codegen

compileOnly mnLibs.graal

implementation projects.gdkCliCore

runtimeOnly libs.bouncycastle.bcpkix
runtimeOnly libs.bouncycastle.bcprov
runtimeOnly libs.jansi
runtimeOnly libs.jline
runtimeOnly libs.slf4j.nop
}

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

micronaut {
version libs.micronaut.starter.api.get().version
processing {
incremental true
annotations 'cloud.graal.gdk.*'
}
}

tasks.named('shadowJar') {
mergeServiceFiles()
}

tasks.named('shadowDistZip') {
enabled = false
}
tasks.named('shadowDistTar') {
enabled = false
}

tasks.register('copyShadowJar', Sync) {
from shadowJar.outputs
into "${project.rootProject.buildDir}/libs"
rename { String fileName -> 'cli.jar' }
}
33 changes: 33 additions & 0 deletions gdk/buildSrc/src/main/groovy/gdk-module-public.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2024 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.
*/

plugins {
id 'gdk-module'
id 'com.diffplug.spotless'
}

spotless {
java {
licenseHeaderFile rootProject.file('config/spotless.license.java')
target 'src/main/java/**'
targetExclude '**/*.rocker.raw', '**/GdkBaseCommand.java', '**/GdkStarter.java', '**/AbstractStarter.java'
}
format 'javaMisc', {
target 'src/main/**/package-info.java', 'src/main/**/module-info.java'
licenseHeaderFile rootProject.file('config/spotless.license.java'), '\\/\\*\\*'
}
}

13 changes: 0 additions & 13 deletions gdk/buildSrc/src/main/groovy/gdk-module.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,6 @@
plugins {
id 'gdk-base'
id 'checkstyle'
id 'com.diffplug.spotless'
}

spotless {
java {
licenseHeaderFile rootProject.file('config/spotless.license.java')
target 'src/main/java/**'
targetExclude '**/*.rocker.raw', '**/GdkBaseCommand.java', '**/GdkStarter.java'
}
format 'javaMisc', {
target 'src/main/**/package-info.java', 'src/main/**/module-info.java'
licenseHeaderFile rootProject.file('config/spotless.license.java'), '\\/\\*\\*'
}
}

publishing {
Expand Down
38 changes: 38 additions & 0 deletions gdk/buildSrc/src/main/groovy/gdk-testing.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2024 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.
*/

plugins {
id 'groovy'
id 'com.adarshr.test-logger'
id 'io.micronaut.library'
}

micronaut {
testRuntime 'spock2'
}

test {
maxHeapSize = '16G'
}

testlogger {
theme 'standard-parallel'
showFullStackTraces true
showStandardStreams true
showPassedStandardStreams false
showSkippedStandardStreams false
showFailedStandardStreams true
}
3 changes: 3 additions & 0 deletions gdk/gdk-cli-core/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
= gdk-cli-core

This submodule is a reusable library contains most of the code for the CLI except for the main class and the build configuration to enable running the CLI.
60 changes: 60 additions & 0 deletions gdk/gdk-cli-core/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2024 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.
*/

plugins {
id 'gdk-module-public'
id 'io.micronaut.library'
}

dependencies {
annotationProcessor mnLibs.picocli.codegen

// not in libs.versions.toml to keep Micronaut version in one place
api(libs.micronaut.starter.cli) {
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'
exclude group: 'io.micronaut', module: 'micronaut-http-netty'
exclude group: 'io.micronaut', module: 'micronaut-websocket'
exclude group: 'io.micronaut.testresources', module: 'micronaut-test-resources-build-tools'
exclude group: 'io.netty', module: 'netty-buffer'
exclude group: 'io.netty', module: 'netty-codec'
exclude group: 'io.netty', module: 'netty-codec-http'
exclude group: 'io.netty', module: 'netty-codec-http2'
exclude group: 'io.netty', module: 'netty-codec-socks'
exclude group: 'io.netty', module: 'netty-common'
exclude group: 'io.netty', module: 'netty-handler'
exclude group: 'io.netty', module: 'netty-handler-proxy'
exclude group: 'io.netty', module: 'netty-resolver'
exclude group: 'io.netty', module: 'netty-transport'
exclude group: 'io.swagger.core.v3', module: 'swagger-annotations'
exclude group: 'org.eclipse.jgit', module: 'org.eclipse.jgit'
exclude group: 'org.jline', module: 'jline'
}
api mnLibs.micronaut.picocli
api mnLibs.picocli
api mnLibs.micronaut.jackson.databind
api mnLibs.micronaut.validation
api projects.gdkCore
}

micronaut {
version libs.micronaut.starter.api.get().version
processing {
incremental true
annotations 'cloud.graal.gdk.*'
}
}
104 changes: 104 additions & 0 deletions gdk/gdk-cli-core/src/main/java/cloud/graal/gdk/AbstractStarter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright 2017-2022 original authors
* Copyright 2024 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.gdk;

import cloud.graal.gdk.command.GdkBaseCommand;
import io.micronaut.context.ApplicationContext;
import io.micronaut.context.BeanContext;
import io.micronaut.inject.BeanDefinition;
import io.micronaut.starter.cli.CodeGenConfig;
import io.micronaut.starter.cli.InteractiveShell;
import io.micronaut.starter.cli.MicronautFactory;
import io.micronaut.starter.cli.command.CodeGenCommand;
import io.micronaut.starter.io.ConsoleOutput;
import picocli.CommandLine;
import picocli.CommandLine.ParameterException;

import java.util.function.BiFunction;

/**
* Base class for CLI main classes. Starts an interactive shell if passed no
* arguments, otherwise instantiates the requested command class.
* <p>
* Based on io.micronaut.starter.cli.MicronautStarter.
*/
public abstract class AbstractStarter extends GdkBaseCommand {

protected static final BiFunction<Throwable, CommandLine, Integer> EXCEPTION_HANDLER = (e, commandLine) -> {
GdkBaseCommand command = commandLine.getCommand();
command.err(e.getMessage());
if (command.showStacktrace()) {
e.printStackTrace(commandLine.getErr());
}
return 1;
};

protected boolean interactiveShell = false;

protected CommandLine createCommandLine() {
boolean noOpConsole = interactiveShell;
try (BeanContext beanContext = ApplicationContext.builder().deduceEnvironment(false).start()) {
return createCommandLine(beanContext, noOpConsole);
}
}

protected int execute(String[] args) {
boolean noOpConsole = args.length > 0 && args[0].startsWith("update-cli-config");
try (BeanContext beanContext = ApplicationContext.builder().deduceEnvironment(false).start()) {
return createCommandLine(beanContext, noOpConsole).execute(args);
}
}

protected CommandLine createCommandLine(BeanContext beanContext, boolean noOpConsole) {
CommandLine commandLine = new CommandLine(this, new MicronautFactory(beanContext));
commandLine.setExecutionExceptionHandler((ex, commandLine1, parseResult) -> EXCEPTION_HANDLER.apply(ex, commandLine1));
commandLine.setUsageHelpWidth(100);

addCodegenCommands(beanContext, noOpConsole, commandLine);

return commandLine;
}

protected void addCodegenCommands(BeanContext beanContext, boolean noOpConsole, CommandLine commandLine) {
CodeGenConfig codeGenConfig = CodeGenConfig.load(beanContext, noOpConsole ? ConsoleOutput.NOOP : this);
if (codeGenConfig != null) {
beanContext.getBeanDefinitions(CodeGenCommand.class).stream()
.map(BeanDefinition::getBeanType)
.map(bt -> beanContext.createBean(bt, codeGenConfig))
.filter(CodeGenCommand::applies)
.forEach(commandLine::addSubcommand);
}
}

/**
* @return the name of the cli, for use in the interactive shell.
*/
protected String getCliName() {
return "gdk";
}

protected void startShell() {
CommandLine commandLine = createCommandLine();
interactiveShell = true;
new InteractiveShell(commandLine, this::execute, EXCEPTION_HANDLER, "@|blue " + getCliName() + ">|@ ").start();
}

@Override
public Integer call() {
throw new ParameterException(spec.commandLine(), "No command specified");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2024 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.gdk.command;

/**
* Convenience base class for external commands.
*/
public abstract class AbstractExternalCommand extends GdkBaseCommand implements ExternalCommand {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2024 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.gdk.command;

/**
* Marker interface for addon commands, e.g. extensions created by users.
*/
public interface ExternalCommand {
}
2 changes: 1 addition & 1 deletion gdk/gdk-cli/README.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= gdk-cli

This submodule generates the GDK CLI application which is compiled to a native executable `gdk`, which works similarly to the Micronaut `mn` CLI with the addition of being able to generate GDK applications by specifying clouds and services.
This submodule generates the GDK CLI application which is compiled to a native executable `gdk`, which works similarly to the Micronaut `mn` CLI with the addition of being able to generate GDK applications by specifying clouds and services. It depends on the `gdk-cli-core` submodule which contains most of the code.

== GdkStarter

Expand Down
Loading

0 comments on commit 56929d7

Please sign in to comment.