Skip to content

[Build] Fix more gradle deprecation warnings scheduled to be removed in 9.0 #14783

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

Merged
merged 3 commits into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ def resources = rootProject.file("gradle/regenerate/icu")
* download and compile a matching icu4c version automatically.
*/

// Configure different icu4j dependencies.
configure(rootProject) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declaring a configuration in one project and use it in another as done here before was one. of those things that had been technically possible forever, never recommended and now been deprecated. A good example of the problem with the historical approach in Gradle that in build logic there hasn't been any boundaries accross projects and the whole global model has been available from everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this plugin is a good example of something that can benefit from been ported into a binary plugin and only keep its actual implementation in this convention plugin rather all the nitty bits of implementation details.

configurations {

def setupIcuDependencies = { proj ->
// Configure different icu4j dependencies.
proj.configurations {
icu_current
groovy
}

dependencies {
proj.dependencies {
icu_current deps.icu4j
// Use a newer groovy that doesn't have illegal reflective accesses.
groovy deps.groovy
Expand All @@ -47,10 +48,11 @@ configure(rootProject) {
// This retrieves the module name/ version for ICU from the given
// configuration (if present).
def icuVersionFromConfiguration(Configuration configuration) {
return configuration.resolvedConfiguration.getFirstLevelModuleDependencies({ dep -> dep.group.startsWith("com.ibm.icu") }).collect { dep -> dep.module.id }.join(", ")
return configuration.resolvedConfiguration.getFirstLevelModuleDependencies().findAll { dep -> dep.moduleGroup.startsWith("com.ibm.icu") }.collect { dep -> dep.module.id }.join(", ")
}

configure(project(":lucene:analysis:icu")) {
setupIcuDependencies(project)
def utr30DataDir = file("src/data/utr30")

def icuBuildDir = file("${buildDir}/icu")
Expand All @@ -74,7 +76,7 @@ configure(project(":lucene:analysis:icu")) {
def icuCompileTask = Os.isFamily(Os.FAMILY_WINDOWS) ? "compileIcuWindows" : "compileIcuLinux"

task genUtr30DataFilesInternal() {
def icuConfig = rootProject.configurations.icu_current
def icuConfig = configurations.icu_current

dependsOn icuConfig
dependsOn icuCompileTask
Expand Down Expand Up @@ -127,7 +129,7 @@ configure(project(":lucene:analysis:icu")) {
}

task genRbbiInternal() {
def icuConfig = rootProject.configurations.icu_current
def icuConfig = configurations.icu_current

dependsOn icuConfig

Expand Down Expand Up @@ -251,8 +253,11 @@ configure(project(":lucene:analysis:icu")) {

// Regenerates UnicodeProps.java
configure(project(":lucene:analysis:common")) {
setupIcuDependencies(project)
task generateUnicodePropsInternal() {
def icuConfig = rootProject.configurations.icu_current
def icuConfig = configurations.icu_current
def groovyConfig = configurations.groovy

def outputFile = file("src/java/org/apache/lucene/analysis/util/UnicodeProps.java")

description = "Regenerate ${outputFile} (with ${icuConfig.name})"
Expand All @@ -266,7 +271,7 @@ configure(project(":lucene:analysis:common")) {
doFirst {
project.javaexec {
main "groovy.lang.GroovyShell"
classpath icuConfig, rootProject.configurations.groovy
classpath icuConfig, groovyConfig

args = [
"--encoding",
Expand All @@ -289,8 +294,10 @@ configure(project(":lucene:analysis:common")) {

// Regenerates CaseFolding.java
configure(project(":lucene:core")) {
setupIcuDependencies(project)
task generateUnicodePropsInternal() {
def icuConfig = rootProject.configurations.icu_current
def icuConfig = configurations.icu_current
def groovyConfig = configurations.groovy
def outputFile = file("src/java/org/apache/lucene/util/automaton/CaseFolding.java")

description = "Regenerate ${outputFile} (with ${icuConfig.name})"
Expand All @@ -304,7 +311,7 @@ configure(project(":lucene:core")) {
doFirst {
project.javaexec {
main "groovy.lang.GroovyShell"
classpath icuConfig, rootProject.configurations.groovy
classpath icuConfig, groovyConfig

args = [
"--encoding",
Expand Down
5 changes: 3 additions & 2 deletions lucene/distribution/binary-release.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ configure(project(":lucene:distribution")) {

task assembleBinaryDirForTests(type: Sync) {
description = "Assemble a subset of the binary Lucene distribution as an expanded directory for tests."

destinationDir = file("${packageBaseName}-itests")
}

Expand All @@ -97,7 +96,9 @@ configure(project(":lucene:distribution")) {
Closure<Void> distributionBinaryContent = { AbstractCopyTask task ->
// Manually correct posix permissions (matters when assembling archives on Windows).
filesMatching(["**/*.sh", "**/*.bat"]) { copy ->
copy.setMode(0755)
copy.permissions {
unix("755")
}
}

// Attach binary release - only files.
Expand Down