diff --git a/devtools/gradle/build-logic/build.gradle.kts b/devtools/gradle/build-logic/build.gradle.kts new file mode 100644 index 0000000000000..4dc03934dc083 --- /dev/null +++ b/devtools/gradle/build-logic/build.gradle.kts @@ -0,0 +1,10 @@ +plugins { + `kotlin-dsl` +} + +dependencies { + implementation(plugin("com.gradle.plugin-publish", "1.2.0")) +} + +fun DependencyHandler.plugin(id: String, version: String) = + create("$id:$id.gradle.plugin:$version") diff --git a/devtools/gradle/build-logic/settings.gradle.kts b/devtools/gradle/build-logic/settings.gradle.kts new file mode 100644 index 0000000000000..db8235fe0a54b --- /dev/null +++ b/devtools/gradle/build-logic/settings.gradle.kts @@ -0,0 +1,13 @@ +@Suppress("UnstableApiUsage") +dependencyResolutionManagement { + repositories { + mavenCentral() + gradlePluginPortal() + } + + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } +} diff --git a/devtools/gradle/build-logic/src/main/kotlin/io.quarkus.devtools.gradle-plugin.gradle.kts b/devtools/gradle/build-logic/src/main/kotlin/io.quarkus.devtools.gradle-plugin.gradle.kts new file mode 100644 index 0000000000000..e317c71f05da2 --- /dev/null +++ b/devtools/gradle/build-logic/src/main/kotlin/io.quarkus.devtools.gradle-plugin.gradle.kts @@ -0,0 +1,16 @@ +plugins { + id("io.quarkus.devtools.java-library") + id("com.gradle.plugin-publish") + id("maven-publish") +} + +dependencies { + val libs = project.the().named("libs") + implementation(project(":gradle-model")) + implementation(libs.getLibrary("quarkus-devtools-common")) +} + +gradlePlugin { + website.set("https://quarkus.io/") + vcsUrl.set("https://github.com/quarkusio/quarkus") +} diff --git a/devtools/gradle/build-logic/src/main/kotlin/io.quarkus.devtools.java-library.gradle.kts b/devtools/gradle/build-logic/src/main/kotlin/io.quarkus.devtools.java-library.gradle.kts new file mode 100644 index 0000000000000..5ad88d8e2ade3 --- /dev/null +++ b/devtools/gradle/build-logic/src/main/kotlin/io.quarkus.devtools.java-library.gradle.kts @@ -0,0 +1,45 @@ +plugins { + id("java-library") + id("maven-publish") +} + +dependencies { + api(gradleApi()) + + val libs = project.the().named("libs") + implementation(platform("io.quarkus:quarkus-bom:$version")) + + implementation(libs.getLibrary("quarkus-bootstrap-core")) + implementation(libs.getLibrary("quarkus-bootstrap-gradle-resolver")) + implementation(libs.getLibrary("quarkus-core-deployment")) + + testImplementation(platform("io.quarkus:quarkus-bom:$version")) + testImplementation(platform(libs.getLibrary("junit-bom"))) + testImplementation(gradleTestKit()) + testImplementation(libs.getLibrary("junit-api")) + testImplementation(libs.getLibrary("assertj")) + + testImplementation(libs.getLibrary("quarkus-devtools-testing")) +} + +tasks.withType().configureEach { + options.release.set(11) + options.encoding = "UTF-8" +} + +tasks.named(JavaPlugin.JAVADOC_TASK_NAME) { + options.encoding = "UTF-8" + (options as? CoreJavadocOptions)?.addStringOption("Xdoclint:-reference", "-quiet") +} + +tasks.named(JavaPlugin.TEST_TASK_NAME) { + useJUnitPlatform() + testLogging { + events("passed", "skipped", "failed") + } + + // propagate the custom local maven repo, in case it's configured + if (System.getProperties().containsKey("maven.repo.local")) { + systemProperty("maven.repo.local", System.getProperty("maven.repo.local")) + } +} diff --git a/devtools/gradle/build-logic/src/main/kotlin/utils.kt b/devtools/gradle/build-logic/src/main/kotlin/utils.kt new file mode 100644 index 0000000000000..d56cbac4e840f --- /dev/null +++ b/devtools/gradle/build-logic/src/main/kotlin/utils.kt @@ -0,0 +1,4 @@ +import org.gradle.api.artifacts.VersionCatalog + +fun VersionCatalog.getLibrary(alias: String) = + findLibrary(alias).orElseThrow { IllegalArgumentException("library $alias not found in catalog $name") } diff --git a/devtools/gradle/build.gradle b/devtools/gradle/build.gradle deleted file mode 100644 index 48e0f93ca87d6..0000000000000 --- a/devtools/gradle/build.gradle +++ /dev/null @@ -1,58 +0,0 @@ -plugins { - id 'com.gradle.plugin-publish' version '1.2.0' apply false -} - -subprojects { - - apply plugin: 'java-library' - apply plugin: 'maven-publish' - - if (JavaVersion.current().isJava9Compatible()) { - compileJava.options.compilerArgs.addAll(['--release', '11']) - } - compileJava { - options.encoding = 'UTF-8' - sourceCompatibility = '11' - targetCompatibility = '11' - } - - compileTestJava { - options.encoding = 'UTF-8' - } - - repositories { - mavenLocal() - mavenCentral() - } - - dependencies { - api gradleApi() - - implementation "io.quarkus:quarkus-bootstrap-core:${version}" - - testImplementation gradleTestKit() - testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2' - testImplementation 'org.assertj:assertj-core:3.24.2' - } - - test { - // propagate the custom local maven repo, in case it's configured - if (System.properties.containsKey('maven.repo.local')) { - systemProperty 'maven.repo.local', System.properties.get('maven.repo.local') - } - testLogging { - events "passed", "skipped", "failed" - } - useJUnitPlatform() - } - - javadoc { - options.addStringOption('encoding', 'UTF-8') - options.addStringOption("Xdoclint:-reference", "-quiet") - } -} - -wrapper { - distributionType = Wrapper.DistributionType.ALL -} - diff --git a/devtools/gradle/build.gradle.kts b/devtools/gradle/build.gradle.kts new file mode 100644 index 0000000000000..6ffe25f29b6e0 --- /dev/null +++ b/devtools/gradle/build.gradle.kts @@ -0,0 +1,5 @@ +tasks.wrapper { + // not sure if it's still required: IntelliJ works fine with `-bin` distribution + // after indexing Gradle API jars + distributionType = Wrapper.DistributionType.ALL +} diff --git a/devtools/gradle/gradle-application-plugin/build.gradle b/devtools/gradle/gradle-application-plugin/build.gradle deleted file mode 100644 index fc8b3ccfff735..0000000000000 --- a/devtools/gradle/gradle-application-plugin/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -plugins { - id 'java-gradle-plugin' - id 'com.gradle.plugin-publish' -} - -dependencies { - implementation "io.quarkus:quarkus-devtools-common:${version}" - implementation "io.quarkus:quarkus-core-deployment:${version}" - implementation "io.quarkus:quarkus-bootstrap-gradle-resolver:${version}" - implementation "io.smallrye.config:smallrye-config-source-yaml:${smallrye_config_version}" - - implementation project(":gradle-model") - - testImplementation "io.quarkus:quarkus-project-core-extension-codestarts:${version}" - testImplementation "io.quarkus:quarkus-devmode-test-utils:${version}" - testImplementation "io.quarkus:quarkus-devtools-testing:${version}" -} - -group = "io.quarkus" - -gradlePlugin { - plugins { - quarkusPlugin { - id = 'io.quarkus' - implementationClass = 'io.quarkus.gradle.QuarkusPlugin' - displayName = 'Quarkus Plugin' - description = 'Builds a Quarkus application, and provides helpers to launch dev-mode, the Quarkus CLI, building of native images' - tags.addAll(['quarkus', 'quarkusio', 'graalvm']) - } - } - vcsUrl.set("https://github.com/quarkusio/quarkus") - website.set("https://quarkus.io/") -} - -test { - systemProperty 'kotlin_version', project.kotlin_version -} diff --git a/devtools/gradle/gradle-application-plugin/build.gradle.kts b/devtools/gradle/gradle-application-plugin/build.gradle.kts new file mode 100644 index 0000000000000..b10d179997a7d --- /dev/null +++ b/devtools/gradle/gradle-application-plugin/build.gradle.kts @@ -0,0 +1,26 @@ +plugins { + id("io.quarkus.devtools.gradle-plugin") +} + +dependencies { + implementation(libs.smallrye.config.yaml) + + testImplementation(libs.quarkus.project.core.extension.codestarts) +} + +group = "io.quarkus" + +gradlePlugin { + plugins.create("quarkusPlugin") { + id = "io.quarkus" + implementationClass = "io.quarkus.gradle.QuarkusPlugin" + displayName = "Quarkus Plugin" + description = + "Builds a Quarkus application, and provides helpers to launch dev-mode, the Quarkus CLI, building of native images" + tags.addAll("quarkus", "quarkusio", "graalvm") + } +} + +tasks.test { + systemProperty("kotlin_version", libs.versions.kotlin.get()) +} diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/ImagePush.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/ImagePush.java index caae7919b3445..4fa72ecee5a1c 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/ImagePush.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/ImagePush.java @@ -33,12 +33,12 @@ public void checkRequiredExtensions() { .collect(Collectors.toList()); if (containerImageExtensions.isEmpty()) { - getProject().getLogger().warn("Task: {} requires a container image extension.", getName()); - getProject().getLogger().warn("Available container image exntesions: [{}]", + getLogger().warn("Task: {} requires a container image extension.", getName()); + getLogger().warn("Available container image exntesions: [{}]", extensions.stream().collect(Collectors.joining(", "))); - getProject().getLogger().warn("To add an extension to the project, you can run one of the commands below:"); + getLogger().warn("To add an extension to the project, you can run one of the commands below:"); extensions.forEach(e -> { - getProject().getLogger().warn("\tgradle addExtension --extensions={}", e); + getLogger().warn("\tgradle addExtension --extensions={}", e); }); } } diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/ImageTask.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/ImageTask.java index 7ecf267341e66..089c63db4caea 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/ImageTask.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/ImageTask.java @@ -69,17 +69,17 @@ public void checkRequiredExtensions() { List availableBuidlers = availableBuilders(); Optional missingBuilder = Optional.of(builder()).filter(Predicate.not(availableBuidlers::contains)); missingBuilder.map(builder -> QUARKUS_CONTAINER_IMAGE_PREFIX + builder.name()).ifPresent(missingDependency -> { - getProject().getLogger().warn("Task: {} requires extensions: {}", getName(), missingDependency); - getProject().getLogger().warn("To add the extensions to the project you can run the following command:"); - getProject().getLogger().warn("\tgradle addExtension --extensions={}", missingDependency); + getLogger().warn("Task: {} requires extensions: {}", getName(), missingDependency); + getLogger().warn("To add the extensions to the project you can run the following command:"); + getLogger().warn("\tgradle addExtension --extensions={}", missingDependency); abort("Aborting."); }); if (!missingBuilder.isPresent() && availableBuidlers.isEmpty()) { - getProject().getLogger().warn("Task: {} requires on of extensions: {}", getName(), + getLogger().warn("Task: {} requires on of extensions: {}", getName(), Arrays.stream(Builder.values()).map(Builder::name).collect(Collectors.joining(", ", "[", "]"))); - getProject().getLogger().warn("To add the extensions to the project you can run the following command:"); - getProject().getLogger().warn("\tgradle addExtension --extensions="); + getLogger().warn("To add the extensions to the project you can run the following command:"); + getLogger().warn("\tgradle addExtension --extensions="); abort("Aborting."); } } diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildTask.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildTask.java index a3637e4243f43..fa954cbed2a59 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildTask.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildTask.java @@ -253,7 +253,7 @@ void generateBuild() { } void abort(String message, Object... args) { - getProject().getLogger().warn(message, args); + getLogger().warn(message, args); getProject().getTasks().stream() .filter(t -> t != this) .filter(t -> !t.getState().getExecuted()).forEach(t -> { diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java index afcdc38d5960e..f9f42451bd761 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java @@ -446,7 +446,7 @@ private QuarkusDevModeLauncher newLauncher() throws Exception { File file = p.toFile(); if (file.exists() && configuredParentFirst.contains(artifact.getKey()) && filesIncludedInClasspath.add(file)) { - getProject().getLogger().debug("Adding dependency {}", file); + getLogger().debug("Adding dependency {}", file); builder.classpathEntry(artifact.getKey(), file); } }); diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusInfo.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusInfo.java index 053c5aca16b14..16d1c5062b199 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusInfo.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusInfo.java @@ -30,8 +30,7 @@ public QuarkusInfo() { @TaskAction public void logInfo() { - - getProject().getLogger().warn(getName() + " is experimental, its options and output might change in future versions"); + getLogger().warn(getName() + " is experimental, its options and output might change in future versions"); final QuarkusProject quarkusProject = getQuarkusProject(false); final QuarkusCommandOutcome outcome; @@ -44,7 +43,7 @@ public void logInfo() { throw new GradleException("Failed to collect Quarkus project information", e); } if (outcome.getValue(ProjectInfoCommandHandler.RECOMMENDATIONS_AVAILABLE, false)) { - this.getProject().getLogger().warn( + getLogger().warn( "Non-recommended Quarkus platform BOM and/or extension versions were found. For more details, please, execute 'gradle quarkusUpdate --rectify'"); } } diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusListPlatforms.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusListPlatforms.java index f5ee805f1e341..c985939dbcdef 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusListPlatforms.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusListPlatforms.java @@ -28,9 +28,9 @@ public void setInstalled(boolean installed) { @TaskAction public void listExtensions() { - getProject().getLogger().info(""); + getLogger().info(""); if (installed) { - getProject().getLogger().info("Imported Quarkus platforms:"); + getLogger().info("Imported Quarkus platforms:"); importedPlatforms().forEach(coords -> { final StringBuilder buf = new StringBuilder(); buf.append(coords.getGroupId()).append(":") @@ -40,13 +40,13 @@ public void listExtensions() { messageWriter().info(buf.toString()); }); } else { - getProject().getLogger().info("Available Quarkus platforms:"); + getLogger().info("Available Quarkus platforms:"); try { new ListPlatforms(getQuarkusProject(installed)).execute(); } catch (Exception e) { throw new GradleException("Unable to list platforms", e); } } - getProject().getLogger().info(""); + getLogger().info(""); } } diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusPlatformTask.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusPlatformTask.java index 9c612cb4e1780..5bc34c46318bd 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusPlatformTask.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusPlatformTask.java @@ -140,7 +140,7 @@ protected QuarkusProject getQuarkusProject(boolean limitExtensionsToImportedPlat } protected GradleMessageWriter messageWriter() { - return new GradleMessageWriter(getProject().getLogger()); + return new GradleMessageWriter(getLogger()); } protected static URL toURL(String url) { diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusUpdate.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusUpdate.java index 20013bd73b3fe..c47654b99d701 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusUpdate.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusUpdate.java @@ -115,8 +115,7 @@ public QuarkusUpdate() { @TaskAction public void logUpdates() { - - getProject().getLogger().warn(getName() + " is experimental, its options and output might change in future versions"); + getLogger().warn(getName() + " is experimental, its options and output might change in future versions"); final QuarkusProject quarkusProject = getQuarkusProject(false); final ExtensionCatalog targetCatalog; try { diff --git a/devtools/gradle/gradle-extension-plugin/build.gradle b/devtools/gradle/gradle-extension-plugin/build.gradle deleted file mode 100644 index d1b76e2206344..0000000000000 --- a/devtools/gradle/gradle-extension-plugin/build.gradle +++ /dev/null @@ -1,35 +0,0 @@ -plugins { - id 'java-gradle-plugin' - id 'com.gradle.plugin-publish' -} - -dependencies { - implementation platform("io.quarkus:quarkus-bom:${version}") - implementation project(":gradle-model") - implementation "io.quarkus:quarkus-core-deployment" - implementation "io.quarkus:quarkus-devtools-common" - implementation "io.quarkus:quarkus-bootstrap-gradle-resolver" - implementation "com.fasterxml.jackson.core:jackson-databind" - implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml" - testImplementation "org.assertj:assertj-core" -} - -group = "io.quarkus.extension" - -gradlePlugin { - plugins { - quarkusBootstrapPlugin { - id = 'io.quarkus.extension' - implementationClass = 'io.quarkus.extension.gradle.QuarkusExtensionPlugin' - displayName = 'Quarkus Extension Plugin' - description = 'Builds a Quarkus extension' - tags.addAll(['quarkus', 'quarkusio', 'graalvm']) - } - } - vcsUrl.set("https://github.com/quarkusio/quarkus") - website.set("https://quarkus.io/") -} - -tasks.withType(Test) { - environment 'GITHUB_REPOSITORY','some/repo' -} \ No newline at end of file diff --git a/devtools/gradle/gradle-extension-plugin/build.gradle.kts b/devtools/gradle/gradle-extension-plugin/build.gradle.kts new file mode 100644 index 0000000000000..e9ee23274ec11 --- /dev/null +++ b/devtools/gradle/gradle-extension-plugin/build.gradle.kts @@ -0,0 +1,24 @@ +plugins { + id("io.quarkus.devtools.gradle-plugin") +} + +dependencies { + implementation(libs.jackson.databind) + implementation(libs.jackson.dataformat.yaml) +} + +group = "io.quarkus.extension" + +gradlePlugin { + plugins.create("quarkusBootstrapPlugin") { + id = "io.quarkus.extension" + implementationClass = "io.quarkus.extension.gradle.QuarkusExtensionPlugin" + displayName = "Quarkus Extension Plugin" + description = "Builds a Quarkus extension" + tags.addAll("quarkus", "quarkusio", "graalvm") + } +} + +tasks.withType().configureEach { + environment("GITHUB_REPOSITORY", "some/repo") +} diff --git a/devtools/gradle/gradle-model/build.gradle b/devtools/gradle/gradle-model/build.gradle deleted file mode 100644 index 15e648b26cae7..0000000000000 --- a/devtools/gradle/gradle-model/build.gradle +++ /dev/null @@ -1,32 +0,0 @@ -dependencies { - implementation "io.quarkus:quarkus-core-deployment:${version}" - implementation "io.quarkus:quarkus-bootstrap-gradle-resolver:${version}" - implementation "org.jetbrains.kotlin:kotlin-gradle-plugin-api:${kotlin_version}" - testImplementation "io.quarkus:quarkus-devtools-testing:${version}" -} - -task sourcesJar(type: Jar, dependsOn: classes) { - archiveClassifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - archiveClassifier = 'javadoc' - from javadoc.destinationDir -} - -group = 'io.quarkus' - -artifacts { - archives sourcesJar - archives javadocJar -} - -publishing { - publications { - maven(MavenPublication) { - artifactId = 'quarkus-gradle-model' - from components.java - } - } -} diff --git a/devtools/gradle/gradle-model/build.gradle.kts b/devtools/gradle/gradle-model/build.gradle.kts new file mode 100644 index 0000000000000..1811928676d47 --- /dev/null +++ b/devtools/gradle/gradle-model/build.gradle.kts @@ -0,0 +1,21 @@ +plugins { + id("io.quarkus.devtools.java-library") +} + +dependencies { + implementation(libs.kotlin.gradle.plugin.api) +} + +group = "io.quarkus" + +java { + withSourcesJar() + withJavadocJar() +} + +publishing { + publications.create("maven") { + artifactId = "quarkus-gradle-model" + from(components["java"]) + } +} diff --git a/devtools/gradle/gradle.properties b/devtools/gradle/gradle.properties index fbf9bb9588a10..72a61ab94d241 100644 --- a/devtools/gradle/gradle.properties +++ b/devtools/gradle/gradle.properties @@ -1,3 +1 @@ version = 999-SNAPSHOT -kotlin_version = 1.8.10 -smallrye_config_version = 2.13.1 diff --git a/devtools/gradle/gradle/libs.versions.toml b/devtools/gradle/gradle/libs.versions.toml new file mode 100644 index 0000000000000..85df1c8967dd3 --- /dev/null +++ b/devtools/gradle/gradle/libs.versions.toml @@ -0,0 +1,29 @@ +[versions] +plugin-publish = "1.2.0" + +kotlin = "1.8.10" +smallrye-config = "2.13.1" + +junit5 = "5.9.2" +assertj = "3.24.2" + +[plugins] +plugin-publish = { id = "com.gradle.plugin-publish", version.ref = "plugin-publish" } + +[libraries] +quarkus-bom = { module = "io.quarkus:quarkus-bom" } +quarkus-bootstrap-core = { module = "io.quarkus:quarkus-bootstrap-core" } +quarkus-bootstrap-gradle-resolver = { module = "io.quarkus:quarkus-bootstrap-gradle-resolver" } +quarkus-core-deployment = { module = "io.quarkus:quarkus-core-deployment" } +quarkus-devtools-common = { module = "io.quarkus:quarkus-devtools-common" } +quarkus-devtools-testing = { module = "io.quarkus:quarkus-devtools-testing" } +quarkus-project-core-extension-codestarts = { module = "io.quarkus:quarkus-project-core-extension-codestarts" } + +kotlin-gradle-plugin-api = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin-api", version.ref = "kotlin" } +smallrye-config-yaml = { module = "io.smallrye.config:smallrye-config-source-yaml", version.ref = "smallrye-config" } +jackson-databind = {module="com.fasterxml.jackson.core:jackson-databind"} +jackson-dataformat-yaml = {module="com.fasterxml.jackson.dataformat:jackson-dataformat-yaml"} + +junit-bom = { module = "org.junit:junit-bom", version.ref = "junit5" } +junit-api = { module = "org.junit.jupiter:junit-jupiter-api" } +assertj = { module = "org.assertj:assertj-core", version.ref = "assertj" } diff --git a/devtools/gradle/gradle/wrapper/gradle-wrapper.jar b/devtools/gradle/gradle/wrapper/gradle-wrapper.jar index 943f0cbfa7545..c1962a79e29d3 100644 Binary files a/devtools/gradle/gradle/wrapper/gradle-wrapper.jar and b/devtools/gradle/gradle/wrapper/gradle-wrapper.jar differ diff --git a/devtools/gradle/gradlew b/devtools/gradle/gradlew index 4f906e0c811fc..aeb74cbb43e39 100755 --- a/devtools/gradle/gradlew +++ b/devtools/gradle/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,98 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +118,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,7 +129,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -106,80 +137,109 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/devtools/gradle/gradlew.bat b/devtools/gradle/gradlew.bat index ac1b06f93825d..6689b85beecde 100644 --- a/devtools/gradle/gradlew.bat +++ b/devtools/gradle/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/devtools/gradle/settings.gradle b/devtools/gradle/settings.gradle deleted file mode 100644 index a06ece264efa7..0000000000000 --- a/devtools/gradle/settings.gradle +++ /dev/null @@ -1,16 +0,0 @@ -plugins { - id "com.gradle.enterprise" version "3.13" -} - -gradleEnterprise { - buildScan { - // plugin configuration - //See also: https://docs.gradle.com/enterprise/gradle-plugin/ - termsOfServiceUrl = 'https://gradle.com/terms-of-service'; - termsOfServiceAgree = 'yes' - publishOnFailure() - } -} - -rootProject.name = 'quarkus-gradle-plugins' -include 'gradle-application-plugin', 'gradle-extension-plugin', 'gradle-model' diff --git a/devtools/gradle/settings.gradle.kts b/devtools/gradle/settings.gradle.kts new file mode 100644 index 0000000000000..16b2d96281d92 --- /dev/null +++ b/devtools/gradle/settings.gradle.kts @@ -0,0 +1,25 @@ +plugins { + id("com.gradle.enterprise") version "3.13" +} + +gradleEnterprise { + buildScan { + // plugin configuration + //See also: https://docs.gradle.com/enterprise/gradle-plugin/ + termsOfServiceUrl = "https://gradle.com/terms-of-service" + termsOfServiceAgree = "yes" + publishOnFailure() + } +} + +rootProject.name = "quarkus-gradle-plugins" +includeBuild("build-logic") +include("gradle-application-plugin", "gradle-extension-plugin", "gradle-model") + +@Suppress("UnstableApiUsage") +dependencyResolutionManagement { + repositories { + mavenLocal() + mavenCentral() + } +} diff --git a/integration-tests/gradle/build.gradle.kts b/integration-tests/gradle/build.gradle.kts new file mode 100644 index 0000000000000..6ffe25f29b6e0 --- /dev/null +++ b/integration-tests/gradle/build.gradle.kts @@ -0,0 +1,5 @@ +tasks.wrapper { + // not sure if it's still required: IntelliJ works fine with `-bin` distribution + // after indexing Gradle API jars + distributionType = Wrapper.DistributionType.ALL +} diff --git a/integration-tests/gradle/gradle/wrapper/gradle-wrapper.jar b/integration-tests/gradle/gradle/wrapper/gradle-wrapper.jar index 943f0cbfa7545..c1962a79e29d3 100644 Binary files a/integration-tests/gradle/gradle/wrapper/gradle-wrapper.jar and b/integration-tests/gradle/gradle/wrapper/gradle-wrapper.jar differ diff --git a/integration-tests/gradle/gradle/wrapper/gradle-wrapper.properties b/integration-tests/gradle/gradle/wrapper/gradle-wrapper.properties index d5e7b2ac5e417..6ee7ce821e01c 100644 --- a/integration-tests/gradle/gradle/wrapper/gradle-wrapper.properties +++ b/integration-tests/gradle/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -# https://gradle.org/release-checksums/ distributionSha256Sum=2cbafcd2c47a101cb2165f636b4677fac0b954949c9429c1c988da399defe6a9 distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip networkTimeout=10000 diff --git a/integration-tests/gradle/gradlew b/integration-tests/gradle/gradlew index 4f906e0c811fc..aeb74cbb43e39 100755 --- a/integration-tests/gradle/gradlew +++ b/integration-tests/gradle/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,98 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +118,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,7 +129,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -106,80 +137,109 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/integration-tests/gradle/gradlew.bat b/integration-tests/gradle/gradlew.bat index ac1b06f93825d..6689b85beecde 100644 --- a/integration-tests/gradle/gradlew.bat +++ b/integration-tests/gradle/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/integration-tests/gradle/pom.xml b/integration-tests/gradle/pom.xml index c85a73c94a045..6feb49c42c27a 100644 --- a/integration-tests/gradle/pom.xml +++ b/integration-tests/gradle/pom.xml @@ -27,11 +27,13 @@ io.quarkus io.quarkus.gradle.plugin ${project.version} + pom io.quarkus.extension io.quarkus.extension.gradle.plugin ${project.version} + pom org.assertj diff --git a/integration-tests/gradle/settings.gradle.kts b/integration-tests/gradle/settings.gradle.kts new file mode 100644 index 0000000000000..df5e9c5ae2828 --- /dev/null +++ b/integration-tests/gradle/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "gradle-plugins-integration-tests" diff --git a/integration-tests/gradle/src/main/resources/basic-java-library-module/library/build.gradle b/integration-tests/gradle/src/main/resources/basic-java-library-module/library/build.gradle index a13ebe4b69f88..f2164ce02a07f 100644 --- a/integration-tests/gradle/src/main/resources/basic-java-library-module/library/build.gradle +++ b/integration-tests/gradle/src/main/resources/basic-java-library-module/library/build.gradle @@ -14,6 +14,7 @@ repositories { dependencies { api enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") api 'io.quarkus:quarkus-kubernetes-client' + implementation 'org.bouncycastle:bcpkix-jdk18on:1.72' } compileJava { diff --git a/integration-tests/gradle/src/main/resources/test-resources-in-build-steps/deployment/src/main/java/org/acme/ext/deployment/AcmeExtProcessor.java b/integration-tests/gradle/src/main/resources/test-resources-in-build-steps/deployment/src/main/java/org/acme/ext/deployment/AcmeExtProcessor.java index 18b2bc4bfdc29..44cee1ad30eab 100644 --- a/integration-tests/gradle/src/main/resources/test-resources-in-build-steps/deployment/src/main/java/org/acme/ext/deployment/AcmeExtProcessor.java +++ b/integration-tests/gradle/src/main/resources/test-resources-in-build-steps/deployment/src/main/java/org/acme/ext/deployment/AcmeExtProcessor.java @@ -8,6 +8,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.StandardCopyOption; class AcmeExtProcessor { @@ -23,9 +24,9 @@ FeatureBuildItem feature(ApplicationArchivesBuildItem appArchivesBuildItem, final Path output = p.getParent().getParent().getParent().resolve(launchModeBuildItem.getLaunchMode() + "-" + p.getFileName()); try { - Files.copy(p, output); + Files.copy(p, output, StandardCopyOption.REPLACE_EXISTING); } catch(IOException e) { - throw new IllegalStateException("Failed to copy " + p + " to " + output); + throw new IllegalStateException("Failed to copy " + p + " to " + output, e); } return new FeatureBuildItem(FEATURE); }