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

Gradle builds include values from .env, which override defaults in application.properties, outlasting non-clean rebuilds. #34869

Closed
Foobartender opened this issue Jul 20, 2023 · 3 comments · Fixed by #35003
Labels
area/config area/gradle Gradle kind/bug Something isn't working
Milestone

Comments

@Foobartender
Copy link
Contributor

Describe the bug

Consider having an application.properties file like this:

greeting.message=${FOO_MESSAGE:Hello!}

...and a .env file like this:

FOO_MESSAGE=Hi!

Expected behavior

Building the project while having the .env file in its root directory doesn't affect the default value provided in application.properties. Actually, it shouldn't affect the build output at all.

Regarding the example project, its endpoint should return "Hello!", unless there is an .env file with a value overriding it in its working directory,

Actual behavior

A clean build uses the value from .env as default. Subsequent builds keep that value even if .env is updated. After cleaning and rebuilding, the updated value from .env is used.

How to Reproduce?

An example project using Gradle (Kotlin) with a ConfigMapping and a RESTEasy endpoint returning greeting.message is provided.
Build, copy build output to a another directory and cd into it (to get the .env file out of the way), run, check output, modify, repeat, clean, repeat... as necessary to reproduce the described actual behavior.

quarkus-dotenv.tar.gz

Output of uname -a or ver

Linux ***** 6.4.3-arch1-2 #1 SMP PREEMPT_DYNAMIC Sat, 15 Jul 2023 19:25:49 +0000 x86_64 GNU/Linux

Output of java -version

openjdk version "17.0.7" 2023-04-18 OpenJDK Runtime Environment GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12) OpenJDK 64-Bit Server VM GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

3.2.1.Final

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

Gradle 8.1.1

Additional information

Bug was introduced sometime between 2.6.x and 3.2.0.

@Foobartender Foobartender added the kind/bug Something isn't working label Jul 20, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Jul 20, 2023

/cc @evanchooly (kotlin), @geoand (kotlin), @glefloch, @quarkusio/devtools

@gsmet
Copy link
Member

gsmet commented Jul 20, 2023

@snazy I wonder if it's an issue specific to Gradle or if it's something that is config-related. Any clue?

@snazy
Copy link
Contributor

snazy commented Jul 25, 2023

It's probably the new mechanism to fetch the config. Let me take a look.

snazy added a commit to snazy/quarkus that referenced this issue Jul 25, 2023
…erties

Currently the Gradle plugin considers only system properties starting with `quarkus.` (and env vars starting with `QUARKUS_`) as relevant for Gradle's cache key. This is on purpose to not cause unnecessary rebuilds, because especially system properties can contain entries that are rather "random-ish". But other environment variables or system properties cannot be specified as "relevant".

This change introduces a new list-property `cachingRelevantProperties` on the Quarkus Gradle extension object to tell the Quarkus Gradle plugin to consider the specified properties/env-vars as input(s) for the tasks. This list-property accepts regex patterns, and by default contains `quarkus[.].*`, matching the current `.startsWith("quarkus.")`.

Fixes quarkusio#34869
snazy added a commit to snazy/quarkus that referenced this issue Jul 25, 2023
…erties

Currently the Gradle plugin considers only system properties starting with `quarkus.` (and env vars starting with `QUARKUS_`) as relevant for Gradle's cache key. This is on purpose to not cause unnecessary rebuilds, because especially system properties can contain entries that are rather "random-ish". But other environment variables or system properties cannot be specified as "relevant".

This change introduces a new list-property `cachingRelevantProperties` on the Quarkus Gradle extension object to tell the Quarkus Gradle plugin to consider the specified properties/env-vars as input(s) for the tasks. This list-property accepts regex patterns, and by default contains `quarkus[.].*`, matching the current `.startsWith("quarkus.")`.

Fixes quarkusio#34869
snazy added a commit to snazy/quarkus that referenced this issue Jul 25, 2023
…erties

Currently the Gradle plugin considers only system properties starting with `quarkus.` (and env vars starting with `QUARKUS_`) as relevant for Gradle's cache key. This is on purpose to not cause unnecessary rebuilds, because especially system properties can contain entries that are rather "random-ish". But other environment variables or system properties cannot be specified as "relevant".

This change introduces a new list-property `cachingRelevantProperties` on the Quarkus Gradle extension object to tell the Quarkus Gradle plugin to consider the specified properties/env-vars as input(s) for the tasks. This list-property accepts regex patterns, and by default contains `quarkus[.].*`, matching the current `.startsWith("quarkus.")`.

Fixes quarkusio#34869
snazy added a commit to snazy/quarkus that referenced this issue Jul 26, 2023
…erties

Currently the Gradle plugin considers only system properties starting with `quarkus.` (and env vars starting with `QUARKUS_`) as relevant for Gradle's cache key. This is on purpose to not cause unnecessary rebuilds, because especially system properties can contain entries that are rather "random-ish". But other environment variables or system properties cannot be specified as "relevant".

This change introduces a new list-property `cachingRelevantProperties` on the Quarkus Gradle extension object to tell the Quarkus Gradle plugin to consider the specified properties/env-vars as input(s) for the tasks. This list-property accepts regex patterns, and by default contains `quarkus[.].*`, matching the current `.startsWith("quarkus.")`.

Fixes quarkusio#34869
@quarkus-bot quarkus-bot bot added this to the 3.4 - main milestone Aug 23, 2023
@gsmet gsmet modified the milestones: 3.4 - main, 3.3.1 Aug 26, 2023
gsmet pushed a commit to gsmet/quarkus that referenced this issue Aug 26, 2023
…erties

Currently the Gradle plugin considers only system properties starting with `quarkus.` (and env vars starting with `QUARKUS_`) as relevant for Gradle's cache key. This is on purpose to not cause unnecessary rebuilds, because especially system properties can contain entries that are rather "random-ish". But other environment variables or system properties cannot be specified as "relevant".

This change introduces a new list-property `cachingRelevantProperties` on the Quarkus Gradle extension object to tell the Quarkus Gradle plugin to consider the specified properties/env-vars as input(s) for the tasks. This list-property accepts regex patterns, and by default contains `quarkus[.].*`, matching the current `.startsWith("quarkus.")`.

Fixes quarkusio#34869

(cherry picked from commit 44b76fa)
gsmet pushed a commit to gsmet/quarkus that referenced this issue Aug 26, 2023
…erties

Currently the Gradle plugin considers only system properties starting with `quarkus.` (and env vars starting with `QUARKUS_`) as relevant for Gradle's cache key. This is on purpose to not cause unnecessary rebuilds, because especially system properties can contain entries that are rather "random-ish". But other environment variables or system properties cannot be specified as "relevant".

This change introduces a new list-property `cachingRelevantProperties` on the Quarkus Gradle extension object to tell the Quarkus Gradle plugin to consider the specified properties/env-vars as input(s) for the tasks. This list-property accepts regex patterns, and by default contains `quarkus[.].*`, matching the current `.startsWith("quarkus.")`.

Fixes quarkusio#34869

(cherry picked from commit 44b76fa)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config area/gradle Gradle kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants