Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Gradle plugins build #32668

Merged
merged 8 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions devtools/gradle/build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")
13 changes: 13 additions & 0 deletions devtools/gradle/build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}

versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
id("io.quarkus.devtools.java-library")
id("com.gradle.plugin-publish")
id("maven-publish")
}

dependencies {
val libs = project.the<VersionCatalogsExtension>().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")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
plugins {
id("java-library")
id("maven-publish")
}

dependencies {
api(gradleApi())

val libs = project.the<VersionCatalogsExtension>().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<JavaCompile>().configureEach {
options.release.set(11)
options.encoding = "UTF-8"
}

tasks.named<Javadoc>(JavaPlugin.JAVADOC_TASK_NAME) {
options.encoding = "UTF-8"
(options as? CoreJavadocOptions)?.addStringOption("Xdoclint:-reference", "-quiet")
}

tasks.named<Test>(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"))
}
}
4 changes: 4 additions & 0 deletions devtools/gradle/build-logic/src/main/kotlin/utils.kt
Original file line number Diff line number Diff line change
@@ -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") }
58 changes: 0 additions & 58 deletions devtools/gradle/build.gradle

This file was deleted.

5 changes: 5 additions & 0 deletions devtools/gradle/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
}
37 changes: 0 additions & 37 deletions devtools/gradle/gradle-application-plugin/build.gradle

This file was deleted.

26 changes: 26 additions & 0 deletions devtools/gradle/gradle-application-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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())
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@ public void checkRequiredExtensions() {
List<Builder> availableBuidlers = availableBuilders();
Optional<Builder> 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=<extension name>");
getLogger().warn("To add the extensions to the project you can run the following command:");
getLogger().warn("\tgradle addExtension --extensions=<extension name>");
abort("Aborting.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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'");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(":")
Expand All @@ -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("");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
35 changes: 0 additions & 35 deletions devtools/gradle/gradle-extension-plugin/build.gradle

This file was deleted.

Loading