Skip to content

Commit 56929d7

Browse files
authored
4.6.0.6 release (#34)
1 parent bdb9568 commit 56929d7

28 files changed

+468
-190
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright 2024 Oracle and/or its affiliates
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
plugins {
18+
id 'gdk-module'
19+
id 'io.micronaut.application'
20+
id 'com.github.johnrengelman.shadow'
21+
}
22+
23+
dependencies {
24+
annotationProcessor mnLibs.picocli.codegen
25+
26+
compileOnly mnLibs.graal
27+
28+
implementation projects.gdkCliCore
29+
30+
runtimeOnly libs.bouncycastle.bcpkix
31+
runtimeOnly libs.bouncycastle.bcprov
32+
runtimeOnly libs.jansi
33+
runtimeOnly libs.jline
34+
runtimeOnly libs.slf4j.nop
35+
}
36+
37+
configurations.configureEach {
38+
exclude module: 'logback-classic'
39+
}
40+
41+
micronaut {
42+
version libs.micronaut.starter.api.get().version
43+
processing {
44+
incremental true
45+
annotations 'cloud.graal.gdk.*'
46+
}
47+
}
48+
49+
tasks.named('shadowJar') {
50+
mergeServiceFiles()
51+
}
52+
53+
tasks.named('shadowDistZip') {
54+
enabled = false
55+
}
56+
tasks.named('shadowDistTar') {
57+
enabled = false
58+
}
59+
60+
tasks.register('copyShadowJar', Sync) {
61+
from shadowJar.outputs
62+
into "${project.rootProject.buildDir}/libs"
63+
rename { String fileName -> 'cli.jar' }
64+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2024 Oracle and/or its affiliates
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
plugins {
18+
id 'gdk-module'
19+
id 'com.diffplug.spotless'
20+
}
21+
22+
spotless {
23+
java {
24+
licenseHeaderFile rootProject.file('config/spotless.license.java')
25+
target 'src/main/java/**'
26+
targetExclude '**/*.rocker.raw', '**/GdkBaseCommand.java', '**/GdkStarter.java', '**/AbstractStarter.java'
27+
}
28+
format 'javaMisc', {
29+
target 'src/main/**/package-info.java', 'src/main/**/module-info.java'
30+
licenseHeaderFile rootProject.file('config/spotless.license.java'), '\\/\\*\\*'
31+
}
32+
}
33+

gdk/buildSrc/src/main/groovy/gdk-module.gradle

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,6 @@
1717
plugins {
1818
id 'gdk-base'
1919
id 'checkstyle'
20-
id 'com.diffplug.spotless'
21-
}
22-
23-
spotless {
24-
java {
25-
licenseHeaderFile rootProject.file('config/spotless.license.java')
26-
target 'src/main/java/**'
27-
targetExclude '**/*.rocker.raw', '**/GdkBaseCommand.java', '**/GdkStarter.java'
28-
}
29-
format 'javaMisc', {
30-
target 'src/main/**/package-info.java', 'src/main/**/module-info.java'
31-
licenseHeaderFile rootProject.file('config/spotless.license.java'), '\\/\\*\\*'
32-
}
3320
}
3421

3522
publishing {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2024 Oracle and/or its affiliates
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
plugins {
18+
id 'groovy'
19+
id 'com.adarshr.test-logger'
20+
id 'io.micronaut.library'
21+
}
22+
23+
micronaut {
24+
testRuntime 'spock2'
25+
}
26+
27+
test {
28+
maxHeapSize = '16G'
29+
}
30+
31+
testlogger {
32+
theme 'standard-parallel'
33+
showFullStackTraces true
34+
showStandardStreams true
35+
showPassedStandardStreams false
36+
showSkippedStandardStreams false
37+
showFailedStandardStreams true
38+
}

gdk/gdk-cli-core/README.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
= gdk-cli-core
2+
3+
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.

gdk/gdk-cli-core/build.gradle

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright 2024 Oracle and/or its affiliates
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
plugins {
18+
id 'gdk-module-public'
19+
id 'io.micronaut.library'
20+
}
21+
22+
dependencies {
23+
annotationProcessor mnLibs.picocli.codegen
24+
25+
// not in libs.versions.toml to keep Micronaut version in one place
26+
api(libs.micronaut.starter.cli) {
27+
exclude group: 'io.micronaut', module: 'micronaut-buffer-netty'
28+
exclude group: 'io.micronaut', module: 'micronaut-http-client'
29+
exclude group: 'io.micronaut', module: 'micronaut-http-client-core'
30+
exclude group: 'io.micronaut', module: 'micronaut-http-netty'
31+
exclude group: 'io.micronaut', module: 'micronaut-websocket'
32+
exclude group: 'io.micronaut.testresources', module: 'micronaut-test-resources-build-tools'
33+
exclude group: 'io.netty', module: 'netty-buffer'
34+
exclude group: 'io.netty', module: 'netty-codec'
35+
exclude group: 'io.netty', module: 'netty-codec-http'
36+
exclude group: 'io.netty', module: 'netty-codec-http2'
37+
exclude group: 'io.netty', module: 'netty-codec-socks'
38+
exclude group: 'io.netty', module: 'netty-common'
39+
exclude group: 'io.netty', module: 'netty-handler'
40+
exclude group: 'io.netty', module: 'netty-handler-proxy'
41+
exclude group: 'io.netty', module: 'netty-resolver'
42+
exclude group: 'io.netty', module: 'netty-transport'
43+
exclude group: 'io.swagger.core.v3', module: 'swagger-annotations'
44+
exclude group: 'org.eclipse.jgit', module: 'org.eclipse.jgit'
45+
exclude group: 'org.jline', module: 'jline'
46+
}
47+
api mnLibs.micronaut.picocli
48+
api mnLibs.picocli
49+
api mnLibs.micronaut.jackson.databind
50+
api mnLibs.micronaut.validation
51+
api projects.gdkCore
52+
}
53+
54+
micronaut {
55+
version libs.micronaut.starter.api.get().version
56+
processing {
57+
incremental true
58+
annotations 'cloud.graal.gdk.*'
59+
}
60+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/*
2+
* Copyright 2017-2022 original authors
3+
* Copyright 2024 Oracle and/or its affiliates
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package cloud.graal.gdk;
18+
19+
import cloud.graal.gdk.command.GdkBaseCommand;
20+
import io.micronaut.context.ApplicationContext;
21+
import io.micronaut.context.BeanContext;
22+
import io.micronaut.inject.BeanDefinition;
23+
import io.micronaut.starter.cli.CodeGenConfig;
24+
import io.micronaut.starter.cli.InteractiveShell;
25+
import io.micronaut.starter.cli.MicronautFactory;
26+
import io.micronaut.starter.cli.command.CodeGenCommand;
27+
import io.micronaut.starter.io.ConsoleOutput;
28+
import picocli.CommandLine;
29+
import picocli.CommandLine.ParameterException;
30+
31+
import java.util.function.BiFunction;
32+
33+
/**
34+
* Base class for CLI main classes. Starts an interactive shell if passed no
35+
* arguments, otherwise instantiates the requested command class.
36+
* <p>
37+
* Based on io.micronaut.starter.cli.MicronautStarter.
38+
*/
39+
public abstract class AbstractStarter extends GdkBaseCommand {
40+
41+
protected static final BiFunction<Throwable, CommandLine, Integer> EXCEPTION_HANDLER = (e, commandLine) -> {
42+
GdkBaseCommand command = commandLine.getCommand();
43+
command.err(e.getMessage());
44+
if (command.showStacktrace()) {
45+
e.printStackTrace(commandLine.getErr());
46+
}
47+
return 1;
48+
};
49+
50+
protected boolean interactiveShell = false;
51+
52+
protected CommandLine createCommandLine() {
53+
boolean noOpConsole = interactiveShell;
54+
try (BeanContext beanContext = ApplicationContext.builder().deduceEnvironment(false).start()) {
55+
return createCommandLine(beanContext, noOpConsole);
56+
}
57+
}
58+
59+
protected int execute(String[] args) {
60+
boolean noOpConsole = args.length > 0 && args[0].startsWith("update-cli-config");
61+
try (BeanContext beanContext = ApplicationContext.builder().deduceEnvironment(false).start()) {
62+
return createCommandLine(beanContext, noOpConsole).execute(args);
63+
}
64+
}
65+
66+
protected CommandLine createCommandLine(BeanContext beanContext, boolean noOpConsole) {
67+
CommandLine commandLine = new CommandLine(this, new MicronautFactory(beanContext));
68+
commandLine.setExecutionExceptionHandler((ex, commandLine1, parseResult) -> EXCEPTION_HANDLER.apply(ex, commandLine1));
69+
commandLine.setUsageHelpWidth(100);
70+
71+
addCodegenCommands(beanContext, noOpConsole, commandLine);
72+
73+
return commandLine;
74+
}
75+
76+
protected void addCodegenCommands(BeanContext beanContext, boolean noOpConsole, CommandLine commandLine) {
77+
CodeGenConfig codeGenConfig = CodeGenConfig.load(beanContext, noOpConsole ? ConsoleOutput.NOOP : this);
78+
if (codeGenConfig != null) {
79+
beanContext.getBeanDefinitions(CodeGenCommand.class).stream()
80+
.map(BeanDefinition::getBeanType)
81+
.map(bt -> beanContext.createBean(bt, codeGenConfig))
82+
.filter(CodeGenCommand::applies)
83+
.forEach(commandLine::addSubcommand);
84+
}
85+
}
86+
87+
/**
88+
* @return the name of the cli, for use in the interactive shell.
89+
*/
90+
protected String getCliName() {
91+
return "gdk";
92+
}
93+
94+
protected void startShell() {
95+
CommandLine commandLine = createCommandLine();
96+
interactiveShell = true;
97+
new InteractiveShell(commandLine, this::execute, EXCEPTION_HANDLER, "@|blue " + getCliName() + ">|@ ").start();
98+
}
99+
100+
@Override
101+
public Integer call() {
102+
throw new ParameterException(spec.commandLine(), "No command specified");
103+
}
104+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2024 Oracle and/or its affiliates
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package cloud.graal.gdk.command;
17+
18+
/**
19+
* Convenience base class for external commands.
20+
*/
21+
public abstract class AbstractExternalCommand extends GdkBaseCommand implements ExternalCommand {
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2024 Oracle and/or its affiliates
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package cloud.graal.gdk.command;
17+
18+
/**
19+
* Marker interface for addon commands, e.g. extensions created by users.
20+
*/
21+
public interface ExternalCommand {
22+
}

0 commit comments

Comments
 (0)