quarkus: quarkus-jacoco problem evaluating gradle project property

Describe the bug

I just added the testImplementation "io.quarkus:quarkus-jacoco" to my build.gradle to have sweet coverage reports.

I have a settings.gradle that contains this : pluginManagement { repositories { mavenCentral { credentials { username nexusUser password nexusPassword } url = nexusGradlePluginPortalRepoUrl } } plugins { id 'io.quarkus' version "${quarkusPluginVersion}" } }

I run my tests using : ./gradlew -PnexusUser=someUser -PnexusPassword=somePassword -test

And the task consistently fails with : Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'nexusUser' for Credentials [username: null] of type org.gradle.internal.credentials.DefaultPasswordCredentials_Decorated. .... Caused by: org.gradle.internal.exceptions.LocationAwareException: Settings file '/path/to/settings.gradle' line: 5

Whereas it has always worked without this quarkus-jacoco dependency.

I also found out that when I hardcode this nexusUser=someUser nexusPassword=somePassword in my `gradle.properties’ file it finally works.

Which surprises me, is there something I did not understand correctly or is this a bug ? I’m not quite sure.

Expected behavior

Should work the same whether the project properties are passed as argument to the ./gradlew -P command or hardcoded in the gradle.properties file

Actual behavior

Project properties passed as parameter do not seem to be evaluated by the quarkus-jacoco plugin

How to Reproduce?

No response

Output of uname -a or ver

Linux 5854622b2b25 5.11.0-37-generic #41~20.04.2-Ubuntu SMP Fri Sep 24 09:06:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version “11.0.12” 2021-07-20 OpenJDK Runtime Environment Temurin-11.0.12+7 (build 11.0.12+7) OpenJDK 64-Bit Server VM Temurin-11.0.12+7 (build 11.0.12+7, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

quarkusPlatformVersion=2.3.0.Final

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

------------------------------------------------------------ Gradle 7.2 ------------------------------------------------------------ Build time: 2021-08-17 09:59:03 UTC Revision: a773786b58bb28710e3dc96c4d1a7063628952ad Kotlin: 1.5.21 Groovy: 3.0.8 Ant: Apache Ant™ version 1.10.9 compiled on September 27 2020 JVM: 11.0.12 (Eclipse Foundation 11.0.12+7) OS: Linux 5.11.0-37-generic amd64

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (14 by maintainers)

Most upvoted comments

I’ve just done a bit more digging into what quarkus-jacoco does.

As part of JacocoProcessor when it’s building an ApplicationModel. https://github.com/quarkusio/quarkus/blob/2.13.2.Final/test-framework/jacoco/deployment/src/main/java/io/quarkus/jacoco/deployment/JacocoProcessor.java#L114

https://github.com/quarkusio/quarkus/blob/e249b500169b9782d12a92c713e97bc7d744442c/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/utils/BuildToolHelper.java#L123

A gradle connector is initialised: https://github.com/quarkusio/quarkus/blob/e249b500169b9782d12a92c713e97bc7d744442c/independent-projects/bootstrap/gradle-resolver/src/main/java/io/quarkus/bootstrap/resolver/QuarkusGradleModelFactory.java#L28

By default if the connector does not specify useGradleUserHomeDir then ~/.gradle is set as default: https://docs.gradle.org/current/javadoc/org/gradle/tooling/GradleConnector.html#useGradleUserHomeDir-java.io.File-

This is the likely reason behind why the issue cannot be reproduced locally but can against CI agents if GRADLE_USER_HOME is anything but ~/.gradle. Would a fix against QuarkusGradleModelFactory to detect if GRADLE_USER_HOME has been set, and adding it if it has resolve this issue?