diff --git a/aws/sdk-codegen/build.gradle.kts b/aws/sdk-codegen/build.gradle.kts index 8c0f518173310407fc833ce2e481600e0b7fb5bb..dd5c081b9d76202f47961482d760a6a470ca18ad 100644 --- a/aws/sdk-codegen/build.gradle.kts +++ b/aws/sdk-codegen/build.gradle.kts @@ -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")) } } diff --git a/build.gradle.kts b/build.gradle.kts index 5d8b38f36682c73df88af11ce329c31c7c0c7a10..440e4ca41c4e38819bcf54c26acc2dbe58af42bd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -27,7 +27,14 @@ allprojects { } } -apply(from = rootProject.file("gradle/maincodecoverage.gradle")) +allprojects.forEach { + it.apply(plugin = "jacoco") + + it.the().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("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("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") { - 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() - // 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() } - } -} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index b1d48a62e5c03022ec13ce99dfe6ad28acea788e..c4b8cf2d35fb008b2c0e4bb213241f4c7642eafc 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -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")) } } diff --git a/codegen-client/build.gradle.kts b/codegen-client/build.gradle.kts index a836fd9100c86bd48d318f91b0c00c444a296eae..7130b5c30114ed3e09641fd96dbb0ce623101ee3 100644 --- a/codegen-client/build.gradle.kts +++ b/codegen-client/build.gradle.kts @@ -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")) } } diff --git a/codegen-core/build.gradle.kts b/codegen-core/build.gradle.kts index 4cb3e06feadd617b095608ad0a975bb300f6e221..d705a62faa7e27d8a58925592d3aa0c1242b92c5 100644 --- a/codegen-core/build.gradle.kts +++ b/codegen-core/build.gradle.kts @@ -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")) } } diff --git a/codegen-server/build.gradle.kts b/codegen-server/build.gradle.kts index b9630cf311d3ab79d7284911a03019ac7c651ef5..d9cea78519374949c19710fa52b4149497f5c4cc 100644 --- a/codegen-server/build.gradle.kts +++ b/codegen-server/build.gradle.kts @@ -51,7 +51,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) } diff --git a/codegen-server/python/build.gradle.kts b/codegen-server/python/build.gradle.kts index a45b0702133f8650524bd802988b092b0fb11633..40dba2024e65a753cc3ccd0fbbf6565f190a2cc3 100644 --- a/codegen-server/python/build.gradle.kts +++ b/codegen-server/python/build.gradle.kts @@ -52,7 +52,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) } diff --git a/gradle/maincodecoverage.gradle b/gradle/maincodecoverage.gradle deleted file mode 100644 index fafc4da1a1530a6d13ea44ad5424a72a61c231f4..0000000000000000000000000000000000000000 --- a/gradle/maincodecoverage.gradle +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -allprojects { - apply plugin: "jacoco" - - jacoco { - toolVersion = "0.8.8" - reportsDir = file("${buildDir}/jacoco-reports") - } -} - -subprojects { - task testCoverageSubproject(type: JacocoReport) { - group = "Reporting" - description = "Generate Jacoco coverage reports." - - def coverageSourceDirs = [ - "common/src", - "jvm/src", - "src/main/kotlin" - ] - // Do not add example projects coverage info - if (!project.name.contains("example")) { - classDirectories.from files(fileTree(dir: "${buildDir}/classes/kotlin/jvm/"), fileTree(dir: "${buildDir}/classes/kotlin/")) - sourceDirectories.from files(coverageSourceDirs) - additionalSourceDirs.from files(coverageSourceDirs) - } - - // Add corresponding test.exec file according to platforms in the project - if ("codegen" == project.name) { - executionData.from files("${buildDir}/jacoco/test.exec") - } else { - executionData.from files("${buildDir}/jacoco/jvmTest.exec") - } - - reports { - xml.enabled true - csv.enabled false - html.enabled true - - html.destination file("${buildDir}/jacoco-reports/html") - } - } -} - -task testCoverageMain(type: JacocoReport) { - group = "Reporting" - description = "Generate Jacoco coverage reports." - dependsOn subprojects.testCoverageSubproject - dependsOn "jacocoMerge" - - def classes = files(subprojects.collect { - files(fileTree(dir: "${it.buildDir}/classes/kotlin/jvm").filter({file -> !file.absolutePath.contains('design/example')})) - files(fileTree(dir: "${it.buildDir}/classes/kotlin").filter({file -> !file.absolutePath.contains('design/example')})) - }) - - def samples = files(subprojects.testCoverageSubproject.executionData).findAll { it.exists() } - - classDirectories.from files(classes) - executionData.from(samples) - - reports { - xml.enabled true - csv.enabled false - html.enabled true - html.destination file("${buildDir}/jacoco-reports/html") - } -}