From f6f959ff8fac775afb109bfecad7e9f8f1673fb0 Mon Sep 17 00:00:00 2001 From: Andy Damevin Date: Tue, 25 Aug 2020 07:57:20 +0200 Subject: [PATCH] Codestart customized package and class and more Fixes #11154 --- .../buildtool/gradle-kotlin-dsl/codestart.yml | 6 +- .../buildtool/gradle/codestart.yml | 6 +- .../commandmode-example/base/README.md | 0 .../commandmode-example/codestart.yml | 7 +- .../{main.class-name}.tpl.qute.java | 19 ++ .../{main.class-name}.tpl.qute.kt | 17 ++ .../code}/resteasy-example/base/README.md | 0 .../META-INF/resources/index.tpl.qute.html | 2 +- .../code}/resteasy-example/codestart.yml | 9 +- .../{resource.class-name}.tpl.qute.java} | 8 +- ...tive{resource.class-name}IT.tpl.qute.java} | 4 +- .../{resource.class-name}Test.tpl.qute.java} | 8 +- .../{resource.class-name}.tpl.qute.kt} | 8 +- .../Native{resource.class-name}IT.tpl.qute.kt | 6 + .../{resource.class-name}Test.tpl.qute.kt} | 8 +- .../{resource.class-name}.tpl.qute.scala} | 8 +- ...tive{resource.class-name}IT.tpl.qute.scala | 6 + .../{resource.class-name}Test.tpl.qute.scala} | 8 +- .../commandmode/GreetingMain.tpl.qute.java | 27 --- .../commandmode/GreetingService.tpl.qute.java | 12 - .../acme/commandmode/GreetingMain.tpl.qute.kt | 22 -- .../commandmode/GreetingService.tpl.qute.kt | 8 - .../main/docker/Dockerfile.tpl.qute.fast-jar | 6 +- .../amazon-lambda-example/codestart.yml | 6 +- .../codestart.yml | 7 +- .../config-yaml-example/codestart.yml | 4 +- .../funqy-amazon-lambda-example/codestart.yml | 6 +- .../funqy-http-example/codestart.yml | 4 +- .../codestart.yml | 6 +- .../codestarts/qute-example/codestart.yml | 3 +- .../org/acme/qute/NativeHelloResourceIT.kt | 2 +- .../acme/resteasy/NativeExampleResourceIT.kt | 6 - .../resteasy/NativeExampleResourceIT.scala | 6 - .../tools/codestarts/codestarts.adoc | 10 +- .../devtools/codestarts/Codestart.java | 4 + .../devtools/codestarts/CodestartData.java | 7 +- .../devtools/codestarts/CodestartInput.java | 31 +-- .../codestarts/CodestartInputBuilder.java | 42 +--- .../devtools/codestarts/CodestartLoader.java | 17 +- .../codestarts/CodestartPathProcessor.java | 36 +++ .../codestarts/CodestartProcessor.java | 11 +- .../devtools/codestarts/CodestartProject.java | 2 +- .../devtools/codestarts/CodestartSpec.java | 16 +- .../devtools/codestarts/Codestarts.java | 18 -- ...DuplicateCodestartFileStrategyHandler.java | 2 +- .../codestarts/CodestartLoaderTest.java | 8 +- .../CodestartPathProcessorTest.java | 41 ++++ .../devtools/codestarts/CodestartsTest.java | 8 +- .../buildtool-maven/b/pom.tpl.qute.xml | 1 + .../buildtool-maven/base/pom.tpl.qute.xml | 2 +- .../buildtool-maven/codestart.yml | 5 +- .../{my-file-name}.tpl.qute.test | 1 + .../example-with-b/codestart.yml | 8 +- .../example-forbidden/codestart.yml | 3 +- .../codestarts/example1/codestart.yml | 3 +- .../codestarts/example2/codestart.yml | 3 +- .../example-fallback/a/.gitkeep | 0 .../example-fallback/codestart.yml | 2 - .../resources/expected-pom-maven-merge.xml | 3 +- .../codestarts/QuarkusCodestartData.java | 62 ++++- .../codestarts/QuarkusCodestartInput.java | 37 +++ .../QuarkusCodestartInputBuilder.java | 132 +++++++++++ .../codestarts/QuarkusCodestarts.java | 82 +++---- .../handlers/CreateProjectCommandHandler.java | 25 +- .../codestarts/CodestartProjectRunIT.java | 117 ---------- ...java => QuarkusCodestartGenerationIT.java} | 220 ++++++++++++++---- .../codestarts/QuarkusCodestartRunIT.java | 158 +++++++++++++ ...startsIT.java => QuarkusCodestartsIT.java} | 46 ++-- ...jectTestRunner.java => WrapperRunner.java} | 2 +- .../it/CreateProjectCodestartMojoIT.java | 69 ++++-- 70 files changed, 979 insertions(+), 510 deletions(-) rename devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/{example => code}/commandmode-example/base/README.md (100%) rename devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/{example => code}/commandmode-example/codestart.yml (63%) create mode 100644 devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/commandmode-example/java/src/main/java/{package-name.dir}/{main.class-name}.tpl.qute.java create mode 100644 devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/commandmode-example/kotlin/src/main/kotlin/{package-name.dir}/{main.class-name}.tpl.qute.kt rename devtools/platform-descriptor-json/src/main/resources/{codestarts => bundled-codestarts/code}/resteasy-example/base/README.md (100%) rename devtools/platform-descriptor-json/src/main/resources/{codestarts => bundled-codestarts/code}/resteasy-example/base/src/main/resources/META-INF/resources/index.tpl.qute.html (97%) rename devtools/platform-descriptor-json/src/main/resources/{codestarts => bundled-codestarts/code}/resteasy-example/codestart.yml (51%) rename devtools/platform-descriptor-json/src/main/resources/{codestarts/resteasy-example/java/src/main/java/org/acme/resteasy/ExampleResource.tpl.qute.java => bundled-codestarts/code/resteasy-example/java/src/main/java/{package-name.dir}/{resource.class-name}.tpl.qute.java} (61%) rename devtools/platform-descriptor-json/src/main/resources/{codestarts/resteasy-example/java/src/native-test/java/org/acme/resteasy/NativeExampleResourceIT.java => bundled-codestarts/code/resteasy-example/java/src/native-test/java/{package-name.dir}/Native{resource.class-name}IT.tpl.qute.java} (53%) rename devtools/platform-descriptor-json/src/main/resources/{codestarts/resteasy-example/java/src/test/java/org/acme/resteasy/ExampleResourceTest.tpl.qute.java => bundled-codestarts/code/resteasy-example/java/src/test/java/{package-name.dir}/{resource.class-name}Test.tpl.qute.java} (66%) rename devtools/platform-descriptor-json/src/main/resources/{codestarts/resteasy-example/kotlin/src/main/kotlin/org/acme/resteasy/ExampleResource.tpl.qute.kt => bundled-codestarts/code/resteasy-example/kotlin/src/main/kotlin/{package-name.dir}/{resource.class-name}.tpl.qute.kt} (57%) create mode 100644 devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/resteasy-example/kotlin/src/native-test/kotlin/{package-name.dir}/Native{resource.class-name}IT.tpl.qute.kt rename devtools/platform-descriptor-json/src/main/resources/{codestarts/resteasy-example/kotlin/src/test/kotlin/org/acme/resteasy/ExampleResourceTest.tpl.qute.kt => bundled-codestarts/code/resteasy-example/kotlin/src/test/kotlin/{package-name.dir}/{resource.class-name}Test.tpl.qute.kt} (65%) rename devtools/platform-descriptor-json/src/main/resources/{codestarts/resteasy-example/scala/src/main/scala/org/acme/resteasy/ExampleResource.tpl.qute.scala => bundled-codestarts/code/resteasy-example/scala/src/main/scala/{package-name.dir}/{resource.class-name}.tpl.qute.scala} (54%) create mode 100644 devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/resteasy-example/scala/src/native-test/scala/{package-name.dir}/Native{resource.class-name}IT.tpl.qute.scala rename devtools/platform-descriptor-json/src/main/resources/{codestarts/resteasy-example/scala/src/test/scala/org/acme/resteasy/ExampleResourceTest.tpl.qute.scala => bundled-codestarts/code/resteasy-example/scala/src/test/scala/{package-name.dir}/{resource.class-name}Test.tpl.qute.scala} (65%) delete mode 100644 devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/example/commandmode-example/java/src/main/java/org/acme/commandmode/GreetingMain.tpl.qute.java delete mode 100644 devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/example/commandmode-example/java/src/main/java/org/acme/commandmode/GreetingService.tpl.qute.java delete mode 100644 devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/example/commandmode-example/kotlin/src/main/kotlin/org/acme/commandmode/GreetingMain.tpl.qute.kt delete mode 100644 devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/example/commandmode-example/kotlin/src/main/kotlin/org/acme/commandmode/GreetingService.tpl.qute.kt delete mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/resteasy-example/kotlin/src/native-test/kotlin/org/acme/resteasy/NativeExampleResourceIT.kt delete mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/resteasy-example/scala/src/native-test/scala/org/acme/resteasy/NativeExampleResourceIT.scala create mode 100644 independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/CodestartPathProcessor.java create mode 100644 independent-projects/tools/codestarts/src/test/java/io/quarkus/devtools/codestarts/CodestartPathProcessorTest.java create mode 100644 independent-projects/tools/codestarts/src/test/resources/bundled-codestarts/example-with-b/b/{my-dir-name}/{my-file-name}.tpl.qute.test delete mode 100644 independent-projects/tools/codestarts/src/test/resources/example-fallback/example-fallback/a/.gitkeep delete mode 100644 independent-projects/tools/codestarts/src/test/resources/example-fallback/example-fallback/codestart.yml create mode 100644 independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/QuarkusCodestartInput.java create mode 100644 independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/QuarkusCodestartInputBuilder.java delete mode 100644 integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/CodestartProjectRunIT.java rename integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/{CodestartProjectGenerationIT.java => QuarkusCodestartGenerationIT.java} (57%) create mode 100644 integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/QuarkusCodestartRunIT.java rename integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/{CodestartsIT.java => QuarkusCodestartsIT.java} (73%) rename integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/{CodestartProjectTestRunner.java => WrapperRunner.java} (98%) diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/codestart.yml index 3534bca41ad405..2f4a15c3a0c5f4 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/codestart.yml +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/codestart.yml @@ -6,12 +6,12 @@ output-strategy: language: base: data: - quarkus: - gradle-plugin: - id: io.quarkus kotlin: version: 1.3.72 shared-data: + quarkus: + gradle-plugin: + id: io.quarkus buildtool: build-dir: build guide: https://quarkus.io/guides/gradle-tooling diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/codestart.yml index f40897a830928b..cc6d670ac58866 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/codestart.yml +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/codestart.yml @@ -6,12 +6,12 @@ output-strategy: language: base: data: - quarkus: - gradle-plugin: - id: io.quarkus kotlin: version: 1.3.72 shared-data: + quarkus: + gradle-plugin: + id: io.quarkus buildtool: build-dir: build guide: https://quarkus.io/guides/gradle-tooling diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/example/commandmode-example/base/README.md b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/commandmode-example/base/README.md similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/example/commandmode-example/base/README.md rename to devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/commandmode-example/base/README.md diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/example/commandmode-example/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/commandmode-example/codestart.yml similarity index 63% rename from devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/example/commandmode-example/codestart.yml rename to devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/commandmode-example/codestart.yml index 077c82077d2857..5915a3c722b9da 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/example/commandmode-example/codestart.yml +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/commandmode-example/codestart.yml @@ -1,10 +1,13 @@ name: commandmode-example ref: commandmode -type: example -fallback: true +type: code +tags: example language: base: data: + main: + class-name: HelloCommando + package-name: org.acme.commandmode greeting: message: "hello" default-name: "commando" diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/commandmode-example/java/src/main/java/{package-name.dir}/{main.class-name}.tpl.qute.java b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/commandmode-example/java/src/main/java/{package-name.dir}/{main.class-name}.tpl.qute.java new file mode 100644 index 00000000000000..b7e1dc55d5245f --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/commandmode-example/java/src/main/java/{package-name.dir}/{main.class-name}.tpl.qute.java @@ -0,0 +1,19 @@ +package {package-name}; + +import javax.enterprise.context.control.ActivateRequestContext; +import javax.inject.Inject; + +import io.quarkus.runtime.Quarkus; +import io.quarkus.runtime.QuarkusApplication; +import io.quarkus.runtime.annotations.QuarkusMain; + +@QuarkusMain +public class {main.class-name} implements QuarkusApplication { + + @Override + public int run(String... args) throws Exception { + final String name = args.length > 0 ? String.join(" ", args) : "{greeting.default-name}"; + System.out.println("{greeting.message} " + name); + return 0; + } +} diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/commandmode-example/kotlin/src/main/kotlin/{package-name.dir}/{main.class-name}.tpl.qute.kt b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/commandmode-example/kotlin/src/main/kotlin/{package-name.dir}/{main.class-name}.tpl.qute.kt new file mode 100644 index 00000000000000..e60be12295eba8 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/commandmode-example/kotlin/src/main/kotlin/{package-name.dir}/{main.class-name}.tpl.qute.kt @@ -0,0 +1,17 @@ +package {package-name} + +import javax.inject.Inject + +import io.quarkus.runtime.QuarkusApplication +import io.quarkus.runtime.annotations.QuarkusMain + +@QuarkusMain +class {main.class-name}: QuarkusApplication { + + override fun run(vararg args: String?): Int { + val name = if (args.isNotEmpty()) args.joinToString(",") else "{greeting.default-name}" + println(name) + return 0 + } + +} diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/resteasy-example/base/README.md b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/resteasy-example/base/README.md similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/resteasy-example/base/README.md rename to devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/resteasy-example/base/README.md diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/resteasy-example/base/src/main/resources/META-INF/resources/index.tpl.qute.html b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/resteasy-example/base/src/main/resources/META-INF/resources/index.tpl.qute.html similarity index 97% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/resteasy-example/base/src/main/resources/META-INF/resources/index.tpl.qute.html rename to devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/resteasy-example/base/src/main/resources/META-INF/resources/index.tpl.qute.html index 5227dc15c9fe7b..0ec933397bfc2b 100644 --- a/devtools/platform-descriptor-json/src/main/resources/codestarts/resteasy-example/base/src/main/resources/META-INF/resources/index.tpl.qute.html +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/code/resteasy-example/base/src/main/resources/META-INF/resources/index.tpl.qute.html @@ -117,7 +117,7 @@

What can I do from here?

If not already done, run the application in dev mode using: {buildtool.cmd.dev}.