Skip to content

Commit da26d61

Browse files
authored
Fix deprecated Gradle syntax and configuration features (#3358)
When running `./gradlew shadowJar compileTestJava --warning-mode=all` on the current HEAD of `main` (68f805a), a number of warnings are produced for deprecated usages of Gradle configuration features. Upon fixing the trivial deprecations produced in the first pass, a second round of issues is also produced. This pull request fixes all of those, such that the command executes cleanly, without generating a Gradle problem report. Each class of issue is addressed in a separate commit (which contains links to the Gradle documentation showing the fix mechanism to be the recommended approach), but broadly speaking there are five categories: 1. Use of `destination` instead of `outputLocation` when configuring JUnit report output location ([docs](https://docs.gradle.org/8.13/dsl/org.gradle.api.reporting.Report.html#org.gradle.api.reporting.Report:destination)) 2. Consistent use of `key = value` assignment rather than "space assignment" or `propertyName(value)` assignment ([docs](https://docs.gradle.org/8.13/userguide/upgrading_version_8.html#groovy_space_assignment_syntax)) 3. Use of plugin blocks instead of conventions for the `Java` plugin ([docs](https://docs.gradle.org/8.13/userguide/upgrading_version_8.html#java_convention_deprecation)) 4. Use of plugin blocks instead of conventions for the `Application` plugin ([docs](https://docs.gradle.org/8.13/userguide/upgrading_version_8.html#application_convention_deprecation)) and applying the ensuing required cleanup from the Gradle 7 migration ([docs](https://docs.gradle.org/current/userguide/upgrading_version_7.html#javaapplication_api_cleanup)) 5. Stopping the use of `Task.project` in Task actions ([docs](https://docs.gradle.org/8.13/userguide/upgrading_version_7.html#task_project)). Other tasks which are not dependents of `shadowJar` or `compileTestJava` likely still use deprecated syntax or conventions - I will follow up with a second pull request to address those in future.
1 parent 6b181b8 commit da26d61

File tree

8 files changed

+28
-16
lines changed

8 files changed

+28
-16
lines changed

build.gradle

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,22 @@ allprojects {
100100

101101
// Configure JUnit tests
102102
tasks.withType(Test) {
103-
reports.junitXml.destination = project.file("${->project.buildDir}/test-results")
103+
reports.junitXml.outputLocation = project.file("${->project.buildDir}/test-results")
104104
}
105105

106+
def projectName = it.name
107+
def projectVersion = it.version
108+
106109
// Configure JAR generation
107110
tasks.jar.configure {
108111
description = "Produces a Jar with the main classes in .out/."
109112
manifest {
110113
attributes "Built-JDK": System.getProperty("java.version"),
111-
"Specification-Title": project.name,
112-
"Specification-Version": "${-> project.version}",
114+
"Specification-Title": projectName,
115+
"Specification-Version": "${-> projectVersion}",
113116
"Specification-Vendor": "Apple Inc.",
114-
"Implementation-Title": project.name,
115-
"Implementation-Version": "${-> project.version}",
117+
"Implementation-Title": projectName,
118+
"Implementation-Version": "${-> projectVersion}",
116119
"Implementation-Vendor": "Apple Inc."
117120
}
118121
doFirst {
@@ -182,8 +185,10 @@ allprojects {
182185
subprojects {
183186
apply from: rootProject.file('gradle/testing.gradle')
184187

185-
sourceCompatibility = JavaVersion.VERSION_11
186-
targetCompatibility = JavaVersion.VERSION_11
188+
java {
189+
sourceCompatibility = JavaVersion.VERSION_11
190+
targetCompatibility = JavaVersion.VERSION_11
191+
}
187192

188193
def publishBuild = Boolean.parseBoolean(findProperty('publishBuild') ?: 'false')
189194
def autoServiceVersion = publishBuild ? libs.versions.autoService.asProvider().get() : libs.versions.autoService.development.get()

examples/examples.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,7 @@ dependencies {
3030
runtimeOnly(libs.log4j.core) // library
3131
}
3232

33-
mainClassName = 'com.apple.foundationdb.record.sample.Main'
34-
applicationDefaultJvmArgs = ["-Dlog4j.configurationFile=${projectDir}/src/main/resources/log4j2.properties"]
33+
application {
34+
mainClass = 'com.apple.foundationdb.record.sample.Main'
35+
applicationDefaultJvmArgs = ["-Dlog4j.configurationFile=${projectDir}/src/main/resources/log4j2.properties"]
36+
}

fdb-relational-api/fdb-relational-api.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,19 @@ task createVersionPropertiesFile() {
3030
// Write a file of version and build info for the java processes to read
3131
// from their classpaths.
3232
def versionsFile = new File(projectDir, "src/gen/main/resources/version.properties")
33+
def projectVersion = project.version
34+
def rootProjectName = rootProject.name
3335
def gitDetails = versionDetails()
36+
3437
outputs.file versionsFile
3538
doLast {
3639
println "Writing ${versionsFile}"
3740
versionsFile.text = """# Generated by fdb-relational-api build.
3841
# Returned by RelationalDatabaseMetaData#getDatabaseProductName()
39-
name=${rootProject.name}
42+
name=${rootProjectName}
4043
# Returned by RelationalDatabaseMetaData#getDatabaseProductVersion()
4144
# and by RelationalDatabaseMetaData#getDriverVersion()
42-
version=${project.version}
45+
version=${projectVersion}
4346
gitHash=${gitDetails.gitHashFull}
4447
branch=${gitDetails.branchName}
4548
# Returned as RelationalDatabaseMetaData#getUrl()

fdb-relational-cli/fdb-relational-cli.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ dependencies {
7474
}
7575

7676
jar {
77-
duplicatesStrategy "exclude"
77+
duplicatesStrategy = "exclude"
7878
manifest {
7979
attributes(
8080
'Main-Class': 'com.apple.foundationdb.relational.cli.sqlline.RelationalSQLLine',

fdb-relational-jdbc/fdb-relational-jdbc.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ serviceLoader {
5252
}
5353

5454
jar {
55-
duplicatesStrategy "exclude"
55+
duplicatesStrategy = "exclude"
5656
}
5757

5858
// Task to build a fat jar, one w/ all dependencies; good for handing out as the 'jdbc' jar.

fdb-relational-server/fdb-relational-server.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ jar {
5656

5757
// Task to build a fat jar, one w/ all dependencies
5858
shadowJar {
59-
mainClassName = mainServerClass
59+
application {
60+
mainClass = mainServerClass
61+
}
6062
mergeServiceFiles()
6163
}
6264

gradle/testing.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ task destructiveTest(type: Test) {
4040
maxParallelForks = 1
4141
}
4242
reports {
43-
junitXml.destination = file("${buildDir}/test-results/destructive")
43+
junitXml.outputLocation = file("${buildDir}/test-results/destructive")
4444
}
4545
}
4646

yaml-tests/yaml-tests.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ project.tasks.named("processTestResources") {
3333
}
3434

3535
tasks.named("sourcesJar") {
36-
duplicatesStrategy('include')
36+
duplicatesStrategy = 'include'
3737
// classifier('sources')
3838
from sourceSets.main.allSource
3939
}

0 commit comments

Comments
 (0)