From 5e90a1bc1b254e90a6f8afcb6d55926724d3e8ee Mon Sep 17 00:00:00 2001 From: "David M. Lloyd" Date: Tue, 25 Jun 2024 07:51:33 -0500 Subject: [PATCH] Make sure Gradle cache is not confused by maps Fixes #41404 --- .../src/main/java/io/quarkus/gradle/tasks/BaseConfig.java | 5 ++++- .../java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/BaseConfig.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/BaseConfig.java index 5ea1afc05997c..e9afdb7ca7d0b 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/BaseConfig.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/BaseConfig.java @@ -2,6 +2,7 @@ import java.util.List; import java.util.Map; +import java.util.TreeMap; import java.util.function.Predicate; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -60,6 +61,8 @@ Map cachingRelevantProperties(List propertyPatterns) { Predicate> keyPredicate = e -> patterns.stream().anyMatch(p -> p.matcher(e.getKey()).matches()); return values.entrySet().stream() .filter(keyPredicate) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (s, s2) -> { + throw new IllegalArgumentException("Duplicate key"); + }, TreeMap::new)); } } diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java index 1b1cc049c8bd5..f3b5a930bb51a 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java @@ -3,9 +3,11 @@ import java.io.File; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Collections; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.TreeMap; import java.util.stream.Collectors; import javax.inject.Inject; @@ -76,7 +78,8 @@ Map getInternalTaskConfig() { // an input to the cache key. We need to declare these properties as inputs, because those influence the // execution. // Documented here: https://docs.gradle.org/current/userguide/build_cache.html#sec:task_output_caching_inputs - return Map.of("launchMode", launchMode.name(), "inputSourceSetName", inputSourceSetName); + return Collections.unmodifiableMap( + new TreeMap<>(Map.of("launchMode", launchMode.name(), "inputSourceSetName", inputSourceSetName))); } @InputFiles