From 647a3d5f9c1e10a1ff90c6dc1370a2802a25e050 Mon Sep 17 00:00:00 2001 From: Alexey Loubyansky Date: Mon, 15 Jul 2024 18:10:36 +0200 Subject: [PATCH] Use quarkusConditional prefix for Quarkus conditional dependency configurations --- .../ConditionalDependenciesEnabler.java | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ConditionalDependenciesEnabler.java b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ConditionalDependenciesEnabler.java index c090d3b1701a7..4c0bc2fdee5ab 100644 --- a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ConditionalDependenciesEnabler.java +++ b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ConditionalDependenciesEnabler.java @@ -170,8 +170,7 @@ private void queueConditionalDependency(ExtensionDependency extension, Depend private Configuration createConditionalDependenciesConfiguration(Project project, Dependency conditionalDep) { // previously we used a detached configuration here but apparently extendsFrom(enforcedPlatforms) // wouldn't actually enforce platforms on a detached configuration - final String name = conditionalDep.getGroup() + ":" + conditionalDep.getName() + ":" + conditionalDep.getVersion() - + "Configuration"; + var name = getConditionalConfigurationName(conditionalDep); var config = project.getConfigurations().findByName(name); if (config == null) { project.getConfigurations().register(name, configuration -> { @@ -184,6 +183,31 @@ private Configuration createConditionalDependenciesConfiguration(Project project return config; } + private static String getConditionalConfigurationName(Dependency conditionalDep) { + var name = new StringBuilder().append("quarkusConditional"); + appendCapitalized(name, conditionalDep.getGroup()); + appendCapitalized(name, conditionalDep.getName()); + appendCapitalized(name, conditionalDep.getVersion()); + return name.append("Configuration").toString(); + } + + private static void appendCapitalized(StringBuilder sb, String part) { + if (part != null && !part.isEmpty()) { + boolean toUpperCase = true; + for (int i = 0; i < part.length(); ++i) { + var c = part.charAt(i); + if (toUpperCase) { + sb.append(Character.toUpperCase(c)); + toUpperCase = false; + } else if (c == '.' || c == '-') { + toUpperCase = true; + } else { + sb.append(c); + } + } + } + } + private void enableConditionalDependency(ModuleVersionIdentifier dependency) { final Set> extensions = featureVariants.remove(getFeatureKey(dependency)); if (extensions == null) {