From bf83749f1e0845a8af0e3b84c680ed1174d2e7d1 Mon Sep 17 00:00:00 2001 From: Andy Damevin Date: Fri, 9 Oct 2020 17:25:12 +0200 Subject: [PATCH] Codestarts as default codegen - Codestarts which only works alone are called "Singleton" - Added checks to avoid conflict between Singelton codestarts - Make codestart the default codegen and add a legacyCodegen flag - Use RESTEasy example as default (commandmode example is not selectable for now.. until a picocli example?) - Update the guides with `-DnoExamples` when when relevent - Update the tests Fixes #12113 --- .../src/main/java/io/quarkus/cli/Create.java | 1 - .../src/test/java/io/quarkus/cli/CliTest.java | 16 +- .../io/quarkus/maven/CreateProjectMojo.java | 8 +- .../gradle-kotlin-dsl/base/..gitignore | 2 +- .../core/buildtool/gradle/base/..gitignore | 2 +- .../gradle/base/gradle.tpl.qute.properties | 4 +- .../core/buildtool/maven/base/..gitignore | 2 +- .../core/project/quarkus/base/..gitignore | 1 - .../funqy-http-example/base/README.md | 2 +- .../amazon-lambda-example/base/README.md | 0 .../amazon-lambda-example/codestart.yml | 2 +- .../amazon-lambda-example/java/payload.json | 0 .../java/org/acme/lambda/GreetingLambda.java | 0 .../src/main/java/org/acme/lambda/Person.java | 0 .../org/acme/lambda/LambdaHandlerTestIT.java | 0 .../org/acme/lambda/LambdaHandlerTest.java | 0 .../java/src/test/resources/application.yml | 0 .../base/README.md | 0 .../base/azure-config/function.tpl.qute.json | 0 .../base/azure-config/host.json | 0 .../base/azure-config/local.settings.json | 0 .../base/pom.tpl.qute.xml | 0 .../main/resources/application.tpl.qute.yml | 0 .../codestart.yml | 2 +- .../base/README.md | 0 .../funqy-amazon-lambda-example/codestart.yml | 2 +- .../java/payload.json | 0 .../java/org/acme/funqy/GreetingFunction.java | 0 .../src/main/java/org/acme/funqy/Person.java | 0 .../java/org/acme/funqy/FunqyIT.java | 0 .../java/resources/application.properties | 0 .../test/java/org/acme/funqy/FunqyTest.java | 0 .../java/src/test/resources/application.yml | 0 .../base/README.md | 0 .../codestart.yml | 2 +- .../funqy/cloudevent/CloudEventGreeting.java | 0 .../org/acme/funqy/cloudevent/Person.java | 0 .../src/main/k8s/funqy-service.tpl.qute.yaml | 0 .../src/main/k8s/funqy-trigger.tpl.qute.yaml | 0 .../org/acme/funqy/cloudevent/FunqyIT.java | 0 .../org/acme/funqy/cloudevent/FunqyTest.java | 0 .../asciidoc/building-my-first-extension.adoc | 2 +- docs/src/main/asciidoc/kafka-streams.adoc | 2 + docs/src/main/asciidoc/neo4j.adoc | 1 + docs/src/main/asciidoc/optaplanner.adoc | 2 +- docs/src/main/asciidoc/quartz.adoc | 2 +- .../src/main/asciidoc/reactive-event-bus.adoc | 6 +- docs/src/main/asciidoc/redis.adoc | 3 +- docs/src/main/asciidoc/security-jdbc.adoc | 3 +- docs/src/main/asciidoc/security-jpa.adoc | 3 +- .../security-keycloak-authorization.adoc | 3 +- docs/src/main/asciidoc/security-ldap.adoc | 3 +- .../security-openid-connect-multitenancy.adoc | 3 +- .../asciidoc/security-openid-connect.adoc | 3 +- .../codestarts/CodestartProjectInput.java | 5 +- .../CodestartProjectInputBuilder.java | 7 +- .../codestarts/core/CodestartData.java | 8 +- .../codestarts/core/CodestartSpec.java | 2 +- .../codestarts/QuarkusCodestartCatalog.java | 49 ++-- .../QuarkusCodestartProjectInput.java | 8 + .../QuarkusCodestartProjectInputBuilder.java | 20 +- .../devtools/commands/CreateProject.java | 14 +- .../handlers/CreateProjectCommandHandler.java | 231 +++--------------- .../LegacyCreateProjectCommandHandler.java | 196 +++++++++++++++ .../project/extensions/Extensions.java | 19 ++ .../QuarkusCodestartCatalogTest.java | 1 + .../QuarkusCodestartGenerationTest.java | 47 +++- .../codestarts/QuarkusCodestartRunIT.java | 6 +- .../CreateProjectPlatformMetadataTest.java | 18 +- .../devtools/commands/CreateProjectTest.java | 10 +- .../gradle/QuarkusPluginFunctionalTest.java | 2 +- .../maven/it/KotlinCreateMavenProjectIT.java | 2 +- .../quarkus/maven/it/CreateProjectMojoIT.java | 13 +- .../maven/it/ScalaCreateMavenProjectIT.java | 2 +- 74 files changed, 449 insertions(+), 293 deletions(-) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/amazon-lambda-example/base/README.md (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/amazon-lambda-example/codestart.yml (91%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/amazon-lambda-example/java/payload.json (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/amazon-lambda-example/java/src/main/java/org/acme/lambda/GreetingLambda.java (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/amazon-lambda-example/java/src/main/java/org/acme/lambda/Person.java (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/amazon-lambda-example/java/src/native-test/java/org/acme/lambda/LambdaHandlerTestIT.java (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/amazon-lambda-example/java/src/test/java/org/acme/lambda/LambdaHandlerTest.java (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/amazon-lambda-example/java/src/test/resources/application.yml (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/azure-functions-http-example/base/README.md (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/azure-functions-http-example/base/azure-config/function.tpl.qute.json (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/azure-functions-http-example/base/azure-config/host.json (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/azure-functions-http-example/base/azure-config/local.settings.json (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/azure-functions-http-example/base/pom.tpl.qute.xml (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/azure-functions-http-example/base/src/main/resources/application.tpl.qute.yml (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/azure-functions-http-example/codestart.yml (94%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/funqy-amazon-lambda-example/base/README.md (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/funqy-amazon-lambda-example/codestart.yml (92%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/funqy-amazon-lambda-example/java/payload.json (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/funqy-amazon-lambda-example/java/src/main/java/org/acme/funqy/GreetingFunction.java (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/funqy-amazon-lambda-example/java/src/main/java/org/acme/funqy/Person.java (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/funqy-amazon-lambda-example/java/src/native-test/java/org/acme/funqy/FunqyIT.java (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/funqy-amazon-lambda-example/java/src/native-test/java/resources/application.properties (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/funqy-amazon-lambda-example/java/src/test/java/org/acme/funqy/FunqyTest.java (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/funqy-amazon-lambda-example/java/src/test/resources/application.yml (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/funqy-knative-events-example/base/README.md (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/funqy-knative-events-example/codestart.yml (93%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/funqy-knative-events-example/java/src/main/java/org/acme/funqy/cloudevent/CloudEventGreeting.java (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/funqy-knative-events-example/java/src/main/java/org/acme/funqy/cloudevent/Person.java (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/funqy-knative-events-example/java/src/main/k8s/funqy-service.tpl.qute.yaml (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/funqy-knative-events-example/java/src/main/k8s/funqy-trigger.tpl.qute.yaml (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/funqy-knative-events-example/java/src/native-test/java/org/acme/funqy/cloudevent/FunqyIT.java (100%) rename devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/{advanced-examples => singleton-examples}/funqy-knative-events-example/java/src/test/java/org/acme/funqy/cloudevent/FunqyTest.java (100%) create mode 100644 independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/handlers/LegacyCreateProjectCommandHandler.java diff --git a/devtools/cli/src/main/java/io/quarkus/cli/Create.java b/devtools/cli/src/main/java/io/quarkus/cli/Create.java index 704b17babab55c..1b36cdeff41e07 100644 --- a/devtools/cli/src/main/java/io/quarkus/cli/Create.java +++ b/devtools/cli/src/main/java/io/quarkus/cli/Create.java @@ -115,7 +115,6 @@ else if (targetBuildTool.gradleKotlinDsl) .version(version) .sourceType(sourceType) .extensions(extensions) - .codestartsEnabled(true) .noExamples(noExamples) .execute().isSuccess(); diff --git a/devtools/cli/src/test/java/io/quarkus/cli/CliTest.java b/devtools/cli/src/test/java/io/quarkus/cli/CliTest.java index d5e8ae6db5d811..99e3e9ff7c4058 100644 --- a/devtools/cli/src/test/java/io/quarkus/cli/CliTest.java +++ b/devtools/cli/src/test/java/io/quarkus/cli/CliTest.java @@ -65,7 +65,7 @@ public void testAddListRemove() throws Exception { Assertions.assertEquals(CommandLine.ExitCode.USAGE, exitCode); // test not project dir - execute("add", "resteasy"); + execute("add", "qute"); Assertions.assertEquals(CommandLine.ExitCode.SOFTWARE, exitCode); execute("list"); @@ -77,17 +77,18 @@ public void testAddListRemove() throws Exception { // test empty list execute("list"); Assertions.assertEquals(CommandLine.ExitCode.OK, exitCode); - Assertions.assertEquals("", screen.trim()); + Assertions.assertEquals("quarkus-resteasy", screen.trim()); // test add - execute("add", "resteasy"); + execute("add", "qute"); Assertions.assertEquals(CommandLine.ExitCode.OK, exitCode); // test list execute("list"); Assertions.assertEquals(CommandLine.ExitCode.OK, exitCode); - Assertions.assertEquals("quarkus-resteasy", screen.trim()); + Assertions.assertTrue(screen.contains("quarkus-resteasy")); + Assertions.assertTrue(screen.contains("quarkus-qute")); // test add multiple execute("add", "amazon-lambda-http", "jackson"); @@ -98,6 +99,7 @@ public void testAddListRemove() throws Exception { execute("list"); Assertions.assertEquals(CommandLine.ExitCode.OK, exitCode); Assertions.assertTrue(screen.contains("quarkus-resteasy")); + Assertions.assertTrue(screen.contains("quarkus-qute")); Assertions.assertTrue(screen.contains("quarkus-amazon-lambda-http")); Assertions.assertTrue(screen.contains("quarkus-jackson")); @@ -122,16 +124,16 @@ public void testAddListRemove() throws Exception { Assertions.assertEquals(CommandLine.ExitCode.SOFTWARE, exitCode); // test remove - execute("remove", "resteasy"); + execute("remove", "qute"); Assertions.assertEquals(CommandLine.ExitCode.OK, exitCode); execute("list"); Assertions.assertEquals(CommandLine.ExitCode.OK, exitCode); - Assertions.assertFalse(screen.contains("quarkus-resteasy")); + Assertions.assertFalse(screen.contains("quarkus-qute")); Assertions.assertTrue(screen.contains("quarkus-amazon-lambda-http")); Assertions.assertTrue(screen.contains("quarkus-jackson")); // test remove many - execute("rm", "amazon-lambda-http", "jackson"); + execute("rm", "amazon-lambda-http", "jackson", "resteasy"); Assertions.assertEquals(CommandLine.ExitCode.OK, exitCode); execute("list"); Assertions.assertEquals(CommandLine.ExitCode.OK, exitCode); diff --git a/devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java index 368689afe49082..5fa9cb9c80db60 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java @@ -74,8 +74,8 @@ public class CreateProjectMojo extends AbstractMojo { @Parameter(property = "projectVersion") private String projectVersion; - @Parameter(property = "codestartsEnabled", defaultValue = "false") - private boolean codestartsEnabled; + @Parameter(property = "legacyCodegen", defaultValue = "false") + private boolean legacyCodegen; @Parameter(property = "noExamples", defaultValue = "false") private boolean noExamples; @@ -195,7 +195,7 @@ public void execute() throws MojoExecutionException { .sourceType(sourceType) .className(className) .extensions(extensions) - .codestartsEnabled(codestartsEnabled) + .legacyCodegen(legacyCodegen) .noExamples(noExamples); if (path != null) { createProject.setValue("path", path); @@ -203,7 +203,7 @@ public void execute() throws MojoExecutionException { success = createProject.execute().isSuccess(); - if (!codestartsEnabled) { + if (legacyCodegen) { File createdDependenciesBuildFile = new File(projectRoot, buildToolEnum.getDependenciesFile()); if (BuildTool.MAVEN.equals(buildToolEnum)) { createMavenWrapper(createdDependenciesBuildFile, ToolsUtils.readQuarkusProperties(platform)); diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/buildtool/gradle-kotlin-dsl/base/..gitignore b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/buildtool/gradle-kotlin-dsl/base/..gitignore index ace4d3dd9713dc..f318f00be30d3b 100644 --- a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/buildtool/gradle-kotlin-dsl/base/..gitignore +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/buildtool/gradle-kotlin-dsl/base/..gitignore @@ -1,3 +1,3 @@ # Gradle .gradle/ -build/ \ No newline at end of file +build/ diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/buildtool/gradle/base/..gitignore b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/buildtool/gradle/base/..gitignore index ace4d3dd9713dc..f318f00be30d3b 100644 --- a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/buildtool/gradle/base/..gitignore +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/buildtool/gradle/base/..gitignore @@ -1,3 +1,3 @@ # Gradle .gradle/ -build/ \ No newline at end of file +build/ diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/buildtool/gradle/base/gradle.tpl.qute.properties b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/buildtool/gradle/base/gradle.tpl.qute.properties index d3160667382c54..5d57e047ec2553 100644 --- a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/buildtool/gradle/base/gradle.tpl.qute.properties +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/buildtool/gradle/base/gradle.tpl.qute.properties @@ -3,4 +3,6 @@ quarkusPluginId={quarkus.gradle-plugin.id} quarkusPluginVersion={quarkus.gradle-plugin.version} quarkusPlatformGroupId={quarkus.platform.group-id} quarkusPlatformArtifactId={quarkus.platform.artifact-id} -quarkusPlatformVersion={quarkus.platform.version} \ No newline at end of file +quarkusPlatformVersion={quarkus.platform.version} + +org.gradle.logging.level=INFO \ No newline at end of file diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/buildtool/maven/base/..gitignore b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/buildtool/maven/base/..gitignore index b1be26f06a4975..1e4ecfdc2a7f0e 100644 --- a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/buildtool/maven/base/..gitignore +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/buildtool/maven/base/..gitignore @@ -3,4 +3,4 @@ target/ pom.xml.tag pom.xml.releaseBackup pom.xml.versionsBackup -release.properties \ No newline at end of file +release.properties diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/project/quarkus/base/..gitignore b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/project/quarkus/base/..gitignore index ca0fab1daa7097..aff36ab1807a0e 100644 --- a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/project/quarkus/base/..gitignore +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/core/project/quarkus/base/..gitignore @@ -27,4 +27,3 @@ nb-configuration.xml # patch *.orig *.rej - diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/examples/funqy-http-example/base/README.md b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/examples/funqy-http-example/base/README.md index fa7bc9a7cb415e..056189e4a05a6c 100644 --- a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/examples/funqy-http-example/base/README.md +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/examples/funqy-http-example/base/README.md @@ -1,3 +1,3 @@ -== Funqy HTTP Binding +# Funqy HTTP Binding Guide: https://quarkus.io/guides/funqy-http diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/amazon-lambda-example/base/README.md b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/amazon-lambda-example/base/README.md similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/amazon-lambda-example/base/README.md rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/amazon-lambda-example/base/README.md diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/amazon-lambda-example/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/amazon-lambda-example/codestart.yml similarity index 91% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/amazon-lambda-example/codestart.yml rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/amazon-lambda-example/codestart.yml index ce73a5b331e4f2..7012acda0be679 100644 --- a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/amazon-lambda-example/codestart.yml +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/amazon-lambda-example/codestart.yml @@ -3,7 +3,7 @@ ref: amazon-lambda type: code tags: - example - - compatibility-issues + - singleton-example language: base: shared-data: diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/amazon-lambda-example/java/payload.json b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/amazon-lambda-example/java/payload.json similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/amazon-lambda-example/java/payload.json rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/amazon-lambda-example/java/payload.json diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/amazon-lambda-example/java/src/main/java/org/acme/lambda/GreetingLambda.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/amazon-lambda-example/java/src/main/java/org/acme/lambda/GreetingLambda.java similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/amazon-lambda-example/java/src/main/java/org/acme/lambda/GreetingLambda.java rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/amazon-lambda-example/java/src/main/java/org/acme/lambda/GreetingLambda.java diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/amazon-lambda-example/java/src/main/java/org/acme/lambda/Person.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/amazon-lambda-example/java/src/main/java/org/acme/lambda/Person.java similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/amazon-lambda-example/java/src/main/java/org/acme/lambda/Person.java rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/amazon-lambda-example/java/src/main/java/org/acme/lambda/Person.java diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/amazon-lambda-example/java/src/native-test/java/org/acme/lambda/LambdaHandlerTestIT.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/amazon-lambda-example/java/src/native-test/java/org/acme/lambda/LambdaHandlerTestIT.java similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/amazon-lambda-example/java/src/native-test/java/org/acme/lambda/LambdaHandlerTestIT.java rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/amazon-lambda-example/java/src/native-test/java/org/acme/lambda/LambdaHandlerTestIT.java diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/amazon-lambda-example/java/src/test/java/org/acme/lambda/LambdaHandlerTest.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/amazon-lambda-example/java/src/test/java/org/acme/lambda/LambdaHandlerTest.java similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/amazon-lambda-example/java/src/test/java/org/acme/lambda/LambdaHandlerTest.java rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/amazon-lambda-example/java/src/test/java/org/acme/lambda/LambdaHandlerTest.java diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/amazon-lambda-example/java/src/test/resources/application.yml b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/amazon-lambda-example/java/src/test/resources/application.yml similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/amazon-lambda-example/java/src/test/resources/application.yml rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/amazon-lambda-example/java/src/test/resources/application.yml diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/azure-functions-http-example/base/README.md b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/azure-functions-http-example/base/README.md similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/azure-functions-http-example/base/README.md rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/azure-functions-http-example/base/README.md diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/azure-functions-http-example/base/azure-config/function.tpl.qute.json b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/azure-functions-http-example/base/azure-config/function.tpl.qute.json similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/azure-functions-http-example/base/azure-config/function.tpl.qute.json rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/azure-functions-http-example/base/azure-config/function.tpl.qute.json diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/azure-functions-http-example/base/azure-config/host.json b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/azure-functions-http-example/base/azure-config/host.json similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/azure-functions-http-example/base/azure-config/host.json rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/azure-functions-http-example/base/azure-config/host.json diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/azure-functions-http-example/base/azure-config/local.settings.json b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/azure-functions-http-example/base/azure-config/local.settings.json similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/azure-functions-http-example/base/azure-config/local.settings.json rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/azure-functions-http-example/base/azure-config/local.settings.json diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/azure-functions-http-example/base/pom.tpl.qute.xml b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/azure-functions-http-example/base/pom.tpl.qute.xml similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/azure-functions-http-example/base/pom.tpl.qute.xml rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/azure-functions-http-example/base/pom.tpl.qute.xml diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/azure-functions-http-example/base/src/main/resources/application.tpl.qute.yml b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/azure-functions-http-example/base/src/main/resources/application.tpl.qute.yml similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/azure-functions-http-example/base/src/main/resources/application.tpl.qute.yml rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/azure-functions-http-example/base/src/main/resources/application.tpl.qute.yml diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/azure-functions-http-example/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/azure-functions-http-example/codestart.yml similarity index 94% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/azure-functions-http-example/codestart.yml rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/azure-functions-http-example/codestart.yml index 8b45b26888bfa1..f3c7850d98ecb7 100644 --- a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/azure-functions-http-example/codestart.yml +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/azure-functions-http-example/codestart.yml @@ -3,7 +3,7 @@ ref: azure-functions-http type: code tags: - example - - compatibility-issues + - singleton-example - maven-only language: base: diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-amazon-lambda-example/base/README.md b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-amazon-lambda-example/base/README.md similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-amazon-lambda-example/base/README.md rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-amazon-lambda-example/base/README.md diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-amazon-lambda-example/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-amazon-lambda-example/codestart.yml similarity index 92% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-amazon-lambda-example/codestart.yml rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-amazon-lambda-example/codestart.yml index ce5f7bca076566..c36bd8bd06640f 100644 --- a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-amazon-lambda-example/codestart.yml +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-amazon-lambda-example/codestart.yml @@ -3,7 +3,7 @@ ref: funqy-amazon-lambda type: code tags: - example - - compatibility-issues + - singleton-example language: base: shared-data: diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-amazon-lambda-example/java/payload.json b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-amazon-lambda-example/java/payload.json similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-amazon-lambda-example/java/payload.json rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-amazon-lambda-example/java/payload.json diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-amazon-lambda-example/java/src/main/java/org/acme/funqy/GreetingFunction.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-amazon-lambda-example/java/src/main/java/org/acme/funqy/GreetingFunction.java similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-amazon-lambda-example/java/src/main/java/org/acme/funqy/GreetingFunction.java rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-amazon-lambda-example/java/src/main/java/org/acme/funqy/GreetingFunction.java diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-amazon-lambda-example/java/src/main/java/org/acme/funqy/Person.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-amazon-lambda-example/java/src/main/java/org/acme/funqy/Person.java similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-amazon-lambda-example/java/src/main/java/org/acme/funqy/Person.java rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-amazon-lambda-example/java/src/main/java/org/acme/funqy/Person.java diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-amazon-lambda-example/java/src/native-test/java/org/acme/funqy/FunqyIT.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-amazon-lambda-example/java/src/native-test/java/org/acme/funqy/FunqyIT.java similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-amazon-lambda-example/java/src/native-test/java/org/acme/funqy/FunqyIT.java rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-amazon-lambda-example/java/src/native-test/java/org/acme/funqy/FunqyIT.java diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-amazon-lambda-example/java/src/native-test/java/resources/application.properties b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-amazon-lambda-example/java/src/native-test/java/resources/application.properties similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-amazon-lambda-example/java/src/native-test/java/resources/application.properties rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-amazon-lambda-example/java/src/native-test/java/resources/application.properties diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-amazon-lambda-example/java/src/test/java/org/acme/funqy/FunqyTest.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-amazon-lambda-example/java/src/test/java/org/acme/funqy/FunqyTest.java similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-amazon-lambda-example/java/src/test/java/org/acme/funqy/FunqyTest.java rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-amazon-lambda-example/java/src/test/java/org/acme/funqy/FunqyTest.java diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-amazon-lambda-example/java/src/test/resources/application.yml b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-amazon-lambda-example/java/src/test/resources/application.yml similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-amazon-lambda-example/java/src/test/resources/application.yml rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-amazon-lambda-example/java/src/test/resources/application.yml diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-knative-events-example/base/README.md b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-knative-events-example/base/README.md similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-knative-events-example/base/README.md rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-knative-events-example/base/README.md diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-knative-events-example/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-knative-events-example/codestart.yml similarity index 93% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-knative-events-example/codestart.yml rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-knative-events-example/codestart.yml index 5931413b4a2e67..d0a066f0ff2159 100644 --- a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-knative-events-example/codestart.yml +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-knative-events-example/codestart.yml @@ -3,7 +3,7 @@ ref: funqy-knative-events type: code tags: - example - - compatibility-issues + - singleton-example language: base: data: diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-knative-events-example/java/src/main/java/org/acme/funqy/cloudevent/CloudEventGreeting.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-knative-events-example/java/src/main/java/org/acme/funqy/cloudevent/CloudEventGreeting.java similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-knative-events-example/java/src/main/java/org/acme/funqy/cloudevent/CloudEventGreeting.java rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-knative-events-example/java/src/main/java/org/acme/funqy/cloudevent/CloudEventGreeting.java diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-knative-events-example/java/src/main/java/org/acme/funqy/cloudevent/Person.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-knative-events-example/java/src/main/java/org/acme/funqy/cloudevent/Person.java similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-knative-events-example/java/src/main/java/org/acme/funqy/cloudevent/Person.java rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-knative-events-example/java/src/main/java/org/acme/funqy/cloudevent/Person.java diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-knative-events-example/java/src/main/k8s/funqy-service.tpl.qute.yaml b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-knative-events-example/java/src/main/k8s/funqy-service.tpl.qute.yaml similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-knative-events-example/java/src/main/k8s/funqy-service.tpl.qute.yaml rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-knative-events-example/java/src/main/k8s/funqy-service.tpl.qute.yaml diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-knative-events-example/java/src/main/k8s/funqy-trigger.tpl.qute.yaml b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-knative-events-example/java/src/main/k8s/funqy-trigger.tpl.qute.yaml similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-knative-events-example/java/src/main/k8s/funqy-trigger.tpl.qute.yaml rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-knative-events-example/java/src/main/k8s/funqy-trigger.tpl.qute.yaml diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-knative-events-example/java/src/native-test/java/org/acme/funqy/cloudevent/FunqyIT.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-knative-events-example/java/src/native-test/java/org/acme/funqy/cloudevent/FunqyIT.java similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-knative-events-example/java/src/native-test/java/org/acme/funqy/cloudevent/FunqyIT.java rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-knative-events-example/java/src/native-test/java/org/acme/funqy/cloudevent/FunqyIT.java diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-knative-events-example/java/src/test/java/org/acme/funqy/cloudevent/FunqyTest.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-knative-events-example/java/src/test/java/org/acme/funqy/cloudevent/FunqyTest.java similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/advanced-examples/funqy-knative-events-example/java/src/test/java/org/acme/funqy/cloudevent/FunqyTest.java rename to devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus/singleton-examples/funqy-knative-events-example/java/src/test/java/org/acme/funqy/cloudevent/FunqyTest.java diff --git a/docs/src/main/asciidoc/building-my-first-extension.adoc b/docs/src/main/asciidoc/building-my-first-extension.adoc index 246423f8262711..a593181827aa8f 100644 --- a/docs/src/main/asciidoc/building-my-first-extension.adoc +++ b/docs/src/main/asciidoc/building-my-first-extension.adoc @@ -740,7 +740,7 @@ $mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ -DprojectArtifactId=greeting-app \ -DprojectVersion=1.0-SNAPSHOT \ - -DclassName=HelloResource + -DnoExamples ---- `cd` into `greeting-app` and add the dependency on `quarkus-greeting` extension we created above. diff --git a/docs/src/main/asciidoc/kafka-streams.adoc b/docs/src/main/asciidoc/kafka-streams.adoc index 826b3c89e20646..3b9d255b74912a 100644 --- a/docs/src/main/asciidoc/kafka-streams.adoc +++ b/docs/src/main/asciidoc/kafka-streams.adoc @@ -88,6 +88,7 @@ mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ -DprojectArtifactId=kafka-streams-quickstart-producer \ -Dextensions="kafka" \ + -DnoExamples \ && mv kafka-streams-quickstart-producer producer ---- @@ -241,6 +242,7 @@ mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ -DprojectArtifactId=kafka-streams-quickstart-aggregator \ -Dextensions="kafka-streams,resteasy-jsonb" \ + -DnoExamples \ && mv kafka-streams-quickstart-aggregator aggregator ---- diff --git a/docs/src/main/asciidoc/neo4j.adoc b/docs/src/main/asciidoc/neo4j.adoc index 1f7873f2d61763..7d1ed6287ef4df 100644 --- a/docs/src/main/asciidoc/neo4j.adoc +++ b/docs/src/main/asciidoc/neo4j.adoc @@ -127,6 +127,7 @@ First, we need a new project. Create a new project with the following command: mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ -DprojectArtifactId=neo4j-quickstart \ + -DclassName="org.acme.datasource.GreetingResource" \ -Dextensions="neo4j,resteasy-jsonb" cd neo4j-quickstart ---- diff --git a/docs/src/main/asciidoc/optaplanner.adoc b/docs/src/main/asciidoc/optaplanner.adoc index 22f600404956c6..2e7b4f5bcc45e4 100644 --- a/docs/src/main/asciidoc/optaplanner.adoc +++ b/docs/src/main/asciidoc/optaplanner.adoc @@ -70,7 +70,7 @@ Alternatively, generate it from the command line with Maven: mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ -DprojectArtifactId=optaplanner-quickstart \ - -Dextensions="resteasy, resteasy-jackson, optaplanner-quarkus, optaplanner-quarkus-jackson" + -Dextensions="resteasy,resteasy-jackson,optaplanner-quarkus,optaplanner-quarkus-jackson" cd optaplanner-quickstart ---- diff --git a/docs/src/main/asciidoc/quartz.adoc b/docs/src/main/asciidoc/quartz.adoc index 91e92402747584..1f39b67af9e12c 100644 --- a/docs/src/main/asciidoc/quartz.adoc +++ b/docs/src/main/asciidoc/quartz.adoc @@ -49,7 +49,7 @@ mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectArtifactId=quartz-quickstart \ -DclassName="org.acme.quartz.TaskResource" \ -Dpath="/tasks" \ - -Dextensions="quartz, hibernate-orm-panache, flyway, resteasy-jsonb, jdbc-postgresql" + -Dextensions="quartz,hibernate-orm-panache,flyway,resteasy-jsonb,jdbc-postgresql" cd quartz-quickstart ---- diff --git a/docs/src/main/asciidoc/reactive-event-bus.adoc b/docs/src/main/asciidoc/reactive-event-bus.adoc index d21b8e72fbcfc6..7314910589ebf1 100644 --- a/docs/src/main/asciidoc/reactive-event-bus.adoc +++ b/docs/src/main/asciidoc/reactive-event-bus.adoc @@ -30,7 +30,8 @@ If you are creating a new project, set the `extensions` parameter are follows: mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ -DprojectArtifactId=vertx-quickstart \ - -Dextensions="vertx,resteasy-mutiny" + -Dextensions="vertx,resteasy-mutiny" \ + -DnoExamples cd vertx-quickstart ---- @@ -267,7 +268,8 @@ First create a new project using: mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ -DprojectArtifactId=vertx-http-quickstart \ - -Dextensions="vertx" + -Dextensions="vertx" \ + -DnoExamples cd vertx-http-quickstart ---- diff --git a/docs/src/main/asciidoc/redis.adoc b/docs/src/main/asciidoc/redis.adoc index 6af97023ab7596..698ff1d8992178 100644 --- a/docs/src/main/asciidoc/redis.adoc +++ b/docs/src/main/asciidoc/redis.adoc @@ -48,7 +48,8 @@ First, we need a new project. Create a new project with the following command: mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ -DprojectArtifactId=redis-quickstart \ - -Dextensions="redis-client, resteasy-jsonb, resteasy-mutiny" + -Dextensions="redis-client,resteasy-jsonb,resteasy-mutiny" \ + -DnoExamples cd redis-quickstart ---- diff --git a/docs/src/main/asciidoc/security-jdbc.adoc b/docs/src/main/asciidoc/security-jdbc.adoc index 4a5b37ca9df9b5..b0cf272acbf691 100644 --- a/docs/src/main/asciidoc/security-jdbc.adoc +++ b/docs/src/main/asciidoc/security-jdbc.adoc @@ -49,7 +49,8 @@ First, we need a new project. Create a new project with the following command: mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ -DprojectArtifactId=security-jdbc-quickstart \ - -Dextensions="elytron-security-jdbc, jdbc-postgresql, resteasy" + -Dextensions="elytron-security-jdbc,jdbc-postgresql,resteasy" \ + -DnoExamples cd security-jdbc-quickstart ---- diff --git a/docs/src/main/asciidoc/security-jpa.adoc b/docs/src/main/asciidoc/security-jpa.adoc index 10fba0fcc1bb3f..9cd561b6c7b5e7 100644 --- a/docs/src/main/asciidoc/security-jpa.adoc +++ b/docs/src/main/asciidoc/security-jpa.adoc @@ -50,7 +50,8 @@ First, we need a new project. Create a new project with the following command: mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ -DprojectArtifactId=security-jpa-quickstart \ - -Dextensions="security-jpa, jdbc-postgresql, resteasy, hibernate-orm-panache" + -Dextensions="security-jpa,jdbc-postgresql,resteasy,hibernate-orm-panache" \ + -DnoExamples cd security-jpa-quickstart ---- diff --git a/docs/src/main/asciidoc/security-keycloak-authorization.adoc b/docs/src/main/asciidoc/security-keycloak-authorization.adoc index d09a0710c312fc..3d84a83991adf4 100644 --- a/docs/src/main/asciidoc/security-keycloak-authorization.adoc +++ b/docs/src/main/asciidoc/security-keycloak-authorization.adoc @@ -73,7 +73,8 @@ Create a new project with the following command: mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ -DprojectArtifactId=security-keycloak-authorization-quickstart \ - -Dextensions="oidc, keycloak-authorization, resteasy-jsonb" + -Dextensions="oidc,keycloak-authorization,resteasy-jsonb" \ + -DnoExamples cd security-keycloak-authorization-quickstart ---- diff --git a/docs/src/main/asciidoc/security-ldap.adoc b/docs/src/main/asciidoc/security-ldap.adoc index ade36f17dd895a..e5d46eb4982a3e 100644 --- a/docs/src/main/asciidoc/security-ldap.adoc +++ b/docs/src/main/asciidoc/security-ldap.adoc @@ -49,7 +49,8 @@ First, we need a new project. Create a new project with the following command: mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ -DprojectArtifactId=security-ldap-quickstart \ - -Dextensions="elytron-security-ldap, resteasy" + -Dextensions="elytron-security-ldap,resteasy" \ + -DnoExamples cd security-ldap-quickstart ---- diff --git a/docs/src/main/asciidoc/security-openid-connect-multitenancy.adoc b/docs/src/main/asciidoc/security-openid-connect-multitenancy.adoc index 86d2e37364b111..dd27562ea5b636 100644 --- a/docs/src/main/asciidoc/security-openid-connect-multitenancy.adoc +++ b/docs/src/main/asciidoc/security-openid-connect-multitenancy.adoc @@ -53,7 +53,8 @@ First, we need a new project. Create a new project with the following command: mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ -DprojectArtifactId=security-openid-connect-multi-tenancy \ - -Dextensions="oidc, resteasy-jsonb" + -Dextensions="oidc,resteasy-jsonb" \ + -DnoExamples cd security-openid-connect-multi-tenancy ---- diff --git a/docs/src/main/asciidoc/security-openid-connect.adoc b/docs/src/main/asciidoc/security-openid-connect.adoc index c2a62e35f68a32..b8bbb445cc074e 100644 --- a/docs/src/main/asciidoc/security-openid-connect.adoc +++ b/docs/src/main/asciidoc/security-openid-connect.adoc @@ -62,7 +62,8 @@ First, we need a new project. Create a new project with the following command: mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ -DprojectArtifactId=security-openid-connect-quickstart \ - -Dextensions="oidc, resteasy-jsonb" + -Dextensions="resteasy,oidc,resteasy-jsonb" \ + -DnoExamples cd security-openid-connect-quickstart ---- diff --git a/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/CodestartProjectInput.java b/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/CodestartProjectInput.java index 99c8067761411e..e0f291b742846d 100644 --- a/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/CodestartProjectInput.java +++ b/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/CodestartProjectInput.java @@ -2,14 +2,13 @@ import static java.util.Objects.requireNonNull; -import io.quarkus.bootstrap.model.AppArtifactKey; import io.quarkus.devtools.codestarts.utils.NestedMaps; import io.quarkus.devtools.messagewriter.MessageWriter; import java.util.Collection; import java.util.Map; public class CodestartProjectInput { - private final Collection dependencies; + private final Collection dependencies; private final Map data; private final CodestartsSelection selection; private final MessageWriter messageWriter; @@ -33,7 +32,7 @@ public CodestartsSelection getSelection() { return selection; } - public Collection getDependencies() { + public Collection getDependencies() { return dependencies; } diff --git a/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/CodestartProjectInputBuilder.java b/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/CodestartProjectInputBuilder.java index 043c2889d04e85..9ef73f671b28af 100644 --- a/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/CodestartProjectInputBuilder.java +++ b/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/CodestartProjectInputBuilder.java @@ -1,6 +1,5 @@ package io.quarkus.devtools.codestarts; -import io.quarkus.bootstrap.model.AppArtifactKey; import io.quarkus.devtools.messagewriter.MessageWriter; import java.util.ArrayList; import java.util.Collection; @@ -9,7 +8,7 @@ import java.util.Map; public class CodestartProjectInputBuilder { - Collection dependencies = new ArrayList<>(); + Collection dependencies = new ArrayList<>(); CodestartsSelection selection = new CodestartsSelection(); Map data = new HashMap<>(); MessageWriter messageWriter = MessageWriter.info(); @@ -18,12 +17,12 @@ public class CodestartProjectInputBuilder { } - public CodestartProjectInputBuilder addDependencies(Collection dependencies) { + public CodestartProjectInputBuilder addDependencies(Collection dependencies) { this.dependencies.addAll(dependencies); return this; } - public CodestartProjectInputBuilder addDependency(AppArtifactKey dependency) { + public CodestartProjectInputBuilder addDependency(String dependency) { return this.addDependencies(Collections.singletonList(dependency)); } diff --git a/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/CodestartData.java b/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/CodestartData.java index 4c19d43ba3d5f3..3612c03da2b7d1 100644 --- a/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/CodestartData.java +++ b/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/CodestartData.java @@ -1,6 +1,5 @@ package io.quarkus.devtools.codestarts.core; -import io.quarkus.bootstrap.model.AppArtifactKey; import io.quarkus.devtools.codestarts.Codestart; import io.quarkus.devtools.codestarts.core.CodestartSpec.CodestartDep; import io.quarkus.devtools.codestarts.utils.NestedMaps; @@ -43,12 +42,11 @@ public static Map buildCodestartProjectData(Collection buildDependenciesData(Stream codestartsStream, String languageName, - Collection extensions) { + Collection extensions) { final Map> depsData = new HashMap<>(); - final Set extensionsAsDeps = extensions.stream() - .map(k -> k.getGroupId() + ":" + k.getArtifactId()).map(CodestartDep::new) + final Set dependencies = extensions.stream() + .map(CodestartDep::new) .collect(Collectors.toCollection(LinkedHashSet::new)); - final Set dependencies = new LinkedHashSet<>(extensionsAsDeps); final Set testDependencies = new LinkedHashSet<>(); codestartsStream .flatMap(s -> Stream.of(s.getBaseLanguageSpec(), s.getLanguageSpec(languageName))) diff --git a/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/CodestartSpec.java b/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/CodestartSpec.java index 55318c77ed97d9..f062a1989e304e 100644 --- a/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/CodestartSpec.java +++ b/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/CodestartSpec.java @@ -125,7 +125,7 @@ public CodestartDep() { @JsonCreator(mode = JsonCreator.Mode.DELEGATING) public CodestartDep(final String expression) { final String[] split = expression.split(":"); - if (split.length < 2 || split.length > 3) { + if (split.length < 2) { throw new IllegalArgumentException("Invalid CodestartDep expression: " + expression); } this.put(GROUP_ID, split[0]); diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/QuarkusCodestartCatalog.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/QuarkusCodestartCatalog.java index 245c068f71d1b9..25d3967a5efd53 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/QuarkusCodestartCatalog.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/QuarkusCodestartCatalog.java @@ -2,9 +2,9 @@ import static io.quarkus.devtools.codestarts.core.CodestartCatalogs.findLanguageName; -import io.quarkus.bootstrap.model.AppArtifactKey; import io.quarkus.dependencies.Extension; import io.quarkus.devtools.codestarts.core.GenericCodestartCatalog; +import io.quarkus.devtools.project.extensions.Extensions; import io.quarkus.platform.descriptor.QuarkusPlatformDescriptor; import java.io.IOException; import java.nio.file.Path; @@ -19,11 +19,11 @@ public final class QuarkusCodestartCatalog extends GenericCodestartCatalog { public static final String QUARKUS_CODESTARTS_DIR = "codestarts/quarkus"; - private final Map extensionCodestartMapping; + private final Map extensionCodestartMapping; public enum Tag implements KeySupplier { EXAMPLE, - COMPATIBILITY_ISSUES, + SINGLETON_EXAMPLE, MAVEN_ONLY; } @@ -45,7 +45,7 @@ public enum Example implements KeySupplier { } private QuarkusCodestartCatalog(Collection codestarts, - Map extensionCodestartMapping) { + Map extensionCodestartMapping) { super(codestarts); this.extensionCodestartMapping = extensionCodestartMapping; } @@ -54,7 +54,7 @@ public static QuarkusCodestartCatalog fromQuarkusPlatformDescriptor(QuarkusPlatf throws IOException { final CodestartPathLoader pathLoader = platformPathLoader(platformDescriptor); final Collection codestarts = CodestartCatalogLoader.loadCodestarts(pathLoader, QUARKUS_CODESTARTS_DIR); - final Map extensionCodestartMapping = buildCodestartMapping(platformDescriptor.getExtensions()); + final Map extensionCodestartMapping = buildCodestartMapping(platformDescriptor.getExtensions()); return new QuarkusCodestartCatalog(codestarts, extensionCodestartMapping); } @@ -67,7 +67,7 @@ public static QuarkusCodestartCatalog fromQuarkusPlatformDescriptorAndDirectorie for (Path directory : directories) { codestarts.addAll(CodestartCatalogLoader.loadUserDirectoryCodestarts(directory)); } - final Map extensionCodestartMapping = buildCodestartMapping(platformDescriptor.getExtensions()); + final Map extensionCodestartMapping = buildCodestartMapping(platformDescriptor.getExtensions()); return new QuarkusCodestartCatalog(codestarts, extensionCodestartMapping); } @@ -87,29 +87,45 @@ protected Collection select(QuarkusCodestartProjectInput projectInput .filter(c -> !isExample(c) || !projectInput.noExamples()) .collect(Collectors.toCollection(ArrayList::new)); - // include commandmode example codestarts if none selected + // include default example codestarts if none selected if (!projectInput.noExamples() && projectCodestarts.stream() .noneMatch(c -> isExample(c) && !c.getSpec().isPreselected())) { - final Codestart commandModeCodestart = codestarts.stream() - .filter(c -> c.isSelected(Collections.singleton(Example.COMMANDMODE_EXAMPLE.getKey()))) + final Codestart defaultCodestart = codestarts.stream() + .filter(c -> c.isSelected(Collections.singleton(Example.RESTEASY_EXAMPLE.getKey()))) .findFirst().orElseThrow(() -> new CodestartStructureException( - Example.COMMANDMODE_EXAMPLE.getKey() + " codestart not found")); + Example.RESTEASY_EXAMPLE.getKey() + " codestart not found")); final String languageName = findLanguageName(projectCodestarts); - if (commandModeCodestart.implementsLanguage(languageName)) { - projectCodestarts.add(commandModeCodestart); + if (defaultCodestart.implementsLanguage(languageName)) { + projectCodestarts.add(defaultCodestart); } else { projectInput.log().warn( - commandModeCodestart.getName() + " codestart will not be applied (doesn't implement language '" + defaultCodestart.getName() + " codestart will not be applied (doesn't implement language '" + languageName + "' yet)"); } } + + // check compatibility issues + final long examplesWithCompatIssues = projectCodestarts.stream() + .filter(QuarkusCodestartCatalog::isExample) + .filter(c -> c.containsTag(Tag.SINGLETON_EXAMPLE.getKey())) + .count(); + + if (examplesWithCompatIssues == 1) { + // remove other examples + projectCodestarts.removeIf(c -> isExample(c) && !c.containsTag(Tag.SINGLETON_EXAMPLE.getKey())); + } else if (examplesWithCompatIssues > 1) { + throw new CodestartException( + "Only one extension with singleton example can be selected at a time (you can always use 'noExamples' if needed)"); + } + return projectCodestarts; } private Set getExtensionCodestarts(QuarkusCodestartProjectInput projectInput) { - return projectInput.getDependencies().stream() + return projectInput.getExtensions().stream() + .map(Extensions::toGA) .filter(extensionCodestartMapping::containsKey) .map(extensionCodestartMapping::get) .collect(Collectors.toSet()); @@ -164,11 +180,10 @@ default String getKey() { } } - private static Map buildCodestartMapping(Collection extensions) { + private static Map buildCodestartMapping(Collection extensions) { return extensions.stream() .filter(e -> e.getCodestart() != null) - .collect(Collectors.toMap(e -> new AppArtifactKey(e.getGroupId(), e.getArtifactId(), e.getClassifier(), - e.getType() == null ? "jar" : e.getType()), Extension::getCodestart)); + .collect(Collectors.toMap(Extensions::toGA, Extension::getCodestart)); } } diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/QuarkusCodestartProjectInput.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/QuarkusCodestartProjectInput.java index 69dfb239e91a3e..0985a8aa060d13 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/QuarkusCodestartProjectInput.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/QuarkusCodestartProjectInput.java @@ -2,16 +2,20 @@ import static java.util.Objects.requireNonNull; +import io.quarkus.bootstrap.model.AppArtifactCoords; import io.quarkus.devtools.project.BuildTool; +import java.util.Collection; public final class QuarkusCodestartProjectInput extends CodestartProjectInput { private final BuildTool buildTool; + private final Collection extensions; private final boolean noExamples; private final boolean noDockerfiles; private final boolean noBuildToolWrapper; public QuarkusCodestartProjectInput(QuarkusCodestartProjectInputBuilder builder) { super(builder); + this.extensions = builder.extensions; this.buildTool = requireNonNull(builder.buildTool, "buildTool is required"); this.noExamples = builder.noExamples; this.noDockerfiles = builder.noDockerfiles; @@ -22,6 +26,10 @@ public static QuarkusCodestartProjectInputBuilder builder() { return new QuarkusCodestartProjectInputBuilder(); } + public Collection getExtensions() { + return extensions; + } + public boolean noExamples() { return noExamples; } diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/QuarkusCodestartProjectInputBuilder.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/QuarkusCodestartProjectInputBuilder.java index 1f255e17378cca..ad28f7360c1837 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/QuarkusCodestartProjectInputBuilder.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/QuarkusCodestartProjectInputBuilder.java @@ -2,28 +2,42 @@ import static java.util.Objects.requireNonNull; +import io.quarkus.bootstrap.model.AppArtifactCoords; import io.quarkus.bootstrap.model.AppArtifactKey; import io.quarkus.devtools.messagewriter.MessageWriter; import io.quarkus.devtools.project.BuildTool; +import io.quarkus.devtools.project.extensions.Extensions; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Map; +import java.util.stream.Collectors; public class QuarkusCodestartProjectInputBuilder extends CodestartProjectInputBuilder { + public Collection extensions = new ArrayList<>(); boolean noExamples; boolean noDockerfiles; boolean noBuildToolWrapper; BuildTool buildTool = BuildTool.MAVEN; - public QuarkusCodestartProjectInputBuilder addExtensions(Collection extensions) { - super.addDependencies(extensions); + QuarkusCodestartProjectInputBuilder() { + super(); + } + + public QuarkusCodestartProjectInputBuilder addExtensions(Collection extensions) { + this.extensions.addAll(extensions); + super.addDependencies(extensions.stream().map(Extensions::toGAV).collect(Collectors.toList())); return this; } - public QuarkusCodestartProjectInputBuilder addExtension(AppArtifactKey extension) { + public QuarkusCodestartProjectInputBuilder addExtension(AppArtifactCoords extension) { return this.addExtensions(Collections.singletonList(extension)); } + public QuarkusCodestartProjectInputBuilder addExtension(AppArtifactKey extension) { + return this.addExtension(Extensions.toCoords(extension, null)); + } + @Override public QuarkusCodestartProjectInputBuilder addCodestarts(Collection codestarts) { super.addCodestarts(codestarts); diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/CreateProject.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/CreateProject.java index 6eed9503336e0f..cf7641335ccbd9 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/CreateProject.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/CreateProject.java @@ -7,6 +7,7 @@ import io.quarkus.devtools.commands.data.QuarkusCommandInvocation; import io.quarkus.devtools.commands.data.QuarkusCommandOutcome; import io.quarkus.devtools.commands.handlers.CreateProjectCommandHandler; +import io.quarkus.devtools.commands.handlers.LegacyCreateProjectCommandHandler; import io.quarkus.devtools.project.BuildTool; import io.quarkus.devtools.project.QuarkusProject; import io.quarkus.devtools.project.codegen.SourceType; @@ -32,7 +33,6 @@ public class CreateProject { public static final String NAME = "create-project"; - public static final String CODESTARTS_ENABLED = ToolsUtils.dotJoin(ToolsConstants.QUARKUS, NAME, "codestarts-enabled"); public static final String NO_DOCKERFILES = ToolsUtils.dotJoin(ToolsConstants.QUARKUS, NAME, "no-dockerfiles"); public static final String NO_BUILDTOOL_WRAPPER = ToolsUtils.dotJoin(ToolsConstants.QUARKUS, NAME, "no-buildtool-wrapper"); public static final String NO_EXAMPLES = ToolsUtils.dotJoin(ToolsConstants.QUARKUS, NAME, "no-examples"); @@ -40,6 +40,7 @@ public class CreateProject { private static final Pattern JAVA_VERSION_PATTERN = Pattern.compile("(?:1\\.)?(\\d+)(?:\\..*)?"); + private boolean legacyCodegen = false; private final Path projectDirPath; private final QuarkusPlatformDescriptor platformDescr; private String javaTarget; @@ -111,15 +112,11 @@ public CreateProject codestarts(Set codestarts) { return this; } - public CreateProject codestartsEnabled(boolean value) { - setValue(CODESTARTS_ENABLED, value); + public CreateProject legacyCodegen(boolean value) { + this.legacyCodegen = value; return this; } - public CreateProject codestartsEnabled() { - return codestartsEnabled(true); - } - public CreateProject noExamples(boolean value) { setValue(NO_EXAMPLES, value); return this; @@ -182,6 +179,9 @@ public QuarkusCommandOutcome execute() throws QuarkusCommandException { final QuarkusProject quarkusProject = QuarkusProject.of(projectDirPath, platformDescr, buildTool); final QuarkusCommandInvocation invocation = new QuarkusCommandInvocation(quarkusProject, values); + if (legacyCodegen) { + return new LegacyCreateProjectCommandHandler().execute(invocation); + } return new CreateProjectCommandHandler().execute(invocation); } diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/handlers/CreateProjectCommandHandler.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/handlers/CreateProjectCommandHandler.java index 2a2476eb12bb9b..7f323ac2772333 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/handlers/CreateProjectCommandHandler.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/handlers/CreateProjectCommandHandler.java @@ -1,33 +1,26 @@ package io.quarkus.devtools.commands.handlers; import static io.quarkus.devtools.commands.CreateProject.CODESTARTS; -import static io.quarkus.devtools.commands.CreateProject.CODESTARTS_ENABLED; import static io.quarkus.devtools.commands.CreateProject.NO_BUILDTOOL_WRAPPER; import static io.quarkus.devtools.commands.CreateProject.NO_DOCKERFILES; import static io.quarkus.devtools.commands.CreateProject.NO_EXAMPLES; import static io.quarkus.devtools.commands.handlers.QuarkusCommandHandlers.computeCoordsFromQuery; -import static io.quarkus.devtools.project.codegen.ProjectGenerator.*; +import static io.quarkus.devtools.project.codegen.ProjectGenerator.BOM_ARTIFACT_ID; +import static io.quarkus.devtools.project.codegen.ProjectGenerator.BOM_GROUP_ID; +import static io.quarkus.devtools.project.codegen.ProjectGenerator.BOM_VERSION; +import static io.quarkus.devtools.project.codegen.ProjectGenerator.QUARKUS_VERSION; import io.quarkus.bootstrap.model.AppArtifactCoords; -import io.quarkus.bootstrap.model.AppArtifactKey; import io.quarkus.devtools.codestarts.CodestartProjectDefinition; import io.quarkus.devtools.codestarts.CodestartType; import io.quarkus.devtools.codestarts.QuarkusCodestartCatalog; import io.quarkus.devtools.codestarts.QuarkusCodestartData.LegacySupport; import io.quarkus.devtools.codestarts.QuarkusCodestartProjectInput; -import io.quarkus.devtools.codestarts.utils.NestedMaps; import io.quarkus.devtools.commands.data.QuarkusCommandException; import io.quarkus.devtools.commands.data.QuarkusCommandInvocation; import io.quarkus.devtools.commands.data.QuarkusCommandOutcome; import io.quarkus.devtools.messagewriter.MessageIcons; -import io.quarkus.devtools.project.BuildTool; -import io.quarkus.devtools.project.buildfile.GroovyGradleBuildFilesCreator; -import io.quarkus.devtools.project.buildfile.KotlinGradleBuildFilesCreator; import io.quarkus.devtools.project.codegen.ProjectGenerator; -import io.quarkus.devtools.project.codegen.ProjectGeneratorRegistry; -import io.quarkus.devtools.project.codegen.SourceType; -import io.quarkus.devtools.project.codegen.rest.BasicRestProjectGenerator; -import io.quarkus.devtools.project.extensions.ExtensionManager; import io.quarkus.platform.descriptor.QuarkusPlatformDescriptor; import io.quarkus.platform.tools.ToolsUtils; import java.io.IOException; @@ -36,7 +29,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.Properties; import java.util.Set; import java.util.stream.Collectors; @@ -64,194 +56,49 @@ public QuarkusCommandOutcome execute(QuarkusCommandInvocation invocation) throws } }); - if (invocation.getValue(CODESTARTS_ENABLED, false)) { - final List extensionsToAdd = computeCoordsFromQuery(invocation, extensionsQuery).stream() - .map(AppArtifactCoords::getKey) - .collect(Collectors.toList()); - - try { - Map platformData = new HashMap<>(); - if (platformDescr.getMetadata().get("maven") != null) { - platformData.put("maven", platformDescr.getMetadata().get("maven")); - } - if (platformDescr.getMetadata().get("gradle") != null) { - platformData.put("gradle", platformDescr.getMetadata().get("gradle")); - } - final QuarkusCodestartProjectInput input = QuarkusCodestartProjectInput.builder() - .addExtensions(extensionsToAdd) - .buildTool(invocation.getQuarkusProject().getBuildTool()) - .addCodestarts(invocation.getValue(CODESTARTS, new HashSet<>())) - .noExamples(invocation.getValue(NO_EXAMPLES, false)) - .noBuildToolWrapper(invocation.getValue(NO_BUILDTOOL_WRAPPER, false)) - .noDockerfiles(invocation.getValue(NO_DOCKERFILES, false)) - .addData(platformData) - .addData(LegacySupport.convertFromLegacy(invocation.getValues())) - .messageWriter(invocation.log()) - .build(); - invocation.log().info("-----------"); - if (!extensionsToAdd.isEmpty()) { - invocation.log().info("selected extensions: \n" - + extensionsToAdd.stream().map(e -> "- " + e.getGroupId() + ":" + e.getArtifactId() + "\n") - .collect(Collectors.joining())); - } - - final QuarkusCodestartCatalog catalog = QuarkusCodestartCatalog - .fromQuarkusPlatformDescriptor(invocation.getPlatformDescriptor()); - final CodestartProjectDefinition projectDefinition = catalog.createProject(input); - projectDefinition.generate(invocation.getQuarkusProject().getProjectDirPath()); - invocation.log() - .info("\n-----------\n" + MessageIcons.NOOP_ICON + " " - + projectDefinition.getRequiredCodestart(CodestartType.PROJECT).getName() - + " project has been successfully generated in:\n--> " - + invocation.getQuarkusProject().getProjectDirPath().toString() + "\n-----------"); - - } catch (IOException e) { - throw new QuarkusCommandException("Failed to create project", e); - } - return QuarkusCommandOutcome.success(); + final List extensionsToAdd = computeCoordsFromQuery(invocation, extensionsQuery); + if (extensionsToAdd == null) { + throw new QuarkusCommandException("Failed to create project because of invalid extensions"); } - - addPlatformDataToLegacyCodegen(invocation); - try { - String className = invocation.getStringValue(CLASS_NAME); - if (className != null) { - className = invocation.getValue(SOURCE_TYPE, SourceType.JAVA).stripExtensionFrom(className); - int idx = className.lastIndexOf('.'); - if (idx >= 0) { - String pkgName = invocation.getStringValue(PACKAGE_NAME); - if (pkgName == null) { - invocation.setValue(PACKAGE_NAME, className.substring(0, idx)); - } - className = className.substring(idx + 1); - } - invocation.setValue(CLASS_NAME, className); + Map platformData = new HashMap<>(); + if (platformDescr.getMetadata().get("maven") != null) { + platformData.put("maven", platformDescr.getMetadata().get("maven")); + } + if (platformDescr.getMetadata().get("gradle") != null) { + platformData.put("gradle", platformDescr.getMetadata().get("gradle")); + } + final QuarkusCodestartProjectInput input = QuarkusCodestartProjectInput.builder() + .addExtensions(extensionsToAdd) + .buildTool(invocation.getQuarkusProject().getBuildTool()) + .addCodestarts(invocation.getValue(CODESTARTS, new HashSet<>())) + .noExamples(invocation.getValue(NO_EXAMPLES, false)) + .noBuildToolWrapper(invocation.getValue(NO_BUILDTOOL_WRAPPER, false)) + .noDockerfiles(invocation.getValue(NO_DOCKERFILES, false)) + .addData(platformData) + .addData(LegacySupport.convertFromLegacy(invocation.getValues())) + .messageWriter(invocation.log()) + .build(); + invocation.log().info("-----------"); + if (!extensionsToAdd.isEmpty()) { + invocation.log().info("selected extensions: \n" + + extensionsToAdd.stream().map(e -> "- " + e.getGroupId() + ":" + e.getArtifactId() + "\n") + .collect(Collectors.joining())); } - final List extensionsToAdd = computeCoordsFromQuery(invocation, extensionsQuery); - - // extensionsToAdd is null when an error occurred while matching extensions - if (extensionsToAdd != null) { - ProjectGeneratorRegistry.get(BasicRestProjectGenerator.NAME).generate(invocation); + final QuarkusCodestartCatalog catalog = QuarkusCodestartCatalog + .fromQuarkusPlatformDescriptor(invocation.getPlatformDescriptor()); + final CodestartProjectDefinition projectDefinition = catalog.createProject(input); + projectDefinition.generate(invocation.getQuarkusProject().getProjectDirPath()); + invocation.log() + .info("\n-----------\n" + MessageIcons.NOOP_ICON + " " + + projectDefinition.getRequiredCodestart(CodestartType.PROJECT).getName() + + " project has been successfully generated in:\n--> " + + invocation.getQuarkusProject().getProjectDirPath().toString() + "\n-----------"); - //TODO ia3andy extensions should be added directly during the project generation - if (invocation.getQuarkusProject().getBuildTool().equals(BuildTool.GRADLE)) { - final GroovyGradleBuildFilesCreator generator = new GroovyGradleBuildFilesCreator( - invocation.getQuarkusProject()); - generator.create( - invocation.getStringValue(PROJECT_GROUP_ID), - invocation.getStringValue(PROJECT_ARTIFACT_ID), - invocation.getStringValue(PROJECT_VERSION), - quarkusProps, - extensionsToAdd); - } else if (invocation.getQuarkusProject().getBuildTool().equals(BuildTool.GRADLE_KOTLIN_DSL)) { - final KotlinGradleBuildFilesCreator generator = new KotlinGradleBuildFilesCreator( - invocation.getQuarkusProject()); - generator.create( - invocation.getStringValue(PROJECT_GROUP_ID), - invocation.getStringValue(PROJECT_ARTIFACT_ID), - invocation.getStringValue(PROJECT_VERSION), - quarkusProps, - extensionsToAdd); - } else { - final ExtensionManager.InstallResult result = invocation.getQuarkusProject().getExtensionManager() - .install(extensionsToAdd); - result.getInstalled() - .forEach(a -> invocation.log() - .info(MessageIcons.OK_ICON + " Extension " + a.getGroupId() + ":" + a.getArtifactId() - + " has been installed")); - } - } } catch (IOException e) { throw new QuarkusCommandException("Failed to create project", e); } return QuarkusCommandOutcome.success(); } - - // # CLOSE YOUR EYES PLEASE - static void addPlatformDataToLegacyCodegen(QuarkusCommandInvocation invocation) { - final BuildTool buildTool = invocation.getQuarkusProject().getBuildTool(); - if (BuildTool.MAVEN == buildTool) { - final Optional mavenRepositories = NestedMaps.getValue(invocation.getPlatformDescriptor().getMetadata(), - "maven.repositories"); - if (mavenRepositories.isPresent() - && !mavenRepositories.get().isEmpty()) { - // We only take the first one here to make things simpler: - final Map repo = (Map) mavenRepositories.get().get(0); - if (repo != null && repo.get("id") instanceof String && repo.get("url") instanceof String) { - final StringBuilder repositories = new StringBuilder() - .append("\n") - .append(" \n") - .append(" \n") - .append(" ").append(repo.get("id")).append("\n") - .append(" ").append(repo.get("url")).append("\n") - .append(" \n") - .append(" ").append(repo.getOrDefault("releases-enabled", true)) - .append("\n") - .append(" \n") - .append(" \n") - .append(" ").append(repo.getOrDefault("snapshots-enabled", true)) - .append("\n") - .append(" \n") - .append(" \n") - .append(" \n"); - invocation.setValue(MAVEN_REPOSITORIES, repositories.toString()); - } - } - final Optional mavenPluginRepositories = NestedMaps - .getValue(invocation.getPlatformDescriptor().getMetadata(), "maven.plugin-repositories"); - if (mavenPluginRepositories.isPresent() - && !mavenPluginRepositories.get().isEmpty()) { - // We only take the first one here to make things simpler: - final Map repo = (Map) mavenPluginRepositories.get().get(0); - if (repo != null && repo.get("id") instanceof String && repo.get("url") instanceof String) { - final StringBuilder pluginRepositories = new StringBuilder() - .append("\n") - .append(" \n") - .append(" \n") - .append(" ").append(repo.get("id")).append("\n") - .append(" ").append(repo.get("url")).append("\n") - .append(" \n") - .append(" ").append(repo.getOrDefault("releases-enabled", true)) - .append("\n") - .append(" \n") - .append(" \n") - .append(" ").append(repo.getOrDefault("snapshots-enabled", true)) - .append("\n") - .append(" \n") - .append(" \n") - .append(" \n"); - invocation.setValue(MAVEN_PLUGIN_REPOSITORIES, pluginRepositories.toString()); - } - } - } else if (BuildTool.GRADLE == buildTool || BuildTool.GRADLE_KOTLIN_DSL == buildTool) { - final Optional gradleRepositories = NestedMaps - .getValue(invocation.getPlatformDescriptor().getMetadata(), "gradle.repositories"); - if (gradleRepositories.isPresent() - && !gradleRepositories.get().isEmpty()) { - // We only take the first one here to make things simpler: - final Map repo = (Map) gradleRepositories.get().get(0); - if (repo != null && repo.get("url") instanceof String) { - final String repositories = buildTool == BuildTool.GRADLE - ? "\n maven { url \"" + repo.get("url") + "\" }" - : "\n maven { url = uri(\"" + repo.get("url") + "\") }"; - invocation.setValue(MAVEN_REPOSITORIES, repositories); - } - } - final Optional gradlePluginRepositories = NestedMaps - .getValue(invocation.getPlatformDescriptor().getMetadata(), "gradle.plugin-repositories"); - if (gradlePluginRepositories.isPresent() - && !gradlePluginRepositories.get().isEmpty()) { - // We only take the first one here to make things simpler: - final Map repo = (Map) gradlePluginRepositories.get().get(0); - if (repo != null && repo.get("url") instanceof String) { - final String pluginRepositories = buildTool == BuildTool.GRADLE - ? "\n maven { url \"" + repo.get("url") + "\" }" - : "\n maven { url = uri(\"" + repo.get("url") + "\") }"; - invocation.setValue(MAVEN_PLUGIN_REPOSITORIES, pluginRepositories); - } - } - } - } - // # YOU CAN OPEN NOW :) } diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/handlers/LegacyCreateProjectCommandHandler.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/handlers/LegacyCreateProjectCommandHandler.java new file mode 100644 index 00000000000000..8a45c6f909df9f --- /dev/null +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/handlers/LegacyCreateProjectCommandHandler.java @@ -0,0 +1,196 @@ +package io.quarkus.devtools.commands.handlers; + +import static io.quarkus.devtools.commands.handlers.QuarkusCommandHandlers.computeCoordsFromQuery; +import static io.quarkus.devtools.project.codegen.ProjectGenerator.*; + +import io.quarkus.bootstrap.model.AppArtifactCoords; +import io.quarkus.devtools.codestarts.utils.NestedMaps; +import io.quarkus.devtools.commands.data.QuarkusCommandException; +import io.quarkus.devtools.commands.data.QuarkusCommandInvocation; +import io.quarkus.devtools.commands.data.QuarkusCommandOutcome; +import io.quarkus.devtools.messagewriter.MessageIcons; +import io.quarkus.devtools.project.BuildTool; +import io.quarkus.devtools.project.buildfile.GroovyGradleBuildFilesCreator; +import io.quarkus.devtools.project.buildfile.KotlinGradleBuildFilesCreator; +import io.quarkus.devtools.project.codegen.ProjectGenerator; +import io.quarkus.devtools.project.codegen.ProjectGeneratorRegistry; +import io.quarkus.devtools.project.codegen.SourceType; +import io.quarkus.devtools.project.codegen.rest.BasicRestProjectGenerator; +import io.quarkus.devtools.project.extensions.ExtensionManager; +import io.quarkus.platform.descriptor.QuarkusPlatformDescriptor; +import io.quarkus.platform.tools.ToolsUtils; +import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Properties; +import java.util.Set; + +/** + * Instances of this class are thread-safe. They create a new project extracting all the necessary properties from an instance + * of {@link QuarkusCommandInvocation}. + */ +public class LegacyCreateProjectCommandHandler implements QuarkusCommandHandler { + + @Override + public QuarkusCommandOutcome execute(QuarkusCommandInvocation invocation) throws QuarkusCommandException { + final QuarkusPlatformDescriptor platformDescr = invocation.getPlatformDescriptor(); + invocation.setValue(BOM_GROUP_ID, platformDescr.getBomGroupId()); + invocation.setValue(BOM_ARTIFACT_ID, platformDescr.getBomArtifactId()); + invocation.setValue(QUARKUS_VERSION, platformDescr.getQuarkusVersion()); + invocation.setValue(BOM_VERSION, platformDescr.getBomVersion()); + final Set extensionsQuery = invocation.getValue(ProjectGenerator.EXTENSIONS, Collections.emptySet()); + + final Properties quarkusProps = ToolsUtils.readQuarkusProperties(platformDescr); + quarkusProps.forEach((k, v) -> { + String name = k.toString().replace("-", "_"); + if (!invocation.hasValue(name)) { + invocation.setValue(k.toString().replace("-", "_"), v.toString()); + } + }); + + addPlatformDataToLegacyCodegen(invocation); + + try { + String className = invocation.getStringValue(CLASS_NAME); + if (className != null) { + className = invocation.getValue(SOURCE_TYPE, SourceType.JAVA).stripExtensionFrom(className); + int idx = className.lastIndexOf('.'); + if (idx >= 0) { + String pkgName = invocation.getStringValue(PACKAGE_NAME); + if (pkgName == null) { + invocation.setValue(PACKAGE_NAME, className.substring(0, idx)); + } + className = className.substring(idx + 1); + } + invocation.setValue(CLASS_NAME, className); + } + + final List extensionsToAdd = computeCoordsFromQuery(invocation, extensionsQuery); + + // extensionsToAdd is null when an error occurred while matching extensions + if (extensionsToAdd != null) { + ProjectGeneratorRegistry.get(BasicRestProjectGenerator.NAME).generate(invocation); + + //TODO ia3andy extensions should be added directly during the project generation + if (invocation.getQuarkusProject().getBuildTool().equals(BuildTool.GRADLE)) { + final GroovyGradleBuildFilesCreator generator = new GroovyGradleBuildFilesCreator( + invocation.getQuarkusProject()); + generator.create( + invocation.getStringValue(PROJECT_GROUP_ID), + invocation.getStringValue(PROJECT_ARTIFACT_ID), + invocation.getStringValue(PROJECT_VERSION), + quarkusProps, + extensionsToAdd); + } else if (invocation.getQuarkusProject().getBuildTool().equals(BuildTool.GRADLE_KOTLIN_DSL)) { + final KotlinGradleBuildFilesCreator generator = new KotlinGradleBuildFilesCreator( + invocation.getQuarkusProject()); + generator.create( + invocation.getStringValue(PROJECT_GROUP_ID), + invocation.getStringValue(PROJECT_ARTIFACT_ID), + invocation.getStringValue(PROJECT_VERSION), + quarkusProps, + extensionsToAdd); + } else { + final ExtensionManager.InstallResult result = invocation.getQuarkusProject().getExtensionManager() + .install(extensionsToAdd); + result.getInstalled() + .forEach(a -> invocation.log() + .info(MessageIcons.OK_ICON + " Extension " + a.getGroupId() + ":" + a.getArtifactId() + + " has been installed")); + } + } + } catch (IOException e) { + throw new QuarkusCommandException("Failed to create project", e); + } + return QuarkusCommandOutcome.success(); + } + + // # CLOSE YOUR EYES PLEASE + static void addPlatformDataToLegacyCodegen(QuarkusCommandInvocation invocation) { + final BuildTool buildTool = invocation.getQuarkusProject().getBuildTool(); + if (BuildTool.MAVEN == buildTool) { + final Optional mavenRepositories = NestedMaps.getValue(invocation.getPlatformDescriptor().getMetadata(), + "maven.repositories"); + if (mavenRepositories.isPresent() + && !mavenRepositories.get().isEmpty()) { + // We only take the first one here to make things simpler: + final Map repo = (Map) mavenRepositories.get().get(0); + if (repo != null && repo.get("id") instanceof String && repo.get("url") instanceof String) { + final StringBuilder repositories = new StringBuilder() + .append("\n") + .append(" \n") + .append(" \n") + .append(" ").append(repo.get("id")).append("\n") + .append(" ").append(repo.get("url")).append("\n") + .append(" \n") + .append(" ").append(repo.getOrDefault("releases-enabled", true)) + .append("\n") + .append(" \n") + .append(" \n") + .append(" ").append(repo.getOrDefault("snapshots-enabled", true)) + .append("\n") + .append(" \n") + .append(" \n") + .append(" \n"); + invocation.setValue(MAVEN_REPOSITORIES, repositories.toString()); + } + } + final Optional mavenPluginRepositories = NestedMaps + .getValue(invocation.getPlatformDescriptor().getMetadata(), "maven.plugin-repositories"); + if (mavenPluginRepositories.isPresent() + && !mavenPluginRepositories.get().isEmpty()) { + // We only take the first one here to make things simpler: + final Map repo = (Map) mavenPluginRepositories.get().get(0); + if (repo != null && repo.get("id") instanceof String && repo.get("url") instanceof String) { + final StringBuilder pluginRepositories = new StringBuilder() + .append("\n") + .append(" \n") + .append(" \n") + .append(" ").append(repo.get("id")).append("\n") + .append(" ").append(repo.get("url")).append("\n") + .append(" \n") + .append(" ").append(repo.getOrDefault("releases-enabled", true)) + .append("\n") + .append(" \n") + .append(" \n") + .append(" ").append(repo.getOrDefault("snapshots-enabled", true)) + .append("\n") + .append(" \n") + .append(" \n") + .append(" \n"); + invocation.setValue(MAVEN_PLUGIN_REPOSITORIES, pluginRepositories.toString()); + } + } + } else if (BuildTool.GRADLE == buildTool || BuildTool.GRADLE_KOTLIN_DSL == buildTool) { + final Optional gradleRepositories = NestedMaps + .getValue(invocation.getPlatformDescriptor().getMetadata(), "gradle.repositories"); + if (gradleRepositories.isPresent() + && !gradleRepositories.get().isEmpty()) { + // We only take the first one here to make things simpler: + final Map repo = (Map) gradleRepositories.get().get(0); + if (repo != null && repo.get("url") instanceof String) { + final String repositories = buildTool == BuildTool.GRADLE + ? "\n maven { url \"" + repo.get("url") + "\" }" + : "\n maven { url = uri(\"" + repo.get("url") + "\") }"; + invocation.setValue(MAVEN_REPOSITORIES, repositories); + } + } + final Optional gradlePluginRepositories = NestedMaps + .getValue(invocation.getPlatformDescriptor().getMetadata(), "gradle.plugin-repositories"); + if (gradlePluginRepositories.isPresent() + && !gradlePluginRepositories.get().isEmpty()) { + // We only take the first one here to make things simpler: + final Map repo = (Map) gradlePluginRepositories.get().get(0); + if (repo != null && repo.get("url") instanceof String) { + final String pluginRepositories = buildTool == BuildTool.GRADLE + ? "\n maven { url \"" + repo.get("url") + "\" }" + : "\n maven { url = uri(\"" + repo.get("url") + "\") }"; + invocation.setValue(MAVEN_PLUGIN_REPOSITORIES, pluginRepositories); + } + } + } + } + // # YOU CAN OPEN NOW :) +} diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/extensions/Extensions.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/extensions/Extensions.java index da3b60d9f8ae57..b6039f608c3aaa 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/extensions/Extensions.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/extensions/Extensions.java @@ -37,6 +37,25 @@ public static AppArtifactCoords toCoords(final Dependency d, final String overri return overrideVersion(toCoords(d), overrideVersion); } + public static String toGAV(AppArtifactCoords c) { + if (c.getVersion() == null) { + return toGA(c); + } + return c.getGroupId() + ":" + c.getArtifactId() + ":" + c.getVersion(); + } + + public static String toGA(AppArtifactCoords c) { + return c.getGroupId() + ":" + c.getArtifactId(); + } + + public static String toGA(AppArtifactKey c) { + return c.getGroupId() + ":" + c.getArtifactId(); + } + + public static String toGA(Extension e) { + return e.getGroupId() + ":" + e.getArtifactId(); + } + public static AppArtifactCoords stripVersion(final AppArtifactCoords coords) { return overrideVersion(coords, null); } diff --git a/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/QuarkusCodestartCatalogTest.java b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/QuarkusCodestartCatalogTest.java index f87703b7c3a5df..0c30e00a9f9992 100644 --- a/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/QuarkusCodestartCatalogTest.java +++ b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/QuarkusCodestartCatalogTest.java @@ -146,6 +146,7 @@ void prepareProjectTestResteasy() throws IOException { @Test void prepareProjectTestCommandMode() throws IOException { final QuarkusCodestartProjectInput input = QuarkusCodestartProjectInput.builder() + .addCodestart("commandmode") .build(); final CodestartProjectDefinition projectDefinition = getCatalog().createProject(input); assertThat(projectDefinition.getBaseCodestarts()).extracting(Codestart::getName) diff --git a/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/QuarkusCodestartGenerationTest.java b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/QuarkusCodestartGenerationTest.java index e5218ea8fad3ab..59dfe22e5fdf0a 100644 --- a/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/QuarkusCodestartGenerationTest.java +++ b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/QuarkusCodestartGenerationTest.java @@ -15,6 +15,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import io.quarkus.bootstrap.model.AppArtifactCoords; import io.quarkus.bootstrap.model.AppArtifactKey; import io.quarkus.devtools.PlatformAwareTestBase; import io.quarkus.devtools.ProjectTestUtil; @@ -80,8 +81,9 @@ void generateCodestartProjectEmpty() throws IOException { } @Test - void generateCodestartProjectDefaultWithExamples() throws IOException { + void generateCodestartProjectCommandMode() throws IOException { final QuarkusCodestartProjectInput input = QuarkusCodestartProjectInput.builder() + .addCodestart("commandmode") .addData(getTestInputData()) .build(); @@ -99,6 +101,7 @@ void generateCodestartProjectDefaultWithExamples() throws IOException { @Test void generateCodestartProjectCommandModeCustom() throws IOException { final QuarkusCodestartProjectInput input = QuarkusCodestartProjectInput.builder() + .addCodestart("commandmode") .addData(getTestInputData()) .putData(COMMANDMODE_EXAMPLE_PACKAGE_NAME.getKey(), "com.test.andy") .putData(COMMANDMODE_EXAMPLE_RESOURCE_CLASS_NAME.getKey(), "AndyCommando") @@ -148,6 +151,30 @@ void generateCodestartProjectRESTEasyJavaCustom() throws IOException { .satisfies(checkContains("class NativeBonjourResourceIT extends BonjourResourceTest")); } + @Test + void generateMavenProjectWithCustomDep() throws IOException { + final QuarkusCodestartProjectInput input = QuarkusCodestartProjectInput.builder() + .addData(getTestInputData()) + .addExtension(AppArtifactKey.fromString("io.quarkus:quarkus-resteasy")) + .addExtension(AppArtifactCoords.fromString("commons-io:commons-io:2.5")) + + .build(); + final Path projectDir = testDirPath.resolve("maven-custom-dep"); + getCatalog().createProject(input).generate(projectDir); + + checkMaven(projectDir); + assertThat(projectDir.resolve("pom.xml")).exists() + .satisfies(checkContains("\n" + + " commons-io\n" + + " commons-io\n" + + " 2.5\n" + + " \n")) + .satisfies(checkContains("\n" + + " io.quarkus\n" + + " quarkus-resteasy\n" + + " \n")); + } + @Test void generateCodestartProjectRESTEasyKotlinCustom() throws IOException { final QuarkusCodestartProjectInput input = QuarkusCodestartProjectInput.builder() @@ -214,6 +241,24 @@ void generateCodestartProjectRESTEasyScalaCustom() throws IOException { .satisfies(checkContains("class NativeBonjourResourceIT extends BonjourResourceTest")); } + @Test + void generateCodestartProjectMavenDefaultJava() throws IOException { + final QuarkusCodestartProjectInput input = QuarkusCodestartProjectInput.builder() + .addData(getTestInputData()) + .build(); + final Path projectDir = testDirPath.resolve("maven-default-java"); + getCatalog().createProject(input).generate(projectDir); + + checkMaven(projectDir); + checkReadme(projectDir); + checkDockerfiles(projectDir); + checkConfigProperties(projectDir); + + assertThat(projectDir.resolve("src/main/java/org/acme/resteasy/ExampleResource.java")).exists(); + assertThat(projectDir.resolve("src/test/java/org/acme/resteasy/ExampleResourceTest.java")).exists(); + assertThat(projectDir.resolve("src/test/java/org/acme/resteasy/NativeExampleResourceIT.java")).exists(); + } + @Test void generateCodestartProjectMavenResteasyJava() throws IOException { final QuarkusCodestartProjectInput input = QuarkusCodestartProjectInput.builder() diff --git a/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/QuarkusCodestartRunIT.java b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/QuarkusCodestartRunIT.java index 0f86a60776f480..fdea8a70dbbb70 100644 --- a/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/QuarkusCodestartRunIT.java +++ b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/QuarkusCodestartRunIT.java @@ -56,16 +56,16 @@ private Stream provideGenerateCombinations() throws IOException { .filter(c -> !EXCLUDED.contains(c.getName())) .collect(Collectors.toList()); final List> runAlone = examples.stream() - .filter(c -> c.containsTag(Tag.COMPATIBILITY_ISSUES.getKey())) + .filter(c -> c.containsTag(Tag.SINGLETON_EXAMPLE.getKey())) .map(Codestart::getName) .map(Collections::singletonList) .collect(Collectors.toList()); final List runTogether = examples.stream() - .filter(c -> !c.containsTag(Tag.COMPATIBILITY_ISSUES.getKey())) + .filter(c -> !c.containsTag(Tag.SINGLETON_EXAMPLE.getKey())) .map(Codestart::getName) .collect(Collectors.toList()); return Stream.of("java", "kotlin", "scala") - .flatMap(l -> Stream.concat(Stream.of(runTogether, Collections.emptyList()), Stream.of(runAlone.toArray())) + .flatMap(l -> Stream.concat(Stream.of(runTogether), Stream.of(runAlone.toArray())) .map(c -> Arguments.of(l, c))); } diff --git a/integration-tests/devtools/src/test/java/io/quarkus/devtools/commands/CreateProjectPlatformMetadataTest.java b/integration-tests/devtools/src/test/java/io/quarkus/devtools/commands/CreateProjectPlatformMetadataTest.java index dbf24cb357bca6..dac02c1546b6b9 100644 --- a/integration-tests/devtools/src/test/java/io/quarkus/devtools/commands/CreateProjectPlatformMetadataTest.java +++ b/integration-tests/devtools/src/test/java/io/quarkus/devtools/commands/CreateProjectPlatformMetadataTest.java @@ -31,11 +31,11 @@ public class CreateProjectPlatformMetadataTest extends PlatformAwareTestBase { private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); @ParameterizedTest - @ValueSource(booleans = { true, false }) - public void create(boolean codestartsEnabled) throws Exception { + @ValueSource(booleans = { false, true }) + public void create(boolean legacyCodegen) throws Exception { final File file = new File("target/meta-rest"); ProjectTestUtil.delete(file); - createProject(BuildTool.MAVEN, file, "io.quarkus", "basic-rest", "1.0.0-SNAPSHOT", codestartsEnabled); + createProject(BuildTool.MAVEN, file, "io.quarkus", "basic-rest", "1.0.0-SNAPSHOT", legacyCodegen); assertThat(file.toPath().resolve("pom.xml")) .exists() .satisfies(checkContains("redhat")) @@ -47,11 +47,11 @@ public void create(boolean codestartsEnabled) throws Exception { } @ParameterizedTest - @ValueSource(booleans = { true, false }) - public void createGradle(boolean codestartsEnabled) throws Exception { + @ValueSource(booleans = { false, true }) + public void createGradle(boolean legacyCodegen) throws Exception { final File file = new File("target/meta-rest-gradle"); ProjectTestUtil.delete(file); - createProject(BuildTool.GRADLE, file, "io.quarkus", "basic-rest", "1.0.0-SNAPSHOT", codestartsEnabled); + createProject(BuildTool.GRADLE, file, "io.quarkus", "basic-rest", "1.0.0-SNAPSHOT", legacyCodegen); assertThat(file.toPath().resolve("build.gradle")) .exists() .satisfies(checkContains("maven { url \"https://maven.repository.redhat.com\" }")); @@ -61,7 +61,7 @@ public void createGradle(boolean codestartsEnabled) throws Exception { public void createGradleKotlin() throws Exception { final File file = new File("target/meta-rest-gradle-kts"); ProjectTestUtil.delete(file); - createProject(BuildTool.GRADLE_KOTLIN_DSL, file, "io.quarkus", "basic-rest", "1.0.0-SNAPSHOT", true); + createProject(BuildTool.GRADLE_KOTLIN_DSL, file, "io.quarkus", "basic-rest", "1.0.0-SNAPSHOT", false); assertThat(file.toPath().resolve("build.gradle.kts")) .exists() .satisfies(checkContains("maven { url = uri(\"https://maven.repository.redhat.com\") }")); @@ -77,7 +77,7 @@ private Map getMetadata() throws java.io.IOException { } private void createProject(BuildTool buildTool, File file, String groupId, String artifactId, String version, - boolean codestartsEnabled) + boolean legacyCodegen) throws QuarkusCommandException, IOException { final QuarkusPlatformDescriptor platformDescriptor = getPlatformDescriptor(); final QuarkusPlatformDescriptor spy = spy(platformDescriptor); @@ -86,7 +86,7 @@ private void createProject(BuildTool buildTool, File file, String groupId, Strin .buildTool(buildTool) .groupId(groupId) .artifactId(artifactId) - .codestartsEnabled(codestartsEnabled) + .legacyCodegen(legacyCodegen) .version(version) .quarkusMavenPluginVersion("2.3.5") .quarkusGradlePluginVersion("2.3.5-gradle") diff --git a/integration-tests/devtools/src/test/java/io/quarkus/devtools/commands/CreateProjectTest.java b/integration-tests/devtools/src/test/java/io/quarkus/devtools/commands/CreateProjectTest.java index 90c09d8afbf1c7..c217e0041a43f9 100644 --- a/integration-tests/devtools/src/test/java/io/quarkus/devtools/commands/CreateProjectTest.java +++ b/integration-tests/devtools/src/test/java/io/quarkus/devtools/commands/CreateProjectTest.java @@ -3,7 +3,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.contentOf; -import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; @@ -19,7 +18,6 @@ import java.util.stream.IntStream; import org.apache.maven.model.Model; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; @@ -42,7 +40,7 @@ public void create() throws Exception { final File gitignore = new File(file, ".gitignore"); assertTrue(gitignore.exists()); final String gitignoreContent = new String(Files.readAllBytes(gitignore.toPath()), StandardCharsets.UTF_8); - assertTrue(gitignoreContent.contains("\ntarget/\n")); + assertThat(gitignoreContent).matches("(?s).*target/\\R.*"); } @Test @@ -54,9 +52,9 @@ public void createGradle() throws Exception { final File gitignore = new File(file, ".gitignore"); assertTrue(gitignore.exists()); final String gitignoreContent = new String(Files.readAllBytes(gitignore.toPath()), StandardCharsets.UTF_8); - Assertions.assertFalse(gitignoreContent.contains("\ntarget/\n")); - assertTrue(gitignoreContent.contains("\nbuild/")); - assertTrue(gitignoreContent.contains("\n.gradle/\n")); + assertThat(gitignoreContent).doesNotMatch("(?s).*target/\\R.*"); + assertThat(gitignoreContent).matches("(?s).*build/\\R.*"); + assertThat(gitignoreContent).matches("(?s).*\\.gradle/\\R.*"); assertThat(new File(file, "README.md")).exists(); assertThat(contentOf(new File(file, "README.md"), "UTF-8")).contains("./gradlew"); diff --git a/integration-tests/gradle/src/test/java/io/quarkus/gradle/QuarkusPluginFunctionalTest.java b/integration-tests/gradle/src/test/java/io/quarkus/gradle/QuarkusPluginFunctionalTest.java index c43c4b8b141693..f54525a1023489 100644 --- a/integration-tests/gradle/src/test/java/io/quarkus/gradle/QuarkusPluginFunctionalTest.java +++ b/integration-tests/gradle/src/test/java/io/quarkus/gradle/QuarkusPluginFunctionalTest.java @@ -85,7 +85,7 @@ public void canDetectResourceChangeWhenBuilding() throws Exception { assertThat(firstBuild.getTasks().get(":quarkusBuild")).isEqualTo(BuildResult.SUCCESS_OUTCOME); final File applicationProperties = projectRoot.toPath().resolve("src/main/resources/application.properties").toFile(); - DevModeTestUtils.filter(applicationProperties, ImmutableMap.of("# Configuration file", "quarkus.http.port=8888")); + Files.write(applicationProperties.toPath(), "quarkus.http.port=8888".getBytes()); BuildResult secondBuild = runGradleWrapper(projectRoot, "quarkusBuild", "--stacktrace"); assertThat(secondBuild.getTasks().get(":quarkusBuild")).isEqualTo(BuildResult.SUCCESS_OUTCOME); diff --git a/integration-tests/kotlin/src/test/java/io/quarkus/kotlin/maven/it/KotlinCreateMavenProjectIT.java b/integration-tests/kotlin/src/test/java/io/quarkus/kotlin/maven/it/KotlinCreateMavenProjectIT.java index ea79b3193570da..ff46b7862acb3b 100644 --- a/integration-tests/kotlin/src/test/java/io/quarkus/kotlin/maven/it/KotlinCreateMavenProjectIT.java +++ b/integration-tests/kotlin/src/test/java/io/quarkus/kotlin/maven/it/KotlinCreateMavenProjectIT.java @@ -47,7 +47,7 @@ public void testProjectGenerationFromScratchForKotlin() throws MavenInvocationEx String config = Files .asCharSource(new File(testDir, "src/main/resources/application.properties"), Charsets.UTF_8) .read(); - assertThat(config).contains("key = value"); + assertThat(config).isEmpty(); assertThat(new File(testDir, "src/main/docker/Dockerfile.native")).isFile(); assertThat(new File(testDir, "src/main/docker/Dockerfile.jvm")).isFile(); diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectMojoIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectMojoIT.java index a4080a294b610a..7fe3d0dd70bbbf 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectMojoIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectMojoIT.java @@ -75,7 +75,7 @@ public void testProjectGenerationFromScratch() throws MavenInvocationException, String config = Files .asCharSource(new File(testDir, "src/main/resources/application.properties"), Charsets.UTF_8) .read(); - assertThat(config).contains("key = value"); + assertThat(config).isEmpty(); assertThat(new File(testDir, "src/main/docker/Dockerfile.native")).isFile(); assertThat(new File(testDir, "src/main/docker/Dockerfile.jvm")).isFile(); @@ -130,6 +130,7 @@ public void testProjectGenerationFromScratchWithResource() throws Exception { properties.put("projectGroupId", "org.acme"); properties.put("projectArtifactId", "acme"); properties.put("className", "org.acme.MyResource.java"); + properties.put("extensions", "resteasy"); InvocationResult result = setup(properties); assertThat(result.getExitCode()).isZero(); @@ -173,7 +174,7 @@ public void testProjectGenerationFromScratchWithMissingExtensionShouldFail() thr properties.put("extensions", "resteasy,smallrye-metrics,missing"); InvocationResult result = setup(properties); - assertThat(result.getExitCode()).isZero(); + assertThat(result.getExitCode()).isOne(); } @Test @@ -228,7 +229,7 @@ public void testGradleProjectGenerationFromScratchWithExtensions() throws Except properties.put("projectGroupId", "org.acme"); properties.put("projectArtifactId", "acme"); properties.put("className", "org.acme.MyResource"); - properties.put("extensions", "kotlin,jackson"); + properties.put("extensions", "kotlin,resteasy,jackson"); properties.put("buildTool", "gradle"); InvocationResult result = setup(properties); @@ -263,7 +264,7 @@ public void testProjectGenerationFromScratchWithCustomDependencies() throws Exce properties.put("projectGroupId", "org.acme"); properties.put("projectArtifactId", "acme"); properties.put("className", "org.acme.MyResource"); - properties.put("extensions", "commons-io:commons-io:2.5"); + properties.put("extensions", "resteasy,commons-io:commons-io:2.5"); InvocationResult result = setup(properties); assertThat(result.getExitCode()).isZero(); @@ -302,6 +303,7 @@ public void testThatDefaultPackageAreReplaced() throws Exception { Properties properties = new Properties(); properties.put("className", "MyGreatResource"); + properties.put("extensions", "resteasy"); InvocationResult result = setup(properties); assertThat(result.getExitCode()).isZero(); @@ -334,6 +336,7 @@ public void generateNewProjectAndRun() throws Exception { Properties properties = new Properties(); properties.put("projectGroupId", "org.acme"); properties.put("projectArtifactId", "acme"); + properties.put("extensions", "resteasy"); properties.put("className", "org.acme.HelloResource"); InvocationResult result = setup(properties); @@ -368,7 +371,7 @@ private InvocationResult setup(Properties params) request.setGoals(Collections.singletonList( getMavenPluginGroupId() + ":" + getMavenPluginArtifactId() + ":" + getMavenPluginVersion() + ":create")); request.setDebug(false); - request.setShowErrors(false); + request.setShowErrors(true); request.setProperties(params); getEnv().forEach(request::addShellEnvironment); File log = new File(testDir, "build-create-" + testDir.getName() + ".log"); diff --git a/integration-tests/scala/src/test/java/io/quarkus/scala/maven/it/ScalaCreateMavenProjectIT.java b/integration-tests/scala/src/test/java/io/quarkus/scala/maven/it/ScalaCreateMavenProjectIT.java index e086dffd40cbd3..4a25f04bba3e6e 100644 --- a/integration-tests/scala/src/test/java/io/quarkus/scala/maven/it/ScalaCreateMavenProjectIT.java +++ b/integration-tests/scala/src/test/java/io/quarkus/scala/maven/it/ScalaCreateMavenProjectIT.java @@ -48,7 +48,7 @@ public void testProjectGenerationFromScratchForScala() throws MavenInvocationExc String config = Files .asCharSource(new File(testDir, "src/main/resources/application.properties"), Charsets.UTF_8) .read(); - assertThat(config).contains("key = value"); + assertThat(config).isEmpty(); assertThat(new File(testDir, "src/main/docker/Dockerfile.native")).isFile(); assertThat(new File(testDir, "src/main/docker/Dockerfile.jvm")).isFile();