This is an automated email from the ASF dual-hosted git repository. ddekany pushed a commit to branch 2.3-gae in repository https://gitbox.apache.org/repos/asf/freemarker.git
commit 1c465db5b9fcb20bb625bf8ff74333821810f3e8 Author: ddekany <ddek...@apache.org> AuthorDate: Mon Dec 25 18:08:18 2023 +0100 Build: Map camel case configuration names to dashed directory names. (So when we will have "javaxServlet", that will be mapped to "freemarker-javax-servlet", rather than to "freemarker-javaxServlet".) --- .../freemarker/build/FreemarkerRootExtension.kt | 4 ++-- .../freemarker/build/FreemarkerStringExtensions.kt | 25 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/freemarker/build/FreemarkerRootExtension.kt b/buildSrc/src/main/kotlin/freemarker/build/FreemarkerRootExtension.kt index 6683f0a2..dfdd9b3d 100644 --- a/buildSrc/src/main/kotlin/freemarker/build/FreemarkerRootExtension.kt +++ b/buildSrc/src/main/kotlin/freemarker/build/FreemarkerRootExtension.kt @@ -19,7 +19,6 @@ package freemarker.build -import java.util.concurrent.atomic.AtomicBoolean import org.gradle.api.NamedDomainObjectProvider import org.gradle.api.Project import org.gradle.api.artifacts.VersionCatalogsExtension @@ -42,6 +41,7 @@ import org.gradle.kotlin.dsl.the import org.gradle.language.base.plugins.LifecycleBasePlugin import org.gradle.language.jvm.tasks.ProcessResources import org.gradle.testing.base.TestingExtension +import java.util.concurrent.atomic.AtomicBoolean private const val TEST_UTILS_SOURCE_SET_NAME = "test-utils" @@ -94,7 +94,7 @@ class FreemarkerModuleDef internal constructor( val compilerVersion: JavaLanguageVersion ) { val main = sourceSetName == SourceSet.MAIN_SOURCE_SET_NAME - val baseDirName = if (main) "core" else sourceSetName + val baseDirName = if (main) "core" else sourceSetName.camelCaseToDashed() val sourceSet = context.sourceSets.maybeCreate(sourceSetName) diff --git a/buildSrc/src/main/kotlin/freemarker/build/FreemarkerStringExtensions.kt b/buildSrc/src/main/kotlin/freemarker/build/FreemarkerStringExtensions.kt new file mode 100644 index 00000000..b2907602 --- /dev/null +++ b/buildSrc/src/main/kotlin/freemarker/build/FreemarkerStringExtensions.kt @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package freemarker.build + +private val CAMEL_HUMP = "(?<=[A-Za-z0-9])[A-Z]".toRegex() + +fun String.camelCaseToDashed(): String = + replace(CAMEL_HUMP) { "-" + it.value.replaceFirstChar(Char::lowercaseChar) }