diff --git a/devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java index c8f45861476c0..39b40c78436bd 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java @@ -74,6 +74,12 @@ public class CreateProjectMojo extends AbstractMojo { @Parameter(property = "projectVersion") private String projectVersion; + @Parameter(property = "codestartsEnabled") + private Boolean codestartsEnabled; + + @Parameter(property = "withExampleCode") + private Boolean withExampleCode; + /** * Group ID of the target platform BOM */ @@ -190,7 +196,9 @@ public void execute() throws MojoExecutionException { .version(projectVersion) .sourceType(sourceType) .className(className) - .extensions(extensions); + .extensions(extensions) + .codestartsEnabled(codestartsEnabled) + .withExampleCode(withExampleCode); if (path != null) { createProject.setValue("path", path); } diff --git a/devtools/platform-descriptor-json/src/main/java/io/quarkus/platform/descriptor/loader/json/impl/QuarkusJsonPlatformDescriptor.java b/devtools/platform-descriptor-json/src/main/java/io/quarkus/platform/descriptor/loader/json/impl/QuarkusJsonPlatformDescriptor.java index d346fd6fd0759..0b409a9200985 100644 --- a/devtools/platform-descriptor-json/src/main/java/io/quarkus/platform/descriptor/loader/json/impl/QuarkusJsonPlatformDescriptor.java +++ b/devtools/platform-descriptor-json/src/main/java/io/quarkus/platform/descriptor/loader/json/impl/QuarkusJsonPlatformDescriptor.java @@ -16,6 +16,7 @@ import io.quarkus.dependencies.Extension; import io.quarkus.platform.descriptor.QuarkusPlatformDescriptor; import io.quarkus.platform.descriptor.ResourceInputStreamConsumer; +import io.quarkus.platform.descriptor.ResourcePathConsumer; import io.quarkus.platform.descriptor.loader.json.ResourceLoader; import io.quarkus.platform.tools.DefaultMessageWriter; import io.quarkus.platform.tools.MessageWriter; @@ -126,6 +127,15 @@ public T loadResource(String name, ResourceInputStreamConsumer consumer) return resourceLoader.loadResource(name, consumer); } + @Override + public T loadResourceAsPath(String name, ResourcePathConsumer consumer) throws IOException { + getLog().debug("Loading Quarkus platform resource %s", name); + if (resourceLoader == null) { + throw new IllegalStateException("Resource loader has not been provided"); + } + return resourceLoader.loadResourceAsPath(name, consumer); + } + @Override public List getCategories() { return categories; diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/base/..gitignore b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/base/..gitignore new file mode 100644 index 0000000000000..ace4d3dd9713d --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/base/..gitignore @@ -0,0 +1,3 @@ +# Gradle +.gradle/ +build/ \ No newline at end of file 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 new file mode 100644 index 0000000000000..271a56056f92b --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/base/build-layout.include.qute @@ -0,0 +1,42 @@ +{#insert plugins} +plugins { + id '{quarkus.plugin.id}' +} +{/} + +{#insert repositories} +repositories { + mavenLocal() + mavenCentral() +} +{/} + +{#insert dependencies} +dependencies { + implementation enforcedPlatform("$\{quarkusPlatformGroupId}:$\{quarkusPlatformArtifactId}:$\{quarkusPlatformVersion}") +{#for dep in dependencies} + implementation '{dep}' +{/for} + testImplementation 'io.quarkus:quarkus-junit5' +{#for dep in test-dependencies} + testImplementation '{dep}' +{/for} +} +{/} + +{#insert project} +group '{project.group-id}' +version '{project.version}' +{/} + +{#insert java} +java { + {#if java.version == "11"} + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + {#else} + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + {/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 new file mode 100644 index 0000000000000..72c7052dddd09 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/base/gradle.tpl.qute.properties @@ -0,0 +1,6 @@ +#Gradle properties +#Tue Jun 16 08:41:21 UTC 2020 +quarkusPluginVersion={quarkus.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 new file mode 100644 index 0000000000000..adce284138546 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/base/settings.tpl.qute.gradle @@ -0,0 +1,11 @@ +pluginManagement { + repositories { + mavenLocal() + mavenCentral() + gradlePluginPortal() + } + plugins { + id '{quarkus.plugin.id}' 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 new file mode 100644 index 0000000000000..e2d4ee96dc17c --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/codestart.yml @@ -0,0 +1,28 @@ +name: gradle +type: buildtool +language: + base: + data: + quarkus: + plugin: + id: io.quarkus + version: + kotlin: 1.3.72 + scala: 2.12.8 + shared-data: + buildtool: + build-dir: build + guide: https://quarkus.io/guides/gradle-tooling + guide-native: https://quarkus.io/guides/gradle-tooling#building-a-native-executable + cmd: + dev: ./gradlew quarkusDev + package: ./gradlew quarkusBuild + package-uberjar: ./gradlew quarkusBuild --uber-jar + package-native: ./gradlew build -Dquarkus.package.type=native + package-native-container: ./gradlew build -Dquarkus.package.type=native -Dquarkus.native.container-build=true + kotlin: + dependencies: + - org.jetbrains.kotlin:kotlin-stdlib-jdk8 + scala: + dependencies: + - org.scala-lang:scala-library:${version.scala} 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 new file mode 100644 index 0000000000000..185ccdd49c664 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/java/build.tpl.qute.gradle @@ -0,0 +1,17 @@ +{#include build-layout} +{#plugins} +plugins { + id 'java' + id '{quarkus.plugin.id}' +} +{/plugins} +{/include} + +compileJava { + options.encoding = 'UTF-8' + options.compilerArgs << '-parameters' +} + +compileTestJava { + options.encoding = 'UTF-8' +} 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 new file mode 100644 index 0000000000000..fae0ff76d1191 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/kotlin/build.tpl.qute.gradle @@ -0,0 +1,40 @@ +{#include build-layout} +{#plugins} +plugins { + id 'org.jetbrains.kotlin.jvm' version "{version.kotlin}" + id "org.jetbrains.kotlin.plugin.allopen" version "{version.kotlin}" + id '{quarkus.plugin.id}' +} +{/plugins} +{/include} + +quarkus { + setOutputDirectory("$projectDir/build/classes/kotlin/main") +} + +quarkusDev { + setSourceDir("$projectDir/src/main/kotlin") +} + +allOpen { + annotation("javax.ws.rs.Path") + annotation("javax.enterprise.context.ApplicationScoped") + annotation("io.quarkus.test.junit.QuarkusTest") +} + +compileKotlin { + {#if java.version == "11"} + kotlinOptions.jvmTarget = JavaVersion.VERSION_11 + {#else} + kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8 + {/if} + kotlinOptions.javaParameters = true +} + +compileTestKotlin { + {#if java.version == "11"} + kotlinOptions.jvmTarget = JavaVersion.VERSION_11 + {#else} + kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8 + {/if} +} 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 new file mode 100644 index 0000000000000..2367c8343a5f3 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/gradle/scala/build.tpl.qute.gradle @@ -0,0 +1,19 @@ +{#include build-layout} +{#plugins} +plugins { + id 'scala' + id '{quarkus.plugin.id}' +} + {/plugins} +{/include} + +compileScala { + scalaCompileOptions.encoding = 'UTF-8' + {#if java.version == "11"} + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + {#else} + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + {/if} +} diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/base/..gitignore b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/base/..gitignore new file mode 100644 index 0000000000000..b1be26f06a497 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/base/..gitignore @@ -0,0 +1,6 @@ +#Maven +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +release.properties \ No newline at end of file diff --git a/independent-projects/tools/devtools-common/src/test/resources/templates/basic-rest/java/pom.xml-template.ftl b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/base/pom.tpl.qute.xml similarity index 63% rename from independent-projects/tools/devtools-common/src/test/resources/templates/basic-rest/java/pom.xml-template.ftl rename to devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/base/pom.tpl.qute.xml index b82146a023918..60ddf17e328e3 100644 --- a/independent-projects/tools/devtools-common/src/test/resources/templates/basic-rest/java/pom.xml-template.ftl +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/base/pom.tpl.qute.xml @@ -1,31 +1,31 @@ 4.0.0 - ${project_groupId} - ${project_artifactId} - ${project_version} + {project.group-id} + {project.artifact-id} + {project.version} UTF-8 UTF-8 - 1.8 - 1.8 + {java.version} + {java.version} true - ${bom_artifactId} - ${bom_groupId} - ${bom_version} - ${plugin_version} - ${compiler_plugin_version} - ${surefire_plugin_version} + {quarkus.platform.group-id} + {quarkus.platform.artifact-id} + {quarkus.platform.version} + {quarkus.plugin.version} + {maven.version.maven-compiler-plugin} + {maven.version.maven-surefire-plugin} - ${maven_repositories}${maven_plugin_repositories} + - ${quarkus.platform.group-id} - ${quarkus.platform.artifact-id} - ${quarkus.platform.version} + $\{quarkus.platform.group-id} + $\{quarkus.platform.artifact-id} + $\{quarkus.platform.version} pom import @@ -33,10 +33,15 @@ + {#each dependencies} - io.quarkus - quarkus-resteasy + {it.groupId} + {it.artifactId} + {#if it.version} + {it.version} + {/if} + {/each} @@ -44,20 +49,25 @@ quarkus-junit5 test + {#each test-dependencies} - io.rest-assured - rest-assured + {it.groupId} + {it.artifactId} + {#if it.version} + {it.version} + {/if} test + {/each} - ${plugin_groupId} - ${plugin_artifactId} - ${quarkus-plugin.version} + {quarkus.plugin.group-id} + {quarkus.plugin.artifact-id} + $\{quarkus-plugin.version} @@ -70,17 +80,17 @@ maven-compiler-plugin - ${compiler-plugin.version} + $\{compiler-plugin.version} org.apache.maven.plugins maven-surefire-plugin - ${surefire-plugin.version} + $\{surefire-plugin.version} org.jboss.logmanager.LogManager - ${maven.home} + $\{maven.home} @@ -105,7 +115,7 @@ org.apache.maven.plugins maven-failsafe-plugin - ${surefire-plugin.version} + $\{surefire-plugin.version} @@ -114,9 +124,9 @@ - ${project.build.directory}/${project.build.finalName}-runner + $\{project.build.directory}/$\{project.build.finalName}-runner org.jboss.logmanager.LogManager - ${maven.home} + $\{maven.home} diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/codestart.yml new file mode 100644 index 0000000000000..e0565e31ac048 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/codestart.yml @@ -0,0 +1,25 @@ +--- +name: maven +type: buildtool +fallback: true +language: + base: + data: + maven: + version: + kotlin: 1.3.72 + scala: 2.12.8 + scala-maven-plugin: 4.1.1 + maven-compiler-plugin: 3.8.1 + maven-surefire-plugin: 2.22.1 + shared-data: + buildtool: + build-dir: target + guide: https://quarkus.io/guides/maven-tooling.html + guide-native: https://quarkus.io/guides/building-native-image + cmd: + dev: ./mvnw compile quarkus:dev + package: ./mvnw package + package-uberjar: ./mvnw package -PuberJar + package-native: ./mvnw package -Pnative + package-native-container: ./mvnw package -Pnative -Dquarkus.native.container-build=true diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/kotlin/pom.tpl.qute.xml b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/kotlin/pom.tpl.qute.xml new file mode 100644 index 0000000000000..f87cc6b6345bb --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/kotlin/pom.tpl.qute.xml @@ -0,0 +1,67 @@ + + + {maven.version.kotlin} + + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + + + + io.rest-assured + kotlin-extensions + test + + + + src/main/kotlin + src/test/kotlin + + + + kotlin-maven-plugin + org.jetbrains.kotlin + $\{kotlin.version} + + + compile + + compile + + + + test-compile + + test-compile + + + + + true + 1.8 + + + all-open + + + + + + + + + + + + + org.jetbrains.kotlin + kotlin-maven-allopen + $\{kotlin.version} + + + + + + \ No newline at end of file diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/scala/pom.tpl.qute.xml b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/scala/pom.tpl.qute.xml new file mode 100644 index 0000000000000..00c9283819430 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/scala/pom.tpl.qute.xml @@ -0,0 +1,62 @@ + + + {maven.version.scala-maven-plugin} + {maven.version.scala} + + + + io.quarkus + quarkus-scala + + + org.scala-lang + scala-library + $\{scala.version} + + + org.scala-lang + scala-reflect + $\{scala.version} + + + + src/main/scala + src/test/scala + + + net.alchim31.maven + scala-maven-plugin + $\{scala-maven-plugin.version} + + + scala-compile-first + process-resources + + add-source + compile + + + + scala-test-compile + process-test-resources + + add-source + testCompile + + + + + $\{scala.version} + + -deprecation + -feature + -explaintypes + -target:jvm-1.8 + -Ypartial-unification + + + + + + \ No newline at end of file diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/config/properties/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/config/properties/codestart.yml new file mode 100644 index 0000000000000..b7de311e246fa --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/config/properties/codestart.yml @@ -0,0 +1,9 @@ +--- +name: config-properties +type: config +fallback: true +language: + base: + shared-data: + config: + file-name: application.properties \ No newline at end of file diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/config/yaml/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/config/yaml/codestart.yml new file mode 100644 index 0000000000000..e3829b28166eb --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/config/yaml/codestart.yml @@ -0,0 +1,8 @@ +--- +name: config-yaml +type: config +language: + base: + shared-data: + config: + file-name: application.yml \ No newline at end of file diff --git a/independent-projects/tools/devtools-common/src/test/resources/templates/index.ftl b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/example/base-example/base/src/main/resources/META-INF/resources/index.tpl.qute.html similarity index 82% rename from independent-projects/tools/devtools-common/src/test/resources/templates/index.ftl rename to devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/example/base-example/base/src/main/resources/META-INF/resources/index.tpl.qute.html index ef51dbc6ab16c..58552e6516d78 100644 --- a/independent-projects/tools/devtools-common/src/test/resources/templates/index.ftl +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/example/base-example/base/src/main/resources/META-INF/resources/index.tpl.qute.html @@ -2,7 +2,7 @@ - ${project_artifactId} - ${project_version} + {project.artifact-id} - {project.version}