diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java index 41f376657d05d..15d58e6c94f71 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java @@ -519,14 +519,12 @@ private static void configureApplicationModelTask(Project project, QuarkusApplic task.getProjectDescriptor().set(projectDescriptor); task.getLaunchMode().set(launchMode); task.getOriginalClasspath().setFrom(classpath.getOriginalRuntimeClasspathAsInput()); - task.getAppClasspath().configureFrom(classpath.getRuntimeConfiguration()); + task.getAppClasspath().configureFrom(classpath.getRuntimeConfigurationWithoutResolvingDeployment()); task.getPlatformConfiguration().configureFrom(classpath.getPlatformConfiguration()); task.getDeploymentClasspath().configureFrom(classpath.getDeploymentConfiguration()); - task.getPlatformImportProperties().set(classpath.getPlatformImports().getPlatformProperties()); - task.getApplicationModel().set( - project.getLayout().getBuildDirectory() - .file(quarkusModelFile)); - + task.getDeploymentResolvedWorkaround().from(classpath.getDeploymentConfiguration().getIncoming().getFiles()); + task.getPlatformImportProperties().set(classpath.getPlatformImportsWithoutResolvingPlatform().getPlatformProperties()); + task.getApplicationModel().set(project.getLayout().getBuildDirectory().file(quarkusModelFile)); } private static void configureQuarkusBuildTask(Project project, QuarkusPluginExtension quarkusExt, QuarkusBuildTask task, diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusApplicationModelTask.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusApplicationModelTask.java index 3fc1afa5533e1..0532cddf38cf4 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusApplicationModelTask.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusApplicationModelTask.java @@ -48,6 +48,7 @@ import org.gradle.api.provider.Property; import org.gradle.api.tasks.CompileClasspath; import org.gradle.api.tasks.Input; +import org.gradle.api.tasks.InputFiles; import org.gradle.api.tasks.Internal; import org.gradle.api.tasks.Nested; import org.gradle.api.tasks.OutputFile; @@ -107,6 +108,9 @@ public abstract class QuarkusApplicationModelTask extends DefaultTask { @CompileClasspath public abstract ConfigurableFileCollection getOriginalClasspath(); + @InputFiles + public abstract ConfigurableFileCollection getDeploymentResolvedWorkaround(); + @Nested public abstract QuarkusResolvedClasspath getPlatformConfiguration(); diff --git a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ApplicationDeploymentClasspathBuilder.java b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ApplicationDeploymentClasspathBuilder.java index ec5fb1bf5f1e8..70c195738f6bd 100644 --- a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ApplicationDeploymentClasspathBuilder.java +++ b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ApplicationDeploymentClasspathBuilder.java @@ -288,6 +288,10 @@ public Configuration getRuntimeConfiguration() { return project.getConfigurations().getByName(this.runtimeConfigurationName); } + public Configuration getRuntimeConfigurationWithoutResolvingDeployment() { + return project.getConfigurations().getByName(this.runtimeConfigurationName); + } + public Configuration getDeploymentConfiguration() { return project.getConfigurations().getByName(this.deploymentConfigurationName); } @@ -308,6 +312,10 @@ public PlatformImports getPlatformImports() { return platformImports.get(this.platformImportName); } + public PlatformImports getPlatformImportsWithoutResolvingPlatform() { + return platformImports.get(this.platformImportName); + } + private Set> collectFirstMetQuarkusExtensions(Configuration configuration, Collection> knownExtensions) { diff --git a/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/build.gradle.kts b/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/build.gradle.kts new file mode 100644 index 0000000000000..adc10c534b09f --- /dev/null +++ b/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/build.gradle.kts @@ -0,0 +1,31 @@ +plugins { + java + id("io.quarkus") +} + +repositories { + mavenCentral() + mavenLocal() +} + + +dependencies { + implementation("io.quarkus:quarkus-rest") + implementation("io.quarkus:quarkus-arc") + implementation(enforcedPlatform(project(":library"))) + testImplementation("io.quarkus:quarkus-junit5") + testImplementation("io.rest-assured:rest-assured") +} + +group = "org.acme" +version = "1.0.0-SNAPSHOT" + +tasks.withType { + systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager") +} +tasks.withType { + options.encoding = "UTF-8" + options.compilerArgs.add("-parameters") +} + +tasks.all{} diff --git a/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/gradle.properties b/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/gradle.properties new file mode 100644 index 0000000000000..f15a724431c33 --- /dev/null +++ b/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/gradle.properties @@ -0,0 +1,3 @@ +quarkusPlatformArtifactId=quarkus-bom +quarkusPlatformGroupId=io.quarkus +kotlinVersion=${kotlin.version} diff --git a/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/library/build.gradle.kts b/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/library/build.gradle.kts new file mode 100644 index 0000000000000..28d6576a01232 --- /dev/null +++ b/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/library/build.gradle.kts @@ -0,0 +1,15 @@ +plugins { + `java-platform` +} + +val quarkusPlatformGroupId: String by project +val quarkusPlatformArtifactId: String by project +val quarkusPlatformVersion: String by project + +javaPlatform.allowDependencies() +dependencies{ + api(enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")) + constraints{ + api("org.assertj:assertj-core:3.26.3") + } +} diff --git a/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/settings.gradle b/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/settings.gradle new file mode 100644 index 0000000000000..2ab26cc990ee6 --- /dev/null +++ b/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/settings.gradle @@ -0,0 +1,19 @@ +pluginManagement { + repositories { + mavenLocal { + content { + includeGroupByRegex 'io.quarkus.*' + includeGroup 'org.hibernate.orm' + } + } + mavenCentral() + gradlePluginPortal() + } + plugins { + id 'io.quarkus' version "${quarkusPluginVersion}" + id 'org.jetbrains.kotlin.jvm' version "${kotlinVersion}" + id 'org.jetbrains.kotlin.plugin.allopen' version "${kotlinVersion}" + } +} +rootProject.name='java-platform-with-eager-resolution-project' +include(":library") diff --git a/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/src/main/java/org/acme/GreetingResource.java b/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/src/main/java/org/acme/GreetingResource.java new file mode 100644 index 0000000000000..244f294265375 --- /dev/null +++ b/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/src/main/java/org/acme/GreetingResource.java @@ -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 "Hello from Quarkus REST"; + } +} diff --git a/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/src/main/resources/application.properties b/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/src/main/resources/application.properties new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/src/native-test/java/org/acme/GreetingResourceIT.java b/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/src/native-test/java/org/acme/GreetingResourceIT.java new file mode 100644 index 0000000000000..cfa9d1b1aff2b --- /dev/null +++ b/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/src/native-test/java/org/acme/GreetingResourceIT.java @@ -0,0 +1,8 @@ +package org.acme; + +import io.quarkus.test.junit.QuarkusIntegrationTest; + +@QuarkusIntegrationTest +class GreetingResourceIT extends GreetingResourceTest { + // Execute the same tests but in packaged mode. +} diff --git a/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/src/test/java/org/acme/GreetingResourceTest.java b/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/src/test/java/org/acme/GreetingResourceTest.java new file mode 100644 index 0000000000000..18332e4c7ad2f --- /dev/null +++ b/integration-tests/gradle/src/main/resources/java-platform-with-eager-resolution-project/src/test/java/org/acme/GreetingResourceTest.java @@ -0,0 +1,20 @@ +package org.acme; + +import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.Test; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.is; + +@QuarkusTest +class GreetingResourceTest { + @Test + void testHelloEndpoint() { + given() + .when().get("/hello") + .then() + .statusCode(200) + .body(is("Hello from Quarkus REST")); + } + +} \ No newline at end of file diff --git a/integration-tests/gradle/src/test/java/io/quarkus/gradle/JavaPlatformWithEagerResolutionTest.java b/integration-tests/gradle/src/test/java/io/quarkus/gradle/JavaPlatformWithEagerResolutionTest.java new file mode 100644 index 0000000000000..3d85446455867 --- /dev/null +++ b/integration-tests/gradle/src/test/java/io/quarkus/gradle/JavaPlatformWithEagerResolutionTest.java @@ -0,0 +1,26 @@ +package io.quarkus.gradle; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Path; + +import org.junit.jupiter.api.Test; + +public class JavaPlatformWithEagerResolutionTest extends QuarkusGradleWrapperTestBase { + + @Test + public void shouldImportConditionalDependency() throws IOException, URISyntaxException, InterruptedException { + + final File projectDir = getProjectDir("java-platform-with-eager-resolution-project"); + + runGradleWrapper(projectDir, "clean", ":quarkusBuild"); + + final File buildDir = new File(projectDir, "build"); + + final Path quarkusOutput = buildDir.toPath().resolve("quarkus-app"); + assertThat(quarkusOutput.resolve("quarkus-run.jar")).exists(); + } +}