From 9f352cc7ae936e30e2332b5e947dfb7f1486714e Mon Sep 17 00:00:00 2001 From: Andy Damevin Date: Mon, 10 Aug 2020 11:36:19 +0200 Subject: [PATCH] Use metadata for gradle/maven repositories and separate gradle plugin version As part of #11256 --- .../src/main/filtered/quarkus.properties | 14 ++- .../base/build-layout.include.qute | 5 + .../base/gradle.tpl.qute.properties | 4 +- .../{ => gradle}/wrapper/gradle-wrapper.jar | Bin .../gradle-wrapper.tpl.qute.properties | 0 .../base/settings.tpl.qute.gradle.kts | 8 +- .../buildtool/gradle-kotlin-dsl/codestart.yml | 2 +- .../java/build.tpl.qute.gradle.kts | 2 +- .../kotlin/build.tpl.qute.gradle.kts | 2 +- .../scala/build.tpl.qute.gradle.kts | 4 +- .../gradle/base/build-layout.include.qute | 7 +- .../gradle/base/gradle.tpl.qute.properties | 4 +- .../gradle/base/settings.tpl.qute.gradle | 7 +- .../buildtool/gradle/codestart.yml | 2 +- .../gradle/java/build.tpl.qute.gradle | 2 +- .../gradle/kotlin/build.tpl.qute.gradle | 2 +- .../gradle/scala/build.tpl.qute.gradle | 4 +- .../buildtool/maven/base/pom.tpl.qute.xml | 39 ++++++- .../main/docker/Dockerfile.tpl.qute.fast-jar | 6 +- .../src/main/docker/Dockerfile.tpl.qute.jvm | 6 +- .../main/docker/Dockerfile.tpl.qute.native | 2 +- .../tooling/dockerfiles/codestart.yml | 14 +++ .../java/gradle.properties-template.ftl | 2 +- .../basic-rest/java/pom.xml-template.ftl | 6 +- .../java/settings.gradle-template.ftl | 4 +- .../kotlin/gradle.properties-template.ftl | 2 +- .../basic-rest/kotlin/pom.xml-template.ftl | 6 +- .../kotlin/settings.gradle-template.ftl | 4 +- .../scala/gradle.properties-template.ftl | 2 +- .../basic-rest/scala/pom.xml-template.ftl | 6 +- .../scala/settings.gradle-template.ftl | 4 +- .../src/test/resources/fakeextensions.json | 34 ++++-- .../devtools/codestarts/CodestartData.java | 64 +---------- .../devtools/codestarts/Codestarts.java | 10 +- ...tPomMergeCodestartFileStrategyHandler.java | 4 +- .../codestarts/QuarkusCodestartData.java | 79 +++++++++++++ .../devtools/commands/CreateProject.java | 19 ++- .../handlers/CreateProjectCommandHandler.java | 108 +++++++++++++++++- .../quarkus/devtools/project/BuildTool.java | 18 +-- .../AbstractGradleBuildFilesCreator.java | 3 +- .../project/codegen/ProjectGenerator.java | 3 +- .../platform/tools/ToolsConstants.java | 11 +- .../io/quarkus/platform/tools/ToolsUtils.java | 35 ++++-- .../src/test/filtered/quarkus.properties | 14 ++- .../descriptor/PlatformAwareTestBase.java | 34 ------ .../QuarkusTestPlatformDescriptorLoader.java | 6 +- ...QuarkusJsonPlatformDescriptorResolver.java | 7 +- .../src/test/resources/quarkus.properties | 2 +- .../devtools/PlatformAwareTestBase.java | 32 ++---- .../CodestartProjectGenerationTest.java | 37 +++--- .../codestarts/CodestartProjectRunTest.java | 8 +- .../CodestartProjectTestRunner.java | 1 + .../devtools/codestarts/CodestartsTest.java | 2 +- .../commands/AbstractAddExtensionsTest.java | 13 ++- .../AbstractRemoveExtensionsTest.java | 5 +- .../CreateProjectPlatformMetadataTest.java | 96 ++++++++++++++++ .../devtools/commands/CreateProjectTest.java | 3 +- .../devtools/commands/ListExtensionsTest.java | 14 ++- .../rest/BasicRestProjectGeneratorTest.java | 2 +- .../src/test/resources/platform-metadata.json | 28 +++++ .../maven/it/KotlinCreateMavenProjectIT.java | 4 +- .../io/quarkus/maven/it/AddExtensionIT.java | 4 +- .../it/CreateProjectCodestartMojoIT.java | 4 +- .../quarkus/maven/it/CreateProjectMojoIT.java | 4 +- .../io/quarkus/maven/it/GenerateConfigIT.java | 4 +- .../io/quarkus/maven/it/ListExtensionsIT.java | 3 +- .../maven/it/ScalaCreateMavenProjectIT.java | 4 +- .../it/QuarkusPlatformAwareMojoTestBase.java | 20 ++-- 68 files changed, 619 insertions(+), 292 deletions(-) rename devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/{ => gradle}/wrapper/gradle-wrapper.jar (100%) rename devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/{ => gradle}/wrapper/gradle-wrapper.tpl.qute.properties (100%) create mode 100644 independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/QuarkusCodestartData.java create mode 100644 integration-tests/devtools/src/test/java/io/quarkus/devtools/commands/CreateProjectPlatformMetadataTest.java create mode 100644 integration-tests/devtools/src/test/resources/platform-metadata.json diff --git a/devtools/platform-descriptor-json/src/main/filtered/quarkus.properties b/devtools/platform-descriptor-json/src/main/filtered/quarkus.properties index 75b90715a75f6..2c025575f5827 100644 --- a/devtools/platform-descriptor-json/src/main/filtered/quarkus.properties +++ b/devtools/platform-descriptor-json/src/main/filtered/quarkus.properties @@ -8,10 +8,16 @@ kotlin-version=${kotlin.version} scala-version=${scala.version} scala-plugin-version=${scala-plugin.version} -# Plugin metadata -plugin-groupId=${project.groupId} -plugin-artifactId=quarkus-maven-plugin -plugin-version=${project.version} +quarkus-core-version=${project.version} + +# Maven plugin metadata +maven-plugin-groupId=${project.groupId} +maven-plugin-artifactId=quarkus-maven-plugin +maven-plugin-version=${project.version} + +# Gradle plugin metadata +gradle-plugin-id=io.quarkus +gradle-plugin-version=${project.version} supported-maven-versions=${supported-maven-versions} # the proposed version must be in the range of the supported versions diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/build-layout.include.qute b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/build-layout.include.qute index 77fb62af899b4..8fcd7516eba57 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/build-layout.include.qute +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/build-layout.include.qute @@ -8,6 +8,11 @@ plugins { repositories { mavenLocal() mavenCentral() +{#if gradle.repositories} +{#for rep in gradle.repositories} + maven { url = uri("{rep.url}") } +{/for} +{/if} } {/} diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/gradle.tpl.qute.properties b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/gradle.tpl.qute.properties index 72c7052dddd09..d3160667382c5 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/gradle.tpl.qute.properties +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/gradle.tpl.qute.properties @@ -1,6 +1,6 @@ #Gradle properties -#Tue Jun 16 08:41:21 UTC 2020 -quarkusPluginVersion={quarkus.plugin.version} +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 diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/wrapper/gradle-wrapper.jar b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/wrapper/gradle-wrapper.jar rename to devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/gradle/wrapper/gradle-wrapper.jar diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/wrapper/gradle-wrapper.tpl.qute.properties b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/gradle/wrapper/gradle-wrapper.tpl.qute.properties similarity index 100% rename from devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/wrapper/gradle-wrapper.tpl.qute.properties rename to devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/gradle/wrapper/gradle-wrapper.tpl.qute.properties diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/settings.tpl.qute.gradle.kts b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/settings.tpl.qute.gradle.kts index 0c69b3f424cb4..67eb7e52a3b19 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/settings.tpl.qute.gradle.kts +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/base/settings.tpl.qute.gradle.kts @@ -1,12 +1,18 @@ pluginManagement { val quarkusPluginVersion: String by settings + val quarkusPluginId: String by settings repositories { mavenLocal() mavenCentral() gradlePluginPortal() +{#if gradle.plugin-repositories} +{#for rep in gradle.plugin-repositories} + maven { url = uri("{rep.url}") } +{/for} +{/if} } plugins { - id("io.quarkus") version quarkusPluginVersion + id(quarkusPluginId) version quarkusPluginVersion } } rootProject.name="{project.artifact-id}" diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/codestart.yml index 846c3630639ab..c1e0e85761666 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/codestart.yml +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/codestart.yml @@ -7,7 +7,7 @@ language: base: data: quarkus: - plugin: + gradle-plugin: id: io.quarkus gradle: version: 6.5.1 diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/java/build.tpl.qute.gradle.kts b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/java/build.tpl.qute.gradle.kts index 1fa940f2319bb..07df0d995bd6d 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/java/build.tpl.qute.gradle.kts +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/java/build.tpl.qute.gradle.kts @@ -2,7 +2,7 @@ {#plugins} plugins { java - id("{quarkus.plugin.id}") + id("{quarkus.gradle-plugin.id}") } {/plugins} {/include} diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/kotlin/build.tpl.qute.gradle.kts b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/kotlin/build.tpl.qute.gradle.kts index 629b55ce763a2..1a169874299de 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/kotlin/build.tpl.qute.gradle.kts +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/kotlin/build.tpl.qute.gradle.kts @@ -3,7 +3,7 @@ plugins { kotlin("jvm") version "{kotlin.version}" kotlin("plugin.allopen") version "{kotlin.version}" - id("{quarkus.plugin.id}") + id("{quarkus.gradle-plugin.id}") } {/plugins} {/include} diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/scala/build.tpl.qute.gradle.kts b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/scala/build.tpl.qute.gradle.kts index 9564058a8f960..a6c4baa92a1a3 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/scala/build.tpl.qute.gradle.kts +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle-kotlin-dsl/scala/build.tpl.qute.gradle.kts @@ -2,9 +2,9 @@ {#plugins} plugins { scala - id("{quarkus.plugin.id}") + id("{quarkus.gradle-plugin.id}") } - {/plugins} +{/plugins} {/include} tasks.withType { diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/base/build-layout.include.qute b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/base/build-layout.include.qute index 271a56056f92b..2331838993019 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/base/build-layout.include.qute +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/base/build-layout.include.qute @@ -1,6 +1,6 @@ {#insert plugins} plugins { - id '{quarkus.plugin.id}' + id '{quarkus.gradle-plugin.id}' } {/} @@ -8,6 +8,11 @@ plugins { repositories { mavenLocal() mavenCentral() +{#if gradle.repositories} +{#for rep in gradle.repositories} + maven { url "{rep.url}" } +{/for} +{/if} } {/} diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/base/gradle.tpl.qute.properties b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/base/gradle.tpl.qute.properties index 72c7052dddd09..d3160667382c5 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/base/gradle.tpl.qute.properties +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/base/gradle.tpl.qute.properties @@ -1,6 +1,6 @@ #Gradle properties -#Tue Jun 16 08:41:21 UTC 2020 -quarkusPluginVersion={quarkus.plugin.version} +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 diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/base/settings.tpl.qute.gradle b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/base/settings.tpl.qute.gradle index adce284138546..74e5936fa0038 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/base/settings.tpl.qute.gradle +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/base/settings.tpl.qute.gradle @@ -3,9 +3,14 @@ pluginManagement { mavenLocal() mavenCentral() gradlePluginPortal() +{#if gradle.plugin-repositories} +{#for rep in gradle.plugin-repositories} + maven { url "{rep.url}" } +{/for} +{/if} } plugins { - id '{quarkus.plugin.id}' version "$\{quarkusPluginVersion}" + id "$\{quarkusPluginId}" version "$\{quarkusPluginVersion}" } } rootProject.name='{project.artifact-id}' diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/codestart.yml index f58facfda06de..c9411d1dbcdcc 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/codestart.yml +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/codestart.yml @@ -7,7 +7,7 @@ language: base: data: quarkus: - plugin: + gradle-plugin: id: io.quarkus gradle: version: 6.5.1 diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/java/build.tpl.qute.gradle b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/java/build.tpl.qute.gradle index 185ccdd49c664..2933d71345aa9 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/java/build.tpl.qute.gradle +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/java/build.tpl.qute.gradle @@ -2,7 +2,7 @@ {#plugins} plugins { id 'java' - id '{quarkus.plugin.id}' + id '{quarkus.gradle-plugin.id}' } {/plugins} {/include} diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/kotlin/build.tpl.qute.gradle b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/kotlin/build.tpl.qute.gradle index c9f177e677bfd..deb04d2f6bf96 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/kotlin/build.tpl.qute.gradle +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/kotlin/build.tpl.qute.gradle @@ -3,7 +3,7 @@ plugins { id 'org.jetbrains.kotlin.jvm' version "{kotlin.version}" id "org.jetbrains.kotlin.plugin.allopen" version "{kotlin.version}" - id '{quarkus.plugin.id}' + id '{quarkus.gradle-plugin.id}' } {/plugins} {/include} diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/scala/build.tpl.qute.gradle b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/scala/build.tpl.qute.gradle index 2367c8343a5f3..6119eea5168af 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/scala/build.tpl.qute.gradle +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/scala/build.tpl.qute.gradle @@ -2,9 +2,9 @@ {#plugins} plugins { id 'scala' - id '{quarkus.plugin.id}' + id '{quarkus.gradle-plugin.id}' } - {/plugins} +{/plugins} {/include} compileScala { diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/base/pom.tpl.qute.xml b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/base/pom.tpl.qute.xml index 520907e9c6158..74bfdaf6f16b1 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/base/pom.tpl.qute.xml +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/base/pom.tpl.qute.xml @@ -15,7 +15,7 @@ {quarkus.platform.group-id} {quarkus.platform.artifact-id} {quarkus.platform.version} - {quarkus.plugin.version} + {quarkus.maven-plugin.version} {maven-compiler-plugin.version} {maven-surefire-plugin.version} @@ -31,6 +31,39 @@ + {#if maven.repositories} + + + {#for rep in maven.repositories} + + {rep.id} + {rep.url} + + {rep.releases-enabled ?: true} + + + {rep.snapshots-enabled ?: true} + + + {/for} + + {/if} + {#if maven.plugin-repositories} + + {#for rep in maven.plugin-repositories} + + {rep.id} + {rep.url} + + {rep.releases-enabled ?: true} + + + {rep.snapshots-enabled ?: true} + + + {/for} + + {/if} {#each dependencies} @@ -65,8 +98,8 @@ - {quarkus.plugin.group-id} - {quarkus.plugin.artifact-id} + {quarkus.maven-plugin.group-id} + {quarkus.maven-plugin.artifact-id} $\{quarkus-plugin.version} {#if uberjar} diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.fast-jar b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.fast-jar index a5273b13c1fc7..208d90482c169 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.fast-jar +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.fast-jar @@ -21,10 +21,10 @@ # docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/{project.artifact-id}-jvm # ### -FROM registry.access.redhat.com/ubi8/ubi-minimal:8.1 +FROM {dockerfile.fast-jar.from} -ARG JAVA_PACKAGE=java-11-openjdk-headless -ARG RUN_JAVA_VERSION=1.3.8 +ARG JAVA_PACKAGE={dockerfile.fast-jar.java-package} +ARG RUN_JAVA_VERSION={dockerfile.fast-jar.run-java-version} ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.jvm b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.jvm index 1ad005cd38df3..9f28042985ebd 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.jvm +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.jvm @@ -21,10 +21,10 @@ # docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/{project.artifact-id}-jvm # ### -FROM registry.access.redhat.com/ubi8/ubi-minimal:8.1 +FROM {dockerfile.jvm.from} -ARG JAVA_PACKAGE=java-11-openjdk-headless -ARG RUN_JAVA_VERSION=1.3.8 +ARG JAVA_PACKAGE={dockerfile.jvm.java-package} +ARG RUN_JAVA_VERSION={dockerfile.jvm.run-java-version} ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.native b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.native index c3b2f05c0df75..f129944a89739 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.native +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.native @@ -14,7 +14,7 @@ # docker run -i --rm -p 8080:8080 quarkus/{project.artifact-id} # ### -FROM registry.access.redhat.com/ubi8/ubi-minimal:8.1 +FROM {dockerfile.native.from} WORKDIR /work/ RUN chown 1001 /work \ && chmod "g+rwX" /work \ diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/tooling/dockerfiles/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/tooling/dockerfiles/codestart.yml index a44cb0c37183c..bc6fc87e03fa9 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/tooling/dockerfiles/codestart.yml +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/tooling/dockerfiles/codestart.yml @@ -2,3 +2,17 @@ name: dockerfiles type: tooling preselected: true +language: + base: + data: + dockerfile: + jvm: + from: registry.access.redhat.com/ubi8/ubi-minimal:8.1 + java-package: java-11-openjdk-headless + run-java-version: 1.3.8 + fast-jar: + from: registry.access.redhat.com/ubi8/ubi-minimal:8.1 + java-package: java-11-openjdk-headless + run-java-version: 1.3.8 + native: + from: registry.access.redhat.com/ubi8/ubi-minimal:8.1 diff --git a/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/java/gradle.properties-template.ftl b/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/java/gradle.properties-template.ftl index ae1d466f986bb..c89e173e9ad97 100644 --- a/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/java/gradle.properties-template.ftl +++ b/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/java/gradle.properties-template.ftl @@ -1,5 +1,5 @@ quarkusPlatformGroupId = ${bom_groupId} quarkusPlatformArtifactId = ${bom_artifactId} quarkusPlatformVersion = ${bom_version} -quarkusPluginVersion = ${plugin_version} +quarkusPluginVersion = ${gradle_plugin_version} org.gradle.logging.level=INFO diff --git a/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/java/pom.xml-template.ftl b/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/java/pom.xml-template.ftl index c3849780721b1..de6642bb65244 100644 --- a/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/java/pom.xml-template.ftl +++ b/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/java/pom.xml-template.ftl @@ -15,7 +15,7 @@ ${bom_artifactId} ${bom_groupId} ${bom_version} - ${plugin_version} + ${maven_plugin_version} ${compiler_plugin_version} ${surefire_plugin_version} @@ -55,8 +55,8 @@ - ${plugin_groupId} - ${plugin_artifactId} + ${maven_plugin_groupId} + ${maven_plugin_artifactId} ${quarkus-plugin.version} diff --git a/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/java/settings.gradle-template.ftl b/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/java/settings.gradle-template.ftl index 6687873c9483b..61fd4debce633 100644 --- a/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/java/settings.gradle-template.ftl +++ b/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/java/settings.gradle-template.ftl @@ -1,8 +1,8 @@ pluginManagement { repositories { - mavenLocal()${maven_plugin_repositories} + mavenLocal() mavenCentral() - gradlePluginPortal() + gradlePluginPortal()${maven_plugin_repositories} } plugins { id 'io.quarkus' version "${quarkusPluginVersion}" diff --git a/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/kotlin/gradle.properties-template.ftl b/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/kotlin/gradle.properties-template.ftl index ae1d466f986bb..c89e173e9ad97 100644 --- a/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/kotlin/gradle.properties-template.ftl +++ b/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/kotlin/gradle.properties-template.ftl @@ -1,5 +1,5 @@ quarkusPlatformGroupId = ${bom_groupId} quarkusPlatformArtifactId = ${bom_artifactId} quarkusPlatformVersion = ${bom_version} -quarkusPluginVersion = ${plugin_version} +quarkusPluginVersion = ${gradle_plugin_version} org.gradle.logging.level=INFO diff --git a/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/kotlin/pom.xml-template.ftl b/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/kotlin/pom.xml-template.ftl index ad1fde119c327..b043e0dd58943 100644 --- a/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/kotlin/pom.xml-template.ftl +++ b/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/kotlin/pom.xml-template.ftl @@ -15,7 +15,7 @@ ${bom_artifactId} ${bom_groupId} ${bom_version} - ${plugin_version} + ${maven_plugin_version} ${compiler_plugin_version} ${surefire_plugin_version} ${kotlin_version} @@ -62,8 +62,8 @@ src/test/kotlin - ${plugin_groupId} - ${plugin_artifactId} + ${maven_plugin_groupId} + ${maven_plugin_artifactId} ${quarkus-plugin.version} diff --git a/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/kotlin/settings.gradle-template.ftl b/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/kotlin/settings.gradle-template.ftl index 6687873c9483b..61fd4debce633 100644 --- a/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/kotlin/settings.gradle-template.ftl +++ b/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/kotlin/settings.gradle-template.ftl @@ -1,8 +1,8 @@ pluginManagement { repositories { - mavenLocal()${maven_plugin_repositories} + mavenLocal() mavenCentral() - gradlePluginPortal() + gradlePluginPortal()${maven_plugin_repositories} } plugins { id 'io.quarkus' version "${quarkusPluginVersion}" diff --git a/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/scala/gradle.properties-template.ftl b/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/scala/gradle.properties-template.ftl index ae1d466f986bb..c89e173e9ad97 100644 --- a/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/scala/gradle.properties-template.ftl +++ b/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/scala/gradle.properties-template.ftl @@ -1,5 +1,5 @@ quarkusPlatformGroupId = ${bom_groupId} quarkusPlatformArtifactId = ${bom_artifactId} quarkusPlatformVersion = ${bom_version} -quarkusPluginVersion = ${plugin_version} +quarkusPluginVersion = ${gradle_plugin_version} org.gradle.logging.level=INFO diff --git a/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/scala/pom.xml-template.ftl b/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/scala/pom.xml-template.ftl index da626352a5410..37adb835f8b3d 100644 --- a/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/scala/pom.xml-template.ftl +++ b/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/scala/pom.xml-template.ftl @@ -15,7 +15,7 @@ ${bom_artifactId} ${bom_groupId} ${bom_version} - ${plugin_version} + ${maven_plugin_version} ${compiler_plugin_version} ${surefire_plugin_version} ${scala_version} @@ -68,8 +68,8 @@ src/test/scala - ${plugin_groupId} - ${plugin_artifactId} + ${maven_plugin_groupId} + ${maven_plugin_artifactId} ${quarkus-plugin.version} diff --git a/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/scala/settings.gradle-template.ftl b/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/scala/settings.gradle-template.ftl index 6687873c9483b..61fd4debce633 100644 --- a/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/scala/settings.gradle-template.ftl +++ b/devtools/platform-descriptor-json/src/main/resources/templates/basic-rest/scala/settings.gradle-template.ftl @@ -1,8 +1,8 @@ pluginManagement { repositories { - mavenLocal()${maven_plugin_repositories} + mavenLocal() mavenCentral() - gradlePluginPortal() + gradlePluginPortal()${maven_plugin_repositories} } plugins { id 'io.quarkus' version "${quarkusPluginVersion}" diff --git a/devtools/platform-descriptor-json/src/test/resources/fakeextensions.json b/devtools/platform-descriptor-json/src/test/resources/fakeextensions.json index 091a767d3c360..b8d4451868d60 100644 --- a/devtools/platform-descriptor-json/src/test/resources/fakeextensions.json +++ b/devtools/platform-descriptor-json/src/test/resources/fakeextensions.json @@ -6,20 +6,30 @@ "quarkus.native.builder-image" : "foo-bar" }, "maven" : { - "repositories" : { - "id": "redhat", - "url": "https://maven.repository.redhat.com" - }, - "plugin-repositories" : { - "id": "redhat", - "url": "https://maven.repository.redhat.com" - } + "repositories" : [ + { + "id": "redhat", + "url": "https://maven.repository.redhat.com", + "releases-enabled": "true", + "snapshots-enabled": "false" + } + ], + "plugin-repositories" : [ + { + "id": "redhat", + "url": "https://maven.repository.redhat.com", + "releases-enabled": "true", + "snapshots-enabled": "false" + } + ] }, "gradle" : { - "repositories" : { - "id": "redhat", - "url": "https://maven.repository.redhat.com" - } + "repositories" : [ + { + "id": "redhat", + "url": "https://maven.repository.redhat.com" + } + ] } }, "bom": { diff --git a/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/CodestartData.java b/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/CodestartData.java index 330e01fe3c145..b5900109299e1 100644 --- a/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/CodestartData.java +++ b/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/CodestartData.java @@ -7,6 +7,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -16,67 +17,8 @@ public final class CodestartData { private CodestartData() { } - public enum DataKey { - BOM_GROUP_ID("quarkus.platform.group-id"), - BOM_ARTIFACT_ID("quarkus.platform.artifact-id"), - BOM_VERSION("quarkus.platform.version"), - PROJECT_GROUP_ID("project.group-id"), - PROJECT_ARTIFACT_ID("project.artifact-id"), - PROJECT_VERSION("project.version"), - QUARKUS_PLUGIN_GROUP_ID("quarkus.plugin.group-id"), - QUARKUS_PLUGIN_ARTIFACT_ID("quarkus.plugin.artifact-id"), - QUARKUS_PLUGIN_VERSION("quarkus.plugin.version"), - QUARKUS_VERSION("quarkus.version"), - BUILDTOOL("buildtool.name"), - JAVA_VERSION("java.version"); - - private final String key; - - DataKey(String key) { - this.key = key; - } - - public String getKey() { - return key; - } - } - - public enum LegacySupport { - BOM_GROUP_ID("bom_groupId"), - BOM_ARTIFACT_ID("bom_artifactId"), - BOM_VERSION("bom_version"), - PROJECT_GROUP_ID("project_groupId"), - PROJECT_ARTIFACT_ID("project_artifactId"), - PROJECT_VERSION("project_version"), - QUARKUS_PLUGIN_GROUP_ID("plugin_groupId"), - QUARKUS_PLUGIN_ARTIFACT_ID("plugin_artifactId"), - QUARKUS_PLUGIN_VERSION("plugin_version"), - QUARKUS_VERSION("quarkus_version"), - JAVA_VERSION("java_target"); - - private final String legacyKey; - private final String key; - - LegacySupport(String legacyKey) { - this.key = DataKey.valueOf(this.name()).getKey(); - this.legacyKey = legacyKey; - } - - public String getKey() { - return key; - } - - public String getLegacyKey() { - return legacyKey; - } - - public static Map convertFromLegacy(Map legacy) { - return NestedMaps.unflatten(Stream.of(values()) - .filter(v -> v.getLegacyKey() != null) - .filter(v -> legacy.containsKey(v.getLegacyKey())) - .map(v -> new HashMap.SimpleImmutableEntry<>(v.getKey(), legacy.get(v.getLegacyKey()))) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))); - } + public static Optional getBuildtool(final Map data) { + return NestedMaps.getValue(data, "codestart-project.buildtool.name"); } static Map buildCodestartData(final Codestart codestart, final String languageName, diff --git a/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/Codestarts.java b/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/Codestarts.java index 8e5c659f347e4..da1be1c65fe20 100644 --- a/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/Codestarts.java +++ b/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/Codestarts.java @@ -1,6 +1,5 @@ package io.quarkus.devtools.codestarts; -import static io.quarkus.devtools.codestarts.CodestartData.DataKey.BUILDTOOL; import static io.quarkus.devtools.codestarts.CodestartLoader.loadAllCodestarts; import static io.quarkus.devtools.codestarts.CodestartProcessor.buildStrategies; import static io.quarkus.devtools.codestarts.CodestartSpec.Type.LANGUAGE; @@ -10,10 +9,9 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Objects; -import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -21,11 +19,7 @@ public class Codestarts { public static CodestartProject prepareProject(final CodestartInput input) throws IOException { - final Optional buildtool = NestedMaps.getValue(input.getData(), BUILDTOOL.getKey()); - final Set selectedCodestartNames = Stream.concat( - input.getCodestarts().stream(), - Stream.of(buildtool.orElse(null)).filter(Objects::nonNull)) - .collect(Collectors.toSet()); + final Set selectedCodestartNames = new HashSet<>(input.getCodestarts()); final List allCodestarts = loadAllCodestarts(input); diff --git a/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/strategy/SmartPomMergeCodestartFileStrategyHandler.java b/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/strategy/SmartPomMergeCodestartFileStrategyHandler.java index 08540357505f1..48cdae83697e6 100644 --- a/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/strategy/SmartPomMergeCodestartFileStrategyHandler.java +++ b/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/strategy/SmartPomMergeCodestartFileStrategyHandler.java @@ -2,8 +2,8 @@ import io.fabric8.maven.Maven; import io.fabric8.maven.merge.SmartModelMerger; +import io.quarkus.devtools.codestarts.CodestartData; import io.quarkus.devtools.codestarts.CodestartDefinitionException; -import io.quarkus.devtools.codestarts.NestedMaps; import io.quarkus.devtools.codestarts.reader.CodestartFile; import java.io.IOException; import java.io.StringReader; @@ -27,7 +27,7 @@ public void process(Path targetDirectory, String relativePath, List getValue(data, "codestart-project.buildtool.name") + CodestartData.getBuildtool(data) .filter(b -> Objects.equals(b, "maven")) .orElseThrow(() -> new CodestartDefinitionException( "something is wrong, smart-pom-merge file strategy must only be used on maven projects")); diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/QuarkusCodestartData.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/QuarkusCodestartData.java new file mode 100644 index 0000000000000..6684cad45f859 --- /dev/null +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/QuarkusCodestartData.java @@ -0,0 +1,79 @@ +package io.quarkus.devtools.codestarts; + +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public final class QuarkusCodestartData { + + private QuarkusCodestartData() { + } + + public enum DataKey { + BOM_GROUP_ID("quarkus.platform.group-id"), + BOM_ARTIFACT_ID("quarkus.platform.artifact-id"), + BOM_VERSION("quarkus.platform.version"), + PROJECT_GROUP_ID("project.group-id"), + PROJECT_ARTIFACT_ID("project.artifact-id"), + PROJECT_VERSION("project.version"), + QUARKUS_MAVEN_PLUGIN_GROUP_ID("quarkus.maven-plugin.group-id"), + QUARKUS_MAVEN_PLUGIN_ARTIFACT_ID("quarkus.maven-plugin.artifact-id"), + QUARKUS_MAVEN_PLUGIN_VERSION("quarkus.maven-plugin.version"), + QUARKUS_GRADLE_PLUGIN_ID("quarkus.gradle-plugin.id"), + QUARKUS_GRADLE_PLUGIN_VERSION("quarkus.gradle-plugin.version"), + QUARKUS_VERSION("quarkus.version"), + JAVA_VERSION("java.version"), + ; + + private final String key; + + DataKey(String key) { + this.key = key; + } + + public String getKey() { + return key; + } + } + + public enum LegacySupport { + BOM_GROUP_ID("bom_groupId"), + BOM_ARTIFACT_ID("bom_artifactId"), + BOM_VERSION("bom_version"), + PROJECT_GROUP_ID("project_groupId"), + PROJECT_ARTIFACT_ID("project_artifactId"), + PROJECT_VERSION("project_version"), + QUARKUS_MAVEN_PLUGIN_GROUP_ID("maven_plugin_groupId"), + QUARKUS_MAVEN_PLUGIN_ARTIFACT_ID("maven_plugin_artifactId"), + QUARKUS_MAVEN_PLUGIN_VERSION("maven_plugin_version"), + QUARKUS_GRADLE_PLUGIN_ID("gradle_plugin_id"), + QUARKUS_GRADLE_PLUGIN_VERSION("gradle_plugin_version"), + QUARKUS_VERSION("quarkus_version"), + JAVA_VERSION("java_target"); + + private final String legacyKey; + private final String key; + + LegacySupport(String legacyKey) { + this.key = DataKey.valueOf(this.name()).getKey(); + this.legacyKey = legacyKey; + } + + public String getKey() { + return key; + } + + public String getLegacyKey() { + return legacyKey; + } + + public static Map convertFromLegacy(Map legacy) { + return NestedMaps.unflatten(Stream.of(values()) + .filter(v -> v.getLegacyKey() != null) + .filter(v -> legacy.containsKey(v.getLegacyKey())) + .map(v -> new HashMap.SimpleImmutableEntry<>(v.getKey(), legacy.get(v.getLegacyKey()))) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))); + } + } +} 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 cc0e83fc5aefb..50c26b46eb9bc 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 @@ -1,14 +1,6 @@ package io.quarkus.devtools.commands; -import static io.quarkus.devtools.project.codegen.ProjectGenerator.CLASS_NAME; -import static io.quarkus.devtools.project.codegen.ProjectGenerator.EXTENSIONS; -import static io.quarkus.devtools.project.codegen.ProjectGenerator.IS_SPRING; -import static io.quarkus.devtools.project.codegen.ProjectGenerator.JAVA_TARGET; -import static io.quarkus.devtools.project.codegen.ProjectGenerator.PROJECT_ARTIFACT_ID; -import static io.quarkus.devtools.project.codegen.ProjectGenerator.PROJECT_GROUP_ID; -import static io.quarkus.devtools.project.codegen.ProjectGenerator.PROJECT_VERSION; -import static io.quarkus.devtools.project.codegen.ProjectGenerator.QUARKUS_PLUGIN_VERSION; -import static io.quarkus.devtools.project.codegen.ProjectGenerator.SOURCE_TYPE; +import static io.quarkus.devtools.project.codegen.ProjectGenerator.*; import static java.util.Objects.requireNonNull; import io.quarkus.devtools.commands.data.QuarkusCommandException; @@ -67,8 +59,13 @@ public CreateProject version(String version) { return this; } - public CreateProject quarkusPluginVersion(String version) { - setValue(QUARKUS_PLUGIN_VERSION, version); + public CreateProject quarkusMavenPluginVersion(String version) { + setValue(QUARKUS_MAVEN_PLUGIN_VERSION, version); + return this; + } + + public CreateProject quarkusGradlePluginVersion(String version) { + setValue(QUARKUS_GRADLE_PLUGIN_VERSION, version); return this; } 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 17ffde09d9b23..3d935ae6c4c05 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 @@ -6,11 +6,12 @@ import io.quarkus.bootstrap.model.AppArtifactCoords; import io.quarkus.bootstrap.model.AppArtifactKey; import io.quarkus.devtools.codestarts.Codestart; -import io.quarkus.devtools.codestarts.CodestartData; import io.quarkus.devtools.codestarts.CodestartInput; import io.quarkus.devtools.codestarts.CodestartProject; import io.quarkus.devtools.codestarts.CodestartSpec; import io.quarkus.devtools.codestarts.Codestarts; +import io.quarkus.devtools.codestarts.NestedMaps; +import io.quarkus.devtools.codestarts.QuarkusCodestartData.LegacySupport; import io.quarkus.devtools.codestarts.QuarkusCodestarts; import io.quarkus.devtools.commands.data.QuarkusCommandException; import io.quarkus.devtools.commands.data.QuarkusCommandInvocation; @@ -28,7 +29,10 @@ import io.quarkus.platform.tools.ToolsUtils; import java.io.IOException; import java.util.Collections; +import java.util.HashMap; 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; @@ -62,11 +66,18 @@ public QuarkusCommandOutcome execute(QuarkusCommandInvocation invocation) throws .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 CodestartInput input = QuarkusCodestarts.inputBuilder(platformDescr) .addExtensions(extensionsToAdd) - .addData(CodestartData.LegacySupport.convertFromLegacy(invocation.getValues())) - .putData(CodestartData.DataKey.BUILDTOOL.getKey(), - invocation.getQuarkusProject().getBuildTool().toString().toLowerCase().replace("_", "-")) + .addCodestart(invocation.getQuarkusProject().getBuildTool().getKey()) + .addData(platformData) + .addData(LegacySupport.convertFromLegacy(invocation.getValues())) .includeExamples(invocation.getValue("codestarts.with-example-code", true)) .build(); invocation.log().info("Generating Quarkus Codestart Project with data: " + input.getData().toString()); @@ -81,6 +92,8 @@ public QuarkusCommandOutcome execute(QuarkusCommandInvocation invocation) throws return QuarkusCommandOutcome.success(); } + addPlatformDataToLegacyCodegen(invocation); + try { String className = invocation.getStringValue(CLASS_NAME); if (className != null) { @@ -135,4 +148,91 @@ public QuarkusCommandOutcome execute(QuarkusCommandInvocation invocation) throws } 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/BuildTool.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/BuildTool.java index fd45b6642c4b5..fb59fa39d4421 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/BuildTool.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/BuildTool.java @@ -71,18 +71,20 @@ public ExtensionManager createExtensionManager(final Path projectDirPath, } } + public String getKey() { + return toString().toLowerCase().replace("_", "-"); + } + public static BuildTool resolveExistingProject(Path path) { return QuarkusProject.resolveExistingProjectBuildTool(path); } public static BuildTool findTool(String tool) { - if ("GRADLE".equalsIgnoreCase(tool)) - return GRADLE; - else if ("GRADLE_KOTLIN_DSL".equalsIgnoreCase(tool) || "gradle-kotlin-dsl".equalsIgnoreCase(tool)) - return GRADLE_KOTLIN_DSL; - else if ("MAVEN".equalsIgnoreCase(tool)) - return MAVEN; - else - return null; + for (BuildTool value : BuildTool.values()) { + if (value.toString().equalsIgnoreCase(tool) || value.getKey().equalsIgnoreCase(tool)) { + return value; + } + } + return null; } } diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/AbstractGradleBuildFilesCreator.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/AbstractGradleBuildFilesCreator.java index d9d0c6faee1f6..1e0da5432ab95 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/AbstractGradleBuildFilesCreator.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/AbstractGradleBuildFilesCreator.java @@ -125,7 +125,8 @@ private void createProperties() throws IOException { final QuarkusPlatformDescriptor platform = quarkusProject.getPlatformDescriptor(); Properties props = getModel().getPropertiesContent(); if (props.getProperty("quarkusPluginVersion") == null) { - props.setProperty("quarkusPluginVersion", ToolsUtils.getPluginVersion(ToolsUtils.readQuarkusProperties(platform))); + props.setProperty("quarkusPluginVersion", + ToolsUtils.getGradlePluginVersion(ToolsUtils.readQuarkusProperties(platform))); } if (props.getProperty("quarkusPlatformGroupId") == null) { props.setProperty("quarkusPlatformGroupId", platform.getBomGroupId()); diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/codegen/ProjectGenerator.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/codegen/ProjectGenerator.java index ee7c7c28fcf7b..49642d72f87a4 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/codegen/ProjectGenerator.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/codegen/ProjectGenerator.java @@ -10,7 +10,8 @@ public interface ProjectGenerator { String PROJECT_GROUP_ID = "project_groupId"; String PROJECT_ARTIFACT_ID = "project_artifactId"; String PROJECT_VERSION = "project_version"; - String QUARKUS_PLUGIN_VERSION = "plugin_version"; + String QUARKUS_MAVEN_PLUGIN_VERSION = "maven_plugin_version"; + String QUARKUS_GRADLE_PLUGIN_VERSION = "gradle_plugin_version"; String QUARKUS_VERSION = "quarkus_version"; String PACKAGE_NAME = "package_name"; String MAVEN_REPOSITORIES = "maven_repositories"; diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/tools/ToolsConstants.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/tools/ToolsConstants.java index 9f23b61615aa1..69b87d5b72bf9 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/tools/ToolsConstants.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/tools/ToolsConstants.java @@ -13,9 +13,14 @@ public interface ToolsConstants { String DEFAULT_PLATFORM_BOM_GROUP_ID = IO_QUARKUS; String DEFAULT_PLATFORM_BOM_ARTIFACT_ID = "quarkus-universe-bom"; - String PROP_QUARKUS_PLUGIN_GROUP_ID = "plugin-groupId"; - String PROP_QUARKUS_PLUGIN_ARTIFACT_ID = "plugin-artifactId"; - String PROP_QUARKUS_PLUGIN_VERSION = "plugin-version"; + String PROP_QUARKUS_CORE_VERSION = "quarkus-core-version"; + + String PROP_QUARKUS_MAVEN_PLUGIN_GROUP_ID = "maven-plugin-groupId"; + String PROP_QUARKUS_MAVEN_PLUGIN_ARTIFACT_ID = "maven-plugin-artifactId"; + String PROP_QUARKUS_MAVEN_PLUGIN_VERSION = "maven-plugin-version"; + + String PROP_QUARKUS_GRADLE_PLUGIN_ID = "gradle-plugin-id"; + String PROP_QUARKUS_GRADLE_PLUGIN_VERSION = "gradle-plugin-version"; String PROP_PROPOSED_MVN_VERSION = "proposed-maven-version"; String PROP_MVN_WRAPPER_VERSION = "maven-wrapper-version"; diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/tools/ToolsUtils.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/tools/ToolsUtils.java index 5d55e32a79e2d..8019a26f62db3 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/tools/ToolsUtils.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/tools/ToolsUtils.java @@ -14,6 +14,7 @@ public static String requireProperty(String name) { return value; } + public static String getProperty(String name) { return getProperty(name, null); } @@ -56,20 +57,40 @@ public static Properties readQuarkusProperties(QuarkusPlatformDescriptor platfor return properties; } - public static String getPluginArtifactId(Properties props) { - return props.getProperty(ToolsConstants.PROP_QUARKUS_PLUGIN_ARTIFACT_ID); + public static String requireProperty(Properties props, String name) { + final String value = props.getProperty(name); + if (value == null) { + throw new IllegalStateException("Failed to resolve required property " + name); + } + return value; + } + + public static String getMavenPluginArtifactId(Properties props) { + return props.getProperty(ToolsConstants.PROP_QUARKUS_MAVEN_PLUGIN_ARTIFACT_ID); + } + + public static String getMavenPluginGroupId(Properties props) { + return props.getProperty(ToolsConstants.PROP_QUARKUS_MAVEN_PLUGIN_GROUP_ID); + } + + public static String getQuarkusCoreVersion(Properties props) { + return props.getProperty(ToolsConstants.PROP_QUARKUS_CORE_VERSION); + } + + public static String requireQuarkusCoreVersion(Properties props) { + return requireProperty(props, ToolsConstants.PROP_QUARKUS_CORE_VERSION); } - public static String getPluginGroupId(Properties props) { - return props.getProperty(ToolsConstants.PROP_QUARKUS_PLUGIN_GROUP_ID); + public static String getMavenPluginVersion(Properties props) { + return props.getProperty(ToolsConstants.PROP_QUARKUS_MAVEN_PLUGIN_VERSION); } - public static String getPluginVersion(Properties props) { - return props.getProperty(ToolsConstants.PROP_QUARKUS_PLUGIN_VERSION); + public static String getGradlePluginVersion(Properties props) { + return props.getProperty(ToolsConstants.PROP_QUARKUS_GRADLE_PLUGIN_VERSION); } public static String getPluginKey(Properties props) { - return getPluginGroupId(props) + ":" + getPluginArtifactId(props); + return getMavenPluginGroupId(props) + ":" + getMavenPluginArtifactId(props); } public static String getProposedMavenVersion(Properties props) { diff --git a/independent-projects/tools/devtools-common/src/test/filtered/quarkus.properties b/independent-projects/tools/devtools-common/src/test/filtered/quarkus.properties index 75b90715a75f6..2c025575f5827 100644 --- a/independent-projects/tools/devtools-common/src/test/filtered/quarkus.properties +++ b/independent-projects/tools/devtools-common/src/test/filtered/quarkus.properties @@ -8,10 +8,16 @@ kotlin-version=${kotlin.version} scala-version=${scala.version} scala-plugin-version=${scala-plugin.version} -# Plugin metadata -plugin-groupId=${project.groupId} -plugin-artifactId=quarkus-maven-plugin -plugin-version=${project.version} +quarkus-core-version=${project.version} + +# Maven plugin metadata +maven-plugin-groupId=${project.groupId} +maven-plugin-artifactId=quarkus-maven-plugin +maven-plugin-version=${project.version} + +# Gradle plugin metadata +gradle-plugin-id=io.quarkus +gradle-plugin-version=${project.version} supported-maven-versions=${supported-maven-versions} # the proposed version must be in the range of the supported versions diff --git a/independent-projects/tools/devtools-common/src/test/java/io/quarkus/test/platform/descriptor/PlatformAwareTestBase.java b/independent-projects/tools/devtools-common/src/test/java/io/quarkus/test/platform/descriptor/PlatformAwareTestBase.java index c04f0fc5539a2..0cf687fef9304 100644 --- a/independent-projects/tools/devtools-common/src/test/java/io/quarkus/test/platform/descriptor/PlatformAwareTestBase.java +++ b/independent-projects/tools/devtools-common/src/test/java/io/quarkus/test/platform/descriptor/PlatformAwareTestBase.java @@ -2,50 +2,16 @@ import io.quarkus.platform.descriptor.QuarkusPlatformDescriptor; import io.quarkus.platform.tools.config.QuarkusPlatformConfig; -import java.io.IOException; -import java.util.Properties; public class PlatformAwareTestBase { private QuarkusPlatformDescriptor platformDescr; - private Properties quarkusProps; - private String pluginGroupId; - private String pluginArtifactId; - private String pluginVersion; protected QuarkusPlatformDescriptor getPlatformDescriptor() { return platformDescr == null ? platformDescr = QuarkusPlatformConfig.builder().build().getPlatformDescriptor() : platformDescr; } - private Properties getQuarkusProperties() { - if (quarkusProps == null) { - try { - quarkusProps = getPlatformDescriptor().loadResource("quarkus.properties", is -> { - final Properties props = new Properties(); - props.load(is); - return props; - }); - } catch (IOException e) { - throw new IllegalStateException("Failed to load quarkus.properties", e); - } - } - return quarkusProps; - } - - protected String getPluginGroupId() { - return pluginGroupId == null ? pluginGroupId = getQuarkusProperties().getProperty("plugin-groupId") : pluginGroupId; - } - - protected String getPluginArtifactId() { - return pluginArtifactId == null ? pluginArtifactId = getQuarkusProperties().getProperty("plugin-artifactId") - : pluginArtifactId; - } - - protected String getPluginVersion() { - return pluginVersion == null ? pluginVersion = getQuarkusProperties().getProperty("plugin-version") : pluginVersion; - } - protected String getBomGroupId() { return getPlatformDescriptor().getBomGroupId(); } diff --git a/independent-projects/tools/devtools-common/src/test/java/io/quarkus/test/platform/descriptor/loader/QuarkusTestPlatformDescriptorLoader.java b/independent-projects/tools/devtools-common/src/test/java/io/quarkus/test/platform/descriptor/loader/QuarkusTestPlatformDescriptorLoader.java index 8aa9b4676675b..ae1624ef608a0 100644 --- a/independent-projects/tools/devtools-common/src/test/java/io/quarkus/test/platform/descriptor/loader/QuarkusTestPlatformDescriptorLoader.java +++ b/independent-projects/tools/devtools-common/src/test/java/io/quarkus/test/platform/descriptor/loader/QuarkusTestPlatformDescriptorLoader.java @@ -9,6 +9,7 @@ import io.quarkus.platform.descriptor.loader.QuarkusPlatformDescriptorLoader; import io.quarkus.platform.descriptor.loader.QuarkusPlatformDescriptorLoaderContext; import io.quarkus.platform.descriptor.loader.json.ResourceLoaders; +import io.quarkus.platform.tools.ToolsConstants; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; @@ -143,9 +144,10 @@ public void setVersion(String version) { } catch (IOException e) { throw new IllegalStateException("Failed to load quarkus.properties", e); } - quarkusVersion = quarkusProps.getProperty("plugin-version"); + quarkusVersion = quarkusProps.getProperty(ToolsConstants.PROP_QUARKUS_CORE_VERSION); if (quarkusVersion == null) { - throw new IllegalStateException("plugin-version property is missing from quarkus.properties"); + throw new IllegalStateException( + ToolsConstants.PROP_QUARKUS_CORE_VERSION + " property is missing from quarkus.properties"); } addCategories(); diff --git a/independent-projects/tools/platform-descriptor-resolver-json/src/main/java/io/quarkus/platform/descriptor/resolver/json/QuarkusJsonPlatformDescriptorResolver.java b/independent-projects/tools/platform-descriptor-resolver-json/src/main/java/io/quarkus/platform/descriptor/resolver/json/QuarkusJsonPlatformDescriptorResolver.java index 75ea6527ce5ef..7bf003fcec907 100644 --- a/independent-projects/tools/platform-descriptor-resolver-json/src/main/java/io/quarkus/platform/descriptor/resolver/json/QuarkusJsonPlatformDescriptorResolver.java +++ b/independent-projects/tools/platform-descriptor-resolver-json/src/main/java/io/quarkus/platform/descriptor/resolver/json/QuarkusJsonPlatformDescriptorResolver.java @@ -711,12 +711,7 @@ private static String getBundledPlatformQuarkusVersionOrNull() { } catch (IOException e) { throw new IllegalStateException("Failed to load quarkus.properties from the classpath", e); } - final String quarkusVersion = props.getProperty("plugin-version"); - if (quarkusVersion == null) { - throw new IllegalStateException( - "quarkus.properties loaded from the classpath is missing plugin-version property"); - } - return quarkusVersion; + return ToolsUtils.requireQuarkusCoreVersion(props); } private static InputStream getCpResourceAsStream(String name) { diff --git a/independent-projects/tools/platform-descriptor-resolver-json/src/test/resources/quarkus.properties b/independent-projects/tools/platform-descriptor-resolver-json/src/test/resources/quarkus.properties index cf81a1ccd6879..9cb4e05a1c5bd 100644 --- a/independent-projects/tools/platform-descriptor-resolver-json/src/test/resources/quarkus.properties +++ b/independent-projects/tools/platform-descriptor-resolver-json/src/test/resources/quarkus.properties @@ -1 +1 @@ -plugin-version = 1.0.0.CR90 \ No newline at end of file +quarkus-core-version = 1.0.0.CR90 \ No newline at end of file diff --git a/integration-tests/devtools/src/test/java/io/quarkus/devtools/PlatformAwareTestBase.java b/integration-tests/devtools/src/test/java/io/quarkus/devtools/PlatformAwareTestBase.java index cf374e267bde1..60c229fab484c 100644 --- a/integration-tests/devtools/src/test/java/io/quarkus/devtools/PlatformAwareTestBase.java +++ b/integration-tests/devtools/src/test/java/io/quarkus/devtools/PlatformAwareTestBase.java @@ -1,18 +1,15 @@ package io.quarkus.devtools; -import java.io.IOException; import java.util.Properties; import io.quarkus.platform.descriptor.QuarkusPlatformDescriptor; import io.quarkus.platform.descriptor.resolver.json.QuarkusJsonPlatformDescriptorResolver; +import io.quarkus.platform.tools.ToolsUtils; public class PlatformAwareTestBase { private QuarkusPlatformDescriptor platformDescr; private Properties quarkusProps; - private String pluginGroupId; - private String pluginArtifactId; - private String pluginVersion; protected QuarkusPlatformDescriptor getPlatformDescriptor() { return platformDescr == null @@ -22,30 +19,25 @@ protected QuarkusPlatformDescriptor getPlatformDescriptor() { private Properties getQuarkusProperties() { if (quarkusProps == null) { - try { - quarkusProps = getPlatformDescriptor().loadResource("quarkus.properties", is -> { - final Properties props = new Properties(); - props.load(is); - return props; - }); - } catch (IOException e) { - throw new IllegalStateException("Failed to load quarkus.properties", e); - } + quarkusProps = ToolsUtils.readQuarkusProperties(getPlatformDescriptor()); } return quarkusProps; } - protected String getPluginGroupId() { - return pluginGroupId == null ? pluginGroupId = getQuarkusProperties().getProperty("plugin-groupId") : pluginGroupId; + protected String getMavenPluginGroupId() { + return ToolsUtils.getMavenPluginGroupId(getQuarkusProperties()); } - protected String getPluginArtifactId() { - return pluginArtifactId == null ? pluginArtifactId = getQuarkusProperties().getProperty("plugin-artifactId") - : pluginArtifactId; + protected String getMavenPluginArtifactId() { + return ToolsUtils.getMavenPluginArtifactId(getQuarkusProperties()); } - protected String getPluginVersion() { - return pluginVersion == null ? pluginVersion = getQuarkusProperties().getProperty("plugin-version") : pluginVersion; + protected String getMavenPluginVersion() { + return ToolsUtils.getMavenPluginVersion(getQuarkusProperties()); + } + + protected String getQuarkusCoreVersion() { + return ToolsUtils.getQuarkusCoreVersion(getQuarkusProperties()); } protected String getBomGroupId() { diff --git a/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/CodestartProjectGenerationTest.java b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/CodestartProjectGenerationTest.java index 18fb26d7662c0..f45726f42db39 100644 --- a/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/CodestartProjectGenerationTest.java +++ b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/CodestartProjectGenerationTest.java @@ -1,5 +1,6 @@ package io.quarkus.devtools.codestarts; +import static io.quarkus.devtools.codestarts.QuarkusCodestartData.DataKey.*; import static io.quarkus.devtools.codestarts.QuarkusCodestarts.inputBuilder; import static org.assertj.core.api.Assertions.assertThat; @@ -40,17 +41,19 @@ private Map getTestInputData(final Map override) static Map getTestInputData(final QuarkusPlatformDescriptor descriptor, final Map override) { final HashMap data = new HashMap<>(); - data.put("project.group-id", "org.test"); - data.put("project.artifact-id", "test-codestart"); - data.put("project.version", "1.0.0-codestart"); - data.put("quarkus.platform.group-id", descriptor.getBomGroupId()); - data.put("quarkus.platform.artifact-id", descriptor.getBomArtifactId()); - data.put("quarkus.platform.version", descriptor.getBomVersion()); - data.put("quarkus.version", descriptor.getQuarkusVersion()); - data.put("quarkus.plugin.group-id", "io.quarkus"); - data.put("quarkus.plugin.artifact-id", "quarkus-maven-plugin"); - data.put("quarkus.plugin.version", descriptor.getQuarkusVersion()); - data.put("java.version", "11"); + data.put(PROJECT_GROUP_ID.getKey(), "org.test"); + data.put(PROJECT_ARTIFACT_ID.getKey(), "test-codestart"); + data.put(PROJECT_VERSION.getKey(), "1.0.0-codestart"); + data.put(BOM_GROUP_ID.getKey(), descriptor.getBomGroupId()); + data.put(BOM_ARTIFACT_ID.getKey(), descriptor.getBomArtifactId()); + data.put(BOM_VERSION.getKey(), descriptor.getBomVersion()); + data.put(QUARKUS_VERSION.getKey(), descriptor.getQuarkusVersion()); + data.put(QUARKUS_MAVEN_PLUGIN_GROUP_ID.getKey(), "io.quarkus"); + data.put(QUARKUS_MAVEN_PLUGIN_ARTIFACT_ID.getKey(), "quarkus-maven-plugin"); + data.put(QUARKUS_MAVEN_PLUGIN_VERSION.getKey(), descriptor.getQuarkusVersion()); + data.put(QUARKUS_GRADLE_PLUGIN_ID.getKey(), "io.quarkus"); + data.put(QUARKUS_GRADLE_PLUGIN_VERSION.getKey(), descriptor.getQuarkusVersion()); + data.put(JAVA_VERSION.getKey(), "11"); if (override != null) data.putAll(override); return data; @@ -152,9 +155,9 @@ void generateCodestartProjectMavenResteasyScala() throws IOException { void generateCodestartProjectGradleResteasyJava() throws IOException { final CodestartInput input = inputBuilder(getPlatformDescriptor()) .includeExamples() + .addCodestart("gradle") .addExtension(AppArtifactKey.fromString("io.quarkus:quarkus-resteasy")) .addData(getTestInputData()) - .putData("buildtool.name", "gradle") .build(); final CodestartProject codestartProject = Codestarts.prepareProject(input); final Path projectDir = testDirPath.resolve("gradle-resteasy-java"); @@ -174,7 +177,7 @@ void generateCodestartProjectGradleResteasyKotlin() throws IOException { .includeExamples() .addExtension(AppArtifactKey.fromString("io.quarkus:quarkus-resteasy")) .addExtension(AppArtifactKey.fromString("io.quarkus:quarkus-kotlin")) - .putData("buildtool.name", "gradle") + .addCodestart("gradle") .addData(getTestInputData()) .build(); final CodestartProject codestartProject = Codestarts.prepareProject(input); @@ -196,7 +199,7 @@ void generateCodestartProjectGradleResteasyScala() throws IOException { .addExtension(AppArtifactKey.fromString("io.quarkus:quarkus-resteasy")) .addExtension(AppArtifactKey.fromString("io.quarkus:quarkus-scala")) .addData(getTestInputData()) - .putData("buildtool.name", "gradle") + .addCodestart("gradle") .build(); final CodestartProject codestartProject = Codestarts.prepareProject(input); final Path projectDir = testDirPath.resolve("gradle-resteasy-scala"); @@ -216,7 +219,7 @@ void generateCodestartProjectGradleWithKotlinDslResteasyJava() throws IOExceptio .includeExamples() .addExtension(AppArtifactKey.fromString("io.quarkus:quarkus-resteasy")) .addData(getTestInputData()) - .putData("buildtool.name", "gradle-kotlin-dsl") + .addCodestart("gradle-kotlin-dsl") .build(); final CodestartProject codestartProject = Codestarts.prepareProject(input); final Path projectDir = testDirPath.resolve("gradle-kotlin-dsl-resteasy-java"); @@ -236,7 +239,7 @@ void generateCodestartProjectGradleWithKotlinDslResteasyKotlin() throws IOExcept .includeExamples() .addExtension(AppArtifactKey.fromString("io.quarkus:quarkus-resteasy")) .addExtension(AppArtifactKey.fromString("io.quarkus:quarkus-kotlin")) - .putData("buildtool.name", "gradle-kotlin-dsl") + .addCodestart("gradle-kotlin-dsl") .addData(getTestInputData()) .build(); final CodestartProject codestartProject = Codestarts.prepareProject(input); @@ -258,7 +261,7 @@ void generateCodestartProjectGradleWithKotlinDslResteasyScala() throws IOExcepti .addExtension(AppArtifactKey.fromString("io.quarkus:quarkus-resteasy")) .addExtension(AppArtifactKey.fromString("io.quarkus:quarkus-scala")) .addData(getTestInputData()) - .putData("buildtool.name", "gradle-kotlin-dsl") + .addCodestart("gradle-kotlin-dsl") .build(); final CodestartProject codestartProject = Codestarts.prepareProject(input); final Path projectDir = testDirPath.resolve("gradle-kotlin-dsl-resteasy-scala"); diff --git a/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/CodestartProjectRunTest.java b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/CodestartProjectRunTest.java index c9dc0bf3611c0..b13bd7daeae93 100644 --- a/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/CodestartProjectRunTest.java +++ b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/CodestartProjectRunTest.java @@ -78,6 +78,12 @@ public void generateGradleProjectRun(String language, List codestarts) t generateProjectRunTests("gradle", language, codestarts); } + @ParameterizedTest + @MethodSource("provideGenerateCombinations") + public void generateGradleKotlinProjectRun(String language, List codestarts) throws Exception { + generateProjectRunTests("gradle-kotlin-dsl", language, codestarts); + } + @Test public void generateAzureFunctionsHttpExampleProjectRun() throws Exception { generateProjectRunTests("maven", "java", Collections.singletonList("azure-functions-http-example")); @@ -94,7 +100,7 @@ private void generateProjectRunTests(String buildtool, String language, List getExtensionsWithArtifactContaining(String contains) { } private void hasDependency(T project, String artifactId) { - hasDependency(project, getPluginGroupId(), artifactId, null); + hasDependency(project, IO_QUARKUS, artifactId, null); } private void hasDependency(T project, String groupId, String artifactId, String version) { @@ -224,8 +225,8 @@ private void hasDependency(T project, String groupId, String artifactId, String } private void doesNotHaveDependency(T project, String artifactId) { - assertThat(countDependencyOccurrences(project, getPluginGroupId(), artifactId, null)) - .describedAs("Dependency %s:%s must not be in project", getPluginGroupId(), artifactId) + assertThat(countDependencyOccurrences(project, IO_QUARKUS, artifactId, null)) + .describedAs("Dependency %s:%s must not be in project", IO_QUARKUS, artifactId) .isZero(); } diff --git a/integration-tests/devtools/src/test/java/io/quarkus/devtools/commands/AbstractRemoveExtensionsTest.java b/integration-tests/devtools/src/test/java/io/quarkus/devtools/commands/AbstractRemoveExtensionsTest.java index 3f84445eb49fc..c330480f02b2c 100644 --- a/integration-tests/devtools/src/test/java/io/quarkus/devtools/commands/AbstractRemoveExtensionsTest.java +++ b/integration-tests/devtools/src/test/java/io/quarkus/devtools/commands/AbstractRemoveExtensionsTest.java @@ -1,5 +1,6 @@ package io.quarkus.devtools.commands; +import static io.quarkus.platform.tools.ToolsConstants.IO_QUARKUS; import static java.util.Arrays.asList; import java.io.IOException; @@ -90,7 +91,7 @@ void testRegexpMatches() throws Exception { } private void hasDependency(T project, String artifactId) { - hasDependency(project, getPluginGroupId(), artifactId, null); + hasDependency(project, IO_QUARKUS, artifactId, null); } private void hasDependency(T project, String groupId, String artifactId, String version) { @@ -98,7 +99,7 @@ private void hasDependency(T project, String groupId, String artifactId, String } private void hasNoDependency(T project, String artifactId) { - hasNoDependency(project, getPluginGroupId(), artifactId, null); + hasNoDependency(project, IO_QUARKUS, artifactId, null); } private void hasNoDependency(T project, String groupId, String artifactId, String version) { 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 new file mode 100644 index 0000000000000..dbf24cb357bca --- /dev/null +++ b/integration-tests/devtools/src/test/java/io/quarkus/devtools/commands/CreateProjectPlatformMetadataTest.java @@ -0,0 +1,96 @@ +package io.quarkus.devtools.commands; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.util.Map; +import java.util.function.Consumer; + +import org.assertj.core.util.Files; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.quarkus.devtools.PlatformAwareTestBase; +import io.quarkus.devtools.ProjectTestUtil; +import io.quarkus.devtools.commands.data.QuarkusCommandException; +import io.quarkus.devtools.commands.data.QuarkusCommandOutcome; +import io.quarkus.devtools.project.BuildTool; +import io.quarkus.platform.descriptor.QuarkusPlatformDescriptor; + +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 { + final File file = new File("target/meta-rest"); + ProjectTestUtil.delete(file); + createProject(BuildTool.MAVEN, file, "io.quarkus", "basic-rest", "1.0.0-SNAPSHOT", codestartsEnabled); + assertThat(file.toPath().resolve("pom.xml")) + .exists() + .satisfies(checkContains("redhat")) + .satisfies(checkContains("https://maven.repository.redhat.com")) + .satisfies(checkContains("")) + .satisfies(checkContains("")) + .satisfies(checkContains("")) + .satisfies(checkContains("")); + } + + @ParameterizedTest + @ValueSource(booleans = { true, false }) + public void createGradle(boolean codestartsEnabled) 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); + assertThat(file.toPath().resolve("build.gradle")) + .exists() + .satisfies(checkContains("maven { url \"https://maven.repository.redhat.com\" }")); + } + + @Test + 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); + assertThat(file.toPath().resolve("build.gradle.kts")) + .exists() + .satisfies(checkContains("maven { url = uri(\"https://maven.repository.redhat.com\") }")); + } + + private Consumer checkContains(String s) { + return (p) -> assertThat(Files.contentOf(p.toFile(), StandardCharsets.UTF_8)).contains(s); + } + + private Map getMetadata() throws java.io.IOException { + return JSON_MAPPER.reader().readValue(CreateProjectPlatformMetadataTest.class.getResource("/platform-metadata.json"), + Map.class); + } + + private void createProject(BuildTool buildTool, File file, String groupId, String artifactId, String version, + boolean codestartsEnabled) + throws QuarkusCommandException, IOException { + final QuarkusPlatformDescriptor platformDescriptor = getPlatformDescriptor(); + final QuarkusPlatformDescriptor spy = spy(platformDescriptor); + when(spy.getMetadata()).thenReturn(getMetadata()); + final QuarkusCommandOutcome result = new CreateProject(file.toPath(), spy) + .buildTool(buildTool) + .groupId(groupId) + .artifactId(artifactId) + .codestartsEnabled(codestartsEnabled) + .version(version) + .quarkusMavenPluginVersion("2.3.5") + .quarkusGradlePluginVersion("2.3.5-gradle") + .execute(); + assertTrue(result.isSuccess()); + } +} 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 cad083d7e5be7..90c09d8afbf1c 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 @@ -123,7 +123,8 @@ private void createProject(BuildTool buildTool, File file, String groupId, Strin .groupId(groupId) .artifactId(artifactId) .version(version) - .quarkusPluginVersion("2.3.5") + .quarkusMavenPluginVersion("2.3.5") + .quarkusGradlePluginVersion("2.3.5-gradle") .execute(); assertTrue(result.isSuccess()); } diff --git a/integration-tests/devtools/src/test/java/io/quarkus/devtools/commands/ListExtensionsTest.java b/integration-tests/devtools/src/test/java/io/quarkus/devtools/commands/ListExtensionsTest.java index f0392ff5c93a3..26ae669de8ab4 100644 --- a/integration-tests/devtools/src/test/java/io/quarkus/devtools/commands/ListExtensionsTest.java +++ b/integration-tests/devtools/src/test/java/io/quarkus/devtools/commands/ListExtensionsTest.java @@ -1,6 +1,7 @@ package io.quarkus.devtools.commands; import static io.quarkus.maven.utilities.MojoUtils.readPom; +import static io.quarkus.platform.tools.ToolsConstants.IO_QUARKUS; import static java.util.Arrays.asList; import static java.util.stream.Collectors.toMap; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -42,7 +43,7 @@ public void listWithBom() throws Exception { final Map installed = readByKey(project); - Assertions.assertNotNull(installed.get(AppArtifactKey.fromString(getPluginGroupId() + ":quarkus-agroal"))); + Assertions.assertNotNull(installed.get(AppArtifactKey.fromString(IO_QUARKUS + ":quarkus-agroal"))); } /** @@ -60,8 +61,9 @@ public void listWithBomExtensionWithSpaces() throws Exception { final Map installed = readByKey(quarkusProject); - Assertions.assertNotNull(installed.get(AppArtifactKey.fromString(getPluginGroupId() + ":quarkus-resteasy"))); - Assertions.assertNotNull(installed.get(AppArtifactKey.fromString(getPluginGroupId() + ":quarkus-hibernate-validator"))); + Assertions.assertNotNull(installed.get(AppArtifactKey.fromString(IO_QUARKUS + ":quarkus-resteasy"))); + Assertions.assertNotNull( + installed.get(AppArtifactKey.fromString(IO_QUARKUS + ":quarkus-hibernate-validator"))); } @Test @@ -77,7 +79,7 @@ public void listWithoutBom() throws Exception { MojoUtils.write(model, pom); addExtensions(quarkusProject, "commons-io:commons-io:2.5", "Agroal", - "io.quarkus:quarkus-hibernate-orm-panache:" + getPluginVersion()); + "io.quarkus:quarkus-hibernate-orm-panache:" + getMavenPluginVersion()); model = readPom(pom); @@ -106,14 +108,14 @@ public void listWithoutBom() throws Exception { assertTrue(line.startsWith("custom*"), "RESTEasy should list as being custom*: " + line); assertTrue( line.endsWith( - String.format("%-15s", getPluginVersion())), + String.format("%-15s", getMavenPluginVersion())), "RESTEasy should list as being custom*: " + line); resteasy = true; checkGuideInLineAfter = true; } else if (line.contains("quarkus-hibernate-orm-panache ")) { assertTrue(line.startsWith("custom"), "Panache should list as being custom: " + line); assertTrue( - line.endsWith(String.format("%-25s", getPluginVersion())), + line.endsWith(String.format("%-25s", getMavenPluginVersion())), "Panache should list as being custom*: " + line); panache = true; } else if (line.contains("hibernate-validator")) { diff --git a/integration-tests/devtools/src/test/java/io/quarkus/devtools/project/codegen/rest/BasicRestProjectGeneratorTest.java b/integration-tests/devtools/src/test/java/io/quarkus/devtools/project/codegen/rest/BasicRestProjectGeneratorTest.java index a745b1cdb3711..d09ad60d091c0 100644 --- a/integration-tests/devtools/src/test/java/io/quarkus/devtools/project/codegen/rest/BasicRestProjectGeneratorTest.java +++ b/integration-tests/devtools/src/test/java/io/quarkus/devtools/project/codegen/rest/BasicRestProjectGeneratorTest.java @@ -106,7 +106,7 @@ void generateFilesWithJaxRsResource() throws Exception { && argument.contains("quarkus-app0.0.1-SNAPSHOT") && argument.contains( - "<" + MojoUtils.TEMPLATE_PROPERTY_QUARKUS_PLATFORM_VERSION_NAME + ">" + getPluginVersion() + "<" + MojoUtils.TEMPLATE_PROPERTY_QUARKUS_PLATFORM_VERSION_NAME + ">" + getQuarkusCoreVersion() + ""))); verify(mockWriter, times(1)).write(eq("src/main/java/org/example/ExampleResource.java"), argThat(argument -> argument.contains("@Path(\"/hello\")"))); diff --git a/integration-tests/devtools/src/test/resources/platform-metadata.json b/integration-tests/devtools/src/test/resources/platform-metadata.json new file mode 100644 index 0000000000000..f392cfc6d3e33 --- /dev/null +++ b/integration-tests/devtools/src/test/resources/platform-metadata.json @@ -0,0 +1,28 @@ +{ + "maven" : { + "repositories" : [ + { + "id": "redhat", + "url": "https://maven.repository.redhat.com", + "releases-enabled": "true", + "snapshots-enabled": "false" + } + ], + "plugin-repositories" : [ + { + "id": "redhat", + "url": "https://maven.repository.redhat.com", + "releases-enabled": "true", + "snapshots-enabled": "false" + } + ] + }, + "gradle" : { + "repositories" : [ + { + "id": "redhat", + "url": "https://maven.repository.redhat.com" + } + ] + } +} \ No newline at end of file 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 fd8256f0247c6..ea79b3193570d 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 @@ -76,12 +76,12 @@ private InvocationResult setup(Properties params) throws MavenInvocationException, FileNotFoundException, UnsupportedEncodingException { params.setProperty("platformArtifactId", "quarkus-bom"); - params.setProperty("platformVersion", getPluginVersion()); + params.setProperty("platformVersion", getQuarkusCoreVersion()); InvocationRequest request = new DefaultInvocationRequest(); request.setBatchMode(true); request.setGoals(Collections.singletonList( - getPluginGroupId() + ":" + getPluginArtifactId() + ":" + getPluginVersion() + ":create")); + getMavenPluginGroupId() + ":" + getMavenPluginArtifactId() + ":" + getMavenPluginVersion() + ":create")); request.setProperties(params); getEnv().forEach(request::addShellEnvironment); File log = new File(testDir, "build-create-" + testDir.getName() + ".log"); diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/AddExtensionIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/AddExtensionIT.java index 727a9d700df1e..ba97843155f42 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/AddExtensionIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/AddExtensionIT.java @@ -110,11 +110,11 @@ private void addExtension(boolean plural, String ext) InvocationRequest request = new DefaultInvocationRequest(); request.setBatchMode(true); request.setGoals(Collections.singletonList( - getPluginGroupId() + ":" + getPluginArtifactId() + ":" + getPluginVersion() + ":add-extension")); + getMavenPluginGroupId() + ":" + getMavenPluginArtifactId() + ":" + getMavenPluginVersion() + ":add-extension")); Properties properties = new Properties(); properties.setProperty("platformGroupId", "io.quarkus"); properties.setProperty("platformArtifactId", "quarkus-bom"); - properties.setProperty("platformVersion", getPluginVersion()); + properties.setProperty("platformVersion", getQuarkusCoreVersion()); if (plural) { properties.setProperty("extensions", ext); } else { diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectCodestartMojoIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectCodestartMojoIT.java index 416277fa139a0..97b6c91a08371 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectCodestartMojoIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectCodestartMojoIT.java @@ -112,12 +112,12 @@ private InvocationResult executeCreate(Properties params) Invoker invoker = initInvoker(testDir); params.setProperty("platformGroupId", ToolsConstants.IO_QUARKUS); params.setProperty("platformArtifactId", "quarkus-bom"); - params.setProperty("platformVersion", getPluginVersion()); + params.setProperty("platformVersion", getQuarkusCoreVersion()); InvocationRequest request = new DefaultInvocationRequest(); request.setBatchMode(true); request.setGoals(Collections.singletonList( - getPluginGroupId() + ":" + getPluginArtifactId() + ":" + getPluginVersion() + ":create")); + getMavenPluginGroupId() + ":" + getMavenPluginArtifactId() + ":" + getMavenPluginVersion() + ":create")); request.setDebug(false); request.setShowErrors(false); request.setProperties(params); 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 6c56b52a29f03..a4080a294b610 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 @@ -361,12 +361,12 @@ private InvocationResult setup(Properties params) params.setProperty("platformGroupId", ToolsConstants.IO_QUARKUS); params.setProperty("platformArtifactId", "quarkus-bom"); - params.setProperty("platformVersion", getPluginVersion()); + params.setProperty("platformVersion", getQuarkusCoreVersion()); InvocationRequest request = new DefaultInvocationRequest(); request.setBatchMode(true); request.setGoals(Collections.singletonList( - getPluginGroupId() + ":" + getPluginArtifactId() + ":" + getPluginVersion() + ":create")); + getMavenPluginGroupId() + ":" + getMavenPluginArtifactId() + ":" + getMavenPluginVersion() + ":create")); request.setDebug(false); request.setShowErrors(false); request.setProperties(params); diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/GenerateConfigIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/GenerateConfigIT.java index 5d6097d073dd2..af3b7dec40074 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/GenerateConfigIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/GenerateConfigIT.java @@ -62,8 +62,8 @@ private void generateConfig(String filename) InvocationRequest request = new DefaultInvocationRequest(); request.setBatchMode(true); request.setGoals(Collections - .singletonList(getPluginGroupId() + ":" + getPluginArtifactId() + ":" - + getPluginVersion() + ":generate-config")); + .singletonList(getMavenPluginGroupId() + ":" + getMavenPluginArtifactId() + ":" + + getMavenPluginVersion() + ":generate-config")); Properties properties = new Properties(); properties.setProperty("file", filename); request.setProperties(properties); diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/ListExtensionsIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/ListExtensionsIT.java index 962ff87c06cc7..3edcc11e4d4e1 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/ListExtensionsIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/ListExtensionsIT.java @@ -62,7 +62,8 @@ private List listExtensions() InvocationRequest request = new DefaultInvocationRequest(); request.setBatchMode(true); request.setGoals(Collections.singletonList( - getPluginGroupId() + ":" + getPluginArtifactId() + ":" + getPluginVersion() + ":list-extensions")); + getMavenPluginGroupId() + ":" + getMavenPluginArtifactId() + ":" + getMavenPluginVersion() + + ":list-extensions")); getEnv().forEach(request::addShellEnvironment); File outputLog = new File(testDir, "output.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 92cb8977dcde0..e086dffd40cbd 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 @@ -83,12 +83,12 @@ private InvocationResult setup(Properties params) throw e; } params.setProperty("platformArtifactId", getBomArtifactId()); - params.setProperty("platformVersion", getPluginVersion()); + params.setProperty("platformVersion", getQuarkusCoreVersion()); InvocationRequest request = new DefaultInvocationRequest(); request.setBatchMode(true); request.setGoals(Collections.singletonList( - getPluginGroupId() + ":" + getPluginArtifactId() + ":" + getPluginVersion() + ":create")); + getMavenPluginGroupId() + ":" + getMavenPluginArtifactId() + ":" + getMavenPluginVersion() + ":create")); request.setProperties(params); getEnv().forEach(request::addShellEnvironment); File log = new File(testDir, "build-create-" + testDir.getName() + ".log"); diff --git a/test-framework/maven/src/main/java/io/quarkus/maven/it/QuarkusPlatformAwareMojoTestBase.java b/test-framework/maven/src/main/java/io/quarkus/maven/it/QuarkusPlatformAwareMojoTestBase.java index 70dc14920610a..9b401ae8dc036 100644 --- a/test-framework/maven/src/main/java/io/quarkus/maven/it/QuarkusPlatformAwareMojoTestBase.java +++ b/test-framework/maven/src/main/java/io/quarkus/maven/it/QuarkusPlatformAwareMojoTestBase.java @@ -10,9 +10,6 @@ public class QuarkusPlatformAwareMojoTestBase extends MojoTestBase { private QuarkusPlatformDescriptor platformDescr; private Properties quarkusProps; - private String pluginGroupId; - private String pluginArtifactId; - private String pluginVersion; protected QuarkusPlatformDescriptor getPlatformDescriptor() { return platformDescr == null ? platformDescr = QuarkusJsonPlatformDescriptorResolver.newInstance().resolveBundled() @@ -26,17 +23,20 @@ private Properties getQuarkusProperties() { return quarkusProps; } - protected String getPluginGroupId() { - return pluginGroupId == null ? pluginGroupId = getQuarkusProperties().getProperty("plugin-groupId") : pluginGroupId; + protected String getMavenPluginGroupId() { + return ToolsUtils.getMavenPluginGroupId(getQuarkusProperties()); } - protected String getPluginArtifactId() { - return pluginArtifactId == null ? pluginArtifactId = getQuarkusProperties().getProperty("plugin-artifactId") - : pluginArtifactId; + protected String getMavenPluginArtifactId() { + return ToolsUtils.getMavenPluginArtifactId(getQuarkusProperties()); } - protected String getPluginVersion() { - return pluginVersion == null ? pluginVersion = getQuarkusProperties().getProperty("plugin-version") : pluginVersion; + protected String getMavenPluginVersion() { + return ToolsUtils.getMavenPluginVersion(getQuarkusProperties()); + } + + protected String getQuarkusCoreVersion() { + return ToolsUtils.getQuarkusCoreVersion(getQuarkusProperties()); } protected String getBomGroupId() {