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

NullPointerException in QuarkusPluginExtension.beforeTest with Configuration Cache Enabled #46682

Open
shreyasahir opened this issue Mar 10, 2025 · 3 comments
Labels
area/gradle Gradle kind/bug Something isn't working triage/needs-feedback We are waiting for feedback.

Comments

@shreyasahir
Copy link

Describe the bug

When running tests with the Quarkus Gradle plugin and Gradle’s configuration cache enabled, a NullPointerException occurs because the project field in io.quarkus.gradle.extension.QuarkusPluginExtension is null. This happens during the beforeTest method, which attempts to build an application model via ApplicationDeploymentClasspathBuilder, calling project.getPath() on a null project reference. The issue persists even when marking Quarkus tasks (except :test) as notCompatibleWithConfigurationCache, suggesting a deeper initialization problem in the plugin’s test setup.

Expected behavior

Test should run when org.gradle.configuration-cache=true

Actual behavior

This breaks test execution (e.g., ./gradlew :shopper-profile-api-controller:test), preventing JUnit 5/Kotest tests from running. Disabling the configuration cache (org.gradle.configuration-cache=false) resolves the issue, but we’d like to use the cache for build performance (targeting <20-30s Configuration time). Updating the Quarkus plugin version or tweaking test properties (e.g., quarkus.test.native-image=false) didn’t help.

How to Reproduce?

Steps to Reproduce:

  • Use a multi-module Gradle project with Quarkus, Kotlin, and JUnit 5/Kotest.
  • Enable org.gradle.configuration-cache=true in gradle.properties.
  • Configure a simple failing test (e.g., assertEquals(1, 2)).
  • Run ./gradlew :shopper-profile-api-controller:test --configuration-cache --info --stacktrace.
  • Observe the NPE.

Output of uname -a or ver

Darwin LM-SJN-40042039 23.6.0 Darwin Kernel Version 23.6.0: Thu Dec 19 20:47:16 PST 2024; root:xnu-10063.141.1.703.2~1/RELEASE_ARM64_T6031 arm64

Output of java -version

JVM 21

Quarkus version or git rev

3.16.4

Build tool (ie. output of mvnw --version or gradlew --version)

gradle 8.11.1

Additional information

Caused by: java.lang.NullPointerException: Cannot invoke "org.gradle.api.Project.getPath()" because "project" is null
at io.quarkus.gradle.dependency.ApplicationDeploymentClasspathBuilder.(ApplicationDeploymentClasspathBuilder.java:151)
at io.quarkus.gradle.tooling.GradleApplicationModelBuilder.buildAll(GradleApplicationModelBuilder.java:102)
at io.quarkus.gradle.tooling.ToolingUtils.create(ToolingUtils.java:186)
at io.quarkus.gradle.tooling.ToolingUtils.create(ToolingUtils.java:182)
at io.quarkus.gradle.extension.QuarkusPluginExtension.getApplicationModel(QuarkusPluginExtension.java:198)
at io.quarkus.gradle.extension.QuarkusPluginExtension.beforeTest(QuarkusPluginExtension.java:75)

@shreyasahir shreyasahir added the kind/bug Something isn't working label Mar 10, 2025
Copy link

quarkus-bot bot commented Mar 10, 2025

/cc @geoand (kotlin), @gwenneg (cache), @radcortez (config)

@geoand
Copy link
Contributor

geoand commented Mar 10, 2025

cc @quarkusio/devtools

@aloubyansky
Copy link
Member

I'm wondering whether the following would fix it

diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java
index cbf5e6e62e..d9b8f13fb1 100644
--- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java
+++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java
@@ -72,7 +72,7 @@ public void manifest(Action<Manifest> action) {
     public void beforeTest(Test task) {
         try {
             Map<String, Object> props = task.getSystemProperties();
-            ApplicationModel appModel = getApplicationModel(TEST);
+            ApplicationModel appModel = ToolingUtils.create(task.getProject(), TEST);

@shreyasahir is there a chance you could test that or provide a reproducer for me to test? Thanks.

@geoand geoand added the triage/needs-feedback We are waiting for feedback. label Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/gradle Gradle kind/bug Something isn't working triage/needs-feedback We are waiting for feedback.
Projects
None yet
Development

No branches or pull requests

3 participants