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

Declaring explicitly the build service in the QuarkusBuildTask #44399

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@ public void apply(Project project) {
// Apply the `java` plugin
project.getPluginManager().apply(JavaPlugin.class);

project.getGradle().getSharedServices().registerIfAbsent("forcedPropertiesService", ForcedPropertieBuildService.class,
spec -> {
});

registerModel();

// register extension
Expand All @@ -156,7 +152,11 @@ public void apply(Project project) {

private void registerTasks(Project project, QuarkusPluginExtension quarkusExt) {
TaskContainer tasks = project.getTasks();

String forcedPropertiesService = String.format("forcedPropertiesService-%s", project.getName());
Provider<ForcedPropertieBuildService> serviceProvider = project.getGradle().getSharedServices().registerIfAbsent(
forcedPropertiesService, ForcedPropertieBuildService.class,
spec -> {
});
final String devRuntimeConfigName = ApplicationDeploymentClasspathBuilder
.getBaseRuntimeConfigName(LaunchMode.DEVELOPMENT);
final Configuration devRuntimeDependencies = project.getConfigurations().maybeCreate(devRuntimeConfigName);
Expand Down Expand Up @@ -236,14 +236,14 @@ private void registerTasks(Project project, QuarkusPluginExtension quarkusExt) {
});
tasks.register(QUARKUS_SHOW_EFFECTIVE_CONFIG_TASK_NAME,
QuarkusShowEffectiveConfig.class, task -> {
configureQuarkusBuildTask(project, quarkusExt, task, quarkusBuildAppModelTask);
configureQuarkusBuildTask(project, task, quarkusBuildAppModelTask, serviceProvider);
task.setDescription("Show effective Quarkus build configuration.");
});

TaskProvider<QuarkusBuildDependencies> quarkusBuildDependencies = tasks.register(QUARKUS_BUILD_DEP_TASK_NAME,
QuarkusBuildDependencies.class,
task -> {
configureQuarkusBuildTask(project, quarkusExt, task, quarkusBuildAppModelTask);
configureQuarkusBuildTask(project, task, quarkusBuildAppModelTask, serviceProvider);

task.getOutputs().doNotCacheIf("Dependencies are never cached", t -> true);
task.getApplicationModel()
Expand All @@ -256,7 +256,7 @@ private void registerTasks(Project project, QuarkusPluginExtension quarkusExt) {
TaskProvider<QuarkusBuildCacheableAppParts> quarkusBuildCacheableAppParts = tasks.register(
QUARKUS_BUILD_APP_PARTS_TASK_NAME,
QuarkusBuildCacheableAppParts.class, task -> {
configureQuarkusBuildTask(project, quarkusExt, task, quarkusBuildAppModelTask);
configureQuarkusBuildTask(project, task, quarkusBuildAppModelTask, serviceProvider);
task.dependsOn(quarkusGenerateCode);
task.getOutputs().doNotCacheIf(
"Not adding uber-jars, native binaries and mutable-jar package type to Gradle " +
Expand All @@ -272,7 +272,7 @@ public boolean isSatisfiedBy(Task t) {
});

TaskProvider<QuarkusBuild> quarkusBuild = tasks.register(QUARKUS_BUILD_TASK_NAME, QuarkusBuild.class, build -> {
configureQuarkusBuildTask(project, quarkusExt, build, quarkusBuildAppModelTask);
configureQuarkusBuildTask(project, build, quarkusBuildAppModelTask, serviceProvider);
build.dependsOn(quarkusBuildDependencies, quarkusBuildCacheableAppParts);
build.getOutputs().doNotCacheIf(
"Only collects and combines the outputs of " + QUARKUS_BUILD_APP_PARTS_TASK_NAME + " and "
Expand All @@ -296,7 +296,7 @@ public boolean isSatisfiedBy(Task t) {

tasks.register(IMAGE_BUILD_TASK_NAME, ImageBuild.class, task -> {
task.dependsOn(quarkusRequiredExtension);
configureQuarkusBuildTask(project, quarkusExt, task, quarkusBuildAppModelTask);
configureQuarkusBuildTask(project, task, quarkusBuildAppModelTask, serviceProvider);
task.getBuilderName().set(quarkusRequiredExtension.flatMap(ImageCheckRequirementsTask::getOutputFile));
task.getOutputs().doNotCacheIf("Dependencies are never cached", t -> true);
task.getApplicationModel()
Expand All @@ -306,7 +306,7 @@ public boolean isSatisfiedBy(Task t) {

tasks.register(IMAGE_PUSH_TASK_NAME, ImagePush.class, task -> {
task.dependsOn(quarkusRequiredExtension);
configureQuarkusBuildTask(project, quarkusExt, task, quarkusBuildAppModelTask);
configureQuarkusBuildTask(project, task, quarkusBuildAppModelTask, serviceProvider);
task.getBuilderName().set(quarkusRequiredExtension.flatMap(ImageCheckRequirementsTask::getOutputFile));
task.getOutputs().doNotCacheIf("Dependencies are never cached", t -> true);
task.getApplicationModel()
Expand All @@ -315,7 +315,7 @@ public boolean isSatisfiedBy(Task t) {
});

tasks.register(DEPLOY_TASK_NAME, Deploy.class, task -> {
configureQuarkusBuildTask(project, quarkusExt, task, quarkusBuildAppModelTask);
configureQuarkusBuildTask(project, task, quarkusBuildAppModelTask, serviceProvider);
task.getOutputs().doNotCacheIf("Dependencies are never cached", t -> true);
task.getApplicationModel()
.set(quarkusGenerateAppModelTask.flatMap(QuarkusApplicationModelTask::getApplicationModel));
Expand All @@ -326,7 +326,7 @@ public boolean isSatisfiedBy(Task t) {
quarkusExt);
TaskProvider<QuarkusRun> quarkusRun = tasks.register(QUARKUS_RUN_TASK_NAME, QuarkusRun.class,
build -> {
configureQuarkusBuildTask(project, quarkusExt, build, quarkusBuildAppModelTask);
configureQuarkusBuildTask(project, build, quarkusBuildAppModelTask, serviceProvider);
build.getOutputs().doNotCacheIf("Dependencies are never cached", t -> true);
build.getApplicationModel()
.set(quarkusGenerateAppModelTask.flatMap(QuarkusApplicationModelTask::getApplicationModel));
Expand Down Expand Up @@ -527,10 +527,13 @@ private static void configureApplicationModelTask(Project project, QuarkusApplic
task.getApplicationModel().set(project.getLayout().getBuildDirectory().file(quarkusModelFile));
}

private static void configureQuarkusBuildTask(Project project, QuarkusPluginExtension quarkusExt, QuarkusBuildTask task,
TaskProvider<QuarkusApplicationModelTask> quarkusGenerateAppModelTask) {
private static void configureQuarkusBuildTask(Project project, QuarkusBuildTask task,
TaskProvider<QuarkusApplicationModelTask> quarkusGenerateAppModelTask,
Provider<ForcedPropertieBuildService> serviceProvider) {
task.getApplicationModel().set(quarkusGenerateAppModelTask.flatMap(QuarkusApplicationModelTask::getApplicationModel));
SourceSet mainSourceSet = getSourceSet(project, SourceSet.MAIN_SOURCE_SET_NAME);
task.getAdditionalForcedProperties().set(serviceProvider);
task.usesService(serviceProvider);
task.setCompileClasspath(mainSourceSet.getCompileClasspath().plus(mainSourceSet.getRuntimeClasspath())
.plus(mainSourceSet.getAnnotationProcessorPath())
.plus(mainSourceSet.getResources()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.logging.LogLevel;
import org.gradle.api.provider.Property;
import org.gradle.api.services.ServiceReference;
import org.gradle.api.tasks.Classpath;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFile;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.Nested;
import org.gradle.api.tasks.PathSensitive;
import org.gradle.api.tasks.PathSensitivity;
Expand Down Expand Up @@ -48,8 +48,8 @@ public abstract class QuarkusBuildTask extends QuarkusTask {
static final String NATIVE_SOURCES = "native-sources";
private final QuarkusPluginExtensionView extensionView;

@ServiceReference("forcedPropertiesService")
abstract Property<ForcedPropertieBuildService> getAdditionalForcedProperties();
@Internal
public abstract Property<ForcedPropertieBuildService> getAdditionalForcedProperties();

QuarkusBuildTask(String description, boolean compatible) {
super(description, compatible);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
allprojects {

group = "org.acme"
version = "1.0.0-SNAPSHOT"

repositories {
mavenLocal {
content {
includeGroupByRegex("io.quarkus.*")
includeGroup("org.hibernate.orm")
}
}
mavenCentral()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Gradle properties

quarkusPlatformArtifactId=quarkus-bom
quarkusPlatformGroupId=io.quarkus
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
`java-library`
id("io.quarkus")
id("com.github.ben-manes.versions") version "0.51.0"

}
val quarkusPlatformGroupId: String by project
val quarkusPlatformArtifactId: String by project
val quarkusPlatformVersion: String by project

dependencies {
implementation(enforcedPlatform("$quarkusPlatformGroupId:$quarkusPlatformArtifactId:$quarkusPlatformVersion"))
api("io.quarkus:quarkus-resteasy")
api("io.quarkus:quarkus-resteasy-jackson")
api("io.quarkus:quarkus-arc")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!build/*-runner
!build/*-runner.jar
!build/lib/*
!build/quarkus-app/*
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
plugins {
`java-library`
id("io.quarkus")
id("com.github.ben-manes.versions") version "0.51.0"
}
val quarkusPlatformGroupId: String by project
val quarkusPlatformArtifactId: String by project
val quarkusPlatformVersion: String by project

val javaVersion = "17"

dependencies {
implementation(enforcedPlatform("$quarkusPlatformGroupId:$quarkusPlatformArtifactId:$quarkusPlatformVersion"))
implementation(project(":modA"))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.acme;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

@Path("/hello")
public class GreetingResource {

@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "foo bar";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>code-with-quarkus - 1.0.0-SNAPSHOT</title>
<style>
h1, h2, h3, h4, h5, h6 {
margin-bottom: 0.5rem;
font-weight: 400;
line-height: 1.5;
}

h1 {
font-size: 2.5rem;
}

h2 {
font-size: 2rem
}

h3 {
font-size: 1.75rem

}

h4 {
font-size: 1.5rem
}

h5 {
font-size: 1.25rem
}

h6 {
font-size: 1rem
}

.lead {
font-weight: 300;
font-size: 2rem;
}

.banner {
font-size: 2.7rem;
margin: 0;
padding: 2rem 1rem;
background-color: #0d1c2c;
color: white;
}

body {
margin: 0;
font-family: -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}

code {
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: 87.5%;
color: #e83e8c;
word-break: break-word;
}

.left-column {
padding: .75rem;
max-width: 75%;
min-width: 55%;
}

.right-column {
padding: .75rem;
max-width: 25%;
}

.container {
display: flex;
width: 100%;
}

li {
margin: 0.75rem;
}

.right-section {
margin-left: 1rem;
padding-left: 0.5rem;
}

.right-section h3 {
padding-top: 0;
font-weight: 200;
}

.right-section ul {
border-left: 0.3rem solid #71aeef;
list-style-type: none;
padding-left: 0;
}

.example-code {
border-left: 0.3rem solid #71aeef;
padding-left: 10px;
}

.example-code h3 {
font-weight: 200;
}
</style>
</head>
<body>

<div class="banner lead">
Your new Cloud-Native application is ready!
</div>

<div class="container">
<div class="left-column">
<p class="lead"> Congratulations, you have created a new Quarkus cloud application.</p>

<h2>What is this page?</h2>

<p>This page is served by Quarkus. The source is in
<code>src/main/resources/META-INF/resources/index.html</code>.</p>

<h2>What are your next steps?</h2>

<p>If not already done, run the application in <em>dev mode</em> using: <code>./gradlew quarkusDev</code>.
</p>
<ul>
<li>Your static assets are located in <code>src/main/resources/META-INF/resources</code>.</li>
<li>Configure your application in <code>src/main/resources/application.properties</code>.</li>
<li>Quarkus now ships with a <a href="/q/dev/">Dev UI</a> (available in dev mode only)</li>
<li>Play with the getting started example code located in <code>src/main/java</code>:</li>
</ul>
<div class="example-code">
<h3>RESTEasy JAX-RS example</h3>
<p>REST is easy peasy with this Hello World RESTEasy resource.</p>
<p><code>@Path: <a href="/hello-resteasy" class="path-link" target="_blank">/hello-resteasy</a></code></p>
<p><a href="https://quarkus.io/guides/getting-started#the-jax-rs-resources" class="guide-link" target="_blank">Related guide section...</a></p>
</div>
<div class="example-code">
<h3>RESTEasy JSON serialisation using Jackson</h3>
<p>This example demonstrate RESTEasy JSON serialisation by letting you list, add and remove quark types from a list. Quarked!</p>
<p><code>@Path: <a href="/resteasy-jackson/quarks/" class="path-link" target="_blank">/resteasy-jackson/quarks/</a></code></p>
<p><a href="https://quarkus.io/guides/rest-json#creating-your-first-json-rest-service" class="guide-link" target="_blank">Related guide section...</a></p>
</div>

</div>
<div class="right-column">
<div class="right-section">
<h3>Application</h3>
<ul>
<li>GroupId: <code>org.acme</code></li>
<li>ArtifactId: <code>code-with-quarkus</code></li>
<li>Version: <code>1.0.0-SNAPSHOT</code></li>
<li>Quarkus Version: <code>1.12.2.Final</code></li>
</ul>
</div>
<div class="right-section">
<h3>Do you like Quarkus?</h3>
<ul>
<li>Go give it a star on <a href="https://github.com/quarkusio/quarkus">GitHub</a>.</li>
</ul>
</div>
<div class="right-section">
<h3>Selected extensions guides</h3>
<ul>
<li title="REST endpoint framework implementing JAX-RS and more"><a href="https://quarkus.io/guides/rest-json" target="_blank">RESTEasy JAX-RS guide</a></li>
</ul>
</div>
<div class="right-section">
<h3>More reading</h3>
<ul>
<li><a href="https://quarkus.io/guides/gradle-tooling" target="_blank">Setup your IDE</a></li>
<li><a href="https://quarkus.io/guides/getting-started" target="_blank">Getting started</a></li>
<li><a href="https://quarkus.io/guides/" target="_blank">All guides</a></li>
<li><a href="https://quarkus.io" target="_blank">Quarkus Web Site</a></li>
</ul>
</div>
</div>
</div>
</body>
</html>
Loading
Loading