Unverified Commit 884f4418 authored by Ryan Schmitt's avatar Ryan Schmitt Committed by GitHub
Browse files

Fix Gradle deprecation warnings (#1978)

This change provides compatibility with the latest Gradle 8.0 nightly.
Since the top-level code coverage stuff was already broken and
apparently no one noticed, I just deleted it. The coverage reports for
specific subprojects still work fine.
parent 547dd4d6
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ tasks.jar {
val sourcesJar by tasks.creating(Jar::class) {
    group = "publishing"
    description = "Assembles Kotlin sources jar"
    classifier = "sources"
    archiveClassifier.set("sources")
    from(sourceSets.getByName("main").allSource)
}

@@ -93,9 +93,9 @@ tasks.test {
// Configure jacoco (code coverage) to generate an HTML report
tasks.jacocoTestReport {
    reports {
        xml.isEnabled = false
        csv.isEnabled = false
        html.destination = file("$buildDir/reports/jacoco")
        xml.required.set(false)
        csv.required.set(false)
        html.outputLocation.set(file("$buildDir/reports/jacoco"))
    }
}

+10 −34
Original line number Diff line number Diff line
@@ -27,7 +27,14 @@ allprojects {
    }
}

apply(from = rootProject.file("gradle/maincodecoverage.gradle"))
allprojects.forEach {
    it.apply(plugin = "jacoco")

    it.the<JacocoPluginExtension>().apply {
        toolVersion = "0.8.8"
        reportsDirectory.set(file("${buildDir}/jacoco-reports"))
    }
}

val ktlint by configurations.creating {
    // https://github.com/pinterest/ktlint/issues/1114#issuecomment-805793163
@@ -54,7 +61,7 @@ tasks.register<JavaExec>("ktlint") {
    description = "Check Kotlin code style."
    group = "Verification"
    classpath = configurations.getByName("ktlint")
    main = "com.pinterest.ktlint.Main"
    mainClass.set("com.pinterest.ktlint.Main")
    args = listOf("--verbose", "--relative", "--") + lintPaths
    // https://github.com/pinterest/ktlint/issues/1195#issuecomment-1009027802
    jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
@@ -64,39 +71,8 @@ tasks.register<JavaExec>("ktlintFormat") {
    description = "Auto fix Kotlin code style violations"
    group = "formatting"
    classpath = configurations.getByName("ktlint")
    main = "com.pinterest.ktlint.Main"
    mainClass.set("com.pinterest.ktlint.Main")
    args = listOf("--verbose", "--relative", "--format", "--") + lintPaths
    // https://github.com/pinterest/ktlint/issues/1195#issuecomment-1009027802
    jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
}

@Suppress("UnstableApiUsage")
tasks.register<JacocoMerge>("jacocoMerge") {
    group = LifecycleBasePlugin.VERIFICATION_GROUP
    description = "Merge the JaCoCo data files from all subprojects into one"
    afterEvaluate {
        // An empty FileCollection
        val execFiles = objects.fileCollection()
        val projectList = subprojects + project
        projectList.forEach { subProject: Project ->
            if (subProject.pluginManager.hasPlugin("jacoco")) {
                val testTasks = subProject.tasks.withType<Test>()
                // ensure that .exec files are actually present
                dependsOn(testTasks)

                testTasks.forEach { task: Test ->
                    // The JacocoTaskExtension is the source of truth for the location of the .exec file.
                    val extension = task.extensions.findByType(JacocoTaskExtension::class.java)
                    extension?.let {
                        execFiles.from(it.destinationFile)
                    }
                }
            }
        }
        executionData = execFiles
    }
    doFirst {
        // .exec files might be missing if a project has no tests. Filter in execution phase.
        executionData = executionData.filter { it.canRead() }
    }
}
+3 −3
Original line number Diff line number Diff line
@@ -49,9 +49,9 @@ tasks.test {
// Configure jacoco (code coverage) to generate an HTML report
tasks.jacocoTestReport {
    reports {
        xml.isEnabled = false
        csv.isEnabled = false
        html.destination = file("$buildDir/reports/jacoco")
        xml.required.set(false)
        csv.required.set(false)
        html.outputLocation.set(file("$buildDir/reports/jacoco"))
    }
}

+4 −4
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ tasks.jar {
val sourcesJar by tasks.creating(Jar::class) {
    group = "publishing"
    description = "Assembles Kotlin sources jar"
    classifier = "sources"
    archiveClassifier.set("sources")
    from(sourceSets.getByName("main").allSource)
}

@@ -86,9 +86,9 @@ tasks["build"].finalizedBy(tasks["dokkaHtml"])
// Configure jacoco (code coverage) to generate an HTML report
tasks.jacocoTestReport {
    reports {
        xml.isEnabled = false
        csv.isEnabled = false
        html.destination = file("$buildDir/reports/jacoco")
        xml.required.set(false)
        csv.required.set(false)
        html.outputLocation.set(file("$buildDir/reports/jacoco"))
    }
}

+4 −4
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ tasks.jar {
val sourcesJar by tasks.creating(Jar::class) {
    group = "publishing"
    description = "Assembles Kotlin sources jar"
    classifier = "sources"
    archiveClassifier.set("sources")
    from(sourceSets.getByName("main").allSource)
}

@@ -126,9 +126,9 @@ tasks["build"].finalizedBy(tasks["dokkaHtml"])
// Configure jacoco (code coverage) to generate an HTML report
tasks.jacocoTestReport {
    reports {
        xml.isEnabled = false
        csv.isEnabled = false
        html.destination = file("$buildDir/reports/jacoco")
        xml.required.set(false)
        csv.required.set(false)
        html.outputLocation.set(file("$buildDir/reports/jacoco"))
    }
}

Loading