Migrate top level gradle build file to kotlin dsl

This commit is contained in:
Shinokuni 2024-07-04 12:34:02 +02:00
parent 4eef3ba3c3
commit a15e8d617d
1 changed files with 28 additions and 28 deletions

View File

@ -1,62 +1,62 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.8.0' val kotlin_version = "1.8.0"
repositories { repositories {
google() google()
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:8.1.1' classpath("com.android.tools.build:gradle:8.1.1")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
classpath "org.jacoco:org.jacoco.core:0.8.7" classpath("org.jacoco:org.jacoco.core:0.8.7")
} }
} }
allprojects { allprojects {
apply plugin: 'jacoco' //apply("jacoco")
repositories { repositories {
google() google()
mavenCentral() mavenCentral()
maven { url 'https://jitpack.io' } maven(url = "https://jitpack.io")
} }
afterEvaluate { /*afterEvaluate {
tasks.withType(JavaCompile.class) { tasks.withType(JavaCompile.class) {
options.compilerArgs << "-Xmaxerrs" << "1000" options.compilerArgs << "-Xmaxerrs" << "1000"
} }
} }*/
} }
ext { ext {
compileSdkVersion = 34 val compileSdkVersion = 34
minSdkVersion = 21 val minSdkVersion = 21
targetSdkVersion = 34 val targetSdkVersion = 34
buildToolsVersion = "34.0.0" val buildToolsVersion = "34.0.0"
} }
tasks.register('clean', Delete) { tasks.register<Delete>("clean") {
delete rootProject.buildDir delete(rootProject.buildDir)
} }
jacoco { /*jacoco {
toolVersion = "0.8.7" toolVersion = "0.8.7"
} }
tasks.register('jacocoFullReport', JacocoReport) { tasks.register("jacocoFullReport", JacocoReport) {
group = 'Reporting' group = "Reporting"
description = "Generate Jacoco coverage reports for the debug build" description = "Generate Jacoco coverage reports for the debug build"
reports { reports {
html { html {
enabled true enabled true
destination file('build/reports/jacoco/html') destination file("build/reports/jacoco/html")
} }
xml { xml {
enabled true enabled true
destination file('build/reports/jacoco/jacocoFullReport.xml') destination file("build/reports/jacoco/jacocoFullReport.xml")
} }
} }
@ -64,11 +64,11 @@ tasks.register('jacocoFullReport', JacocoReport) {
dependsOn ":api:testDebugUnitTest" dependsOn ":api:testDebugUnitTest"
dependsOn ":db:testDebugUnitTest" dependsOn ":db:testDebugUnitTest"
//dependsOn ":app:connectedAndroidTest" //dependsOn ":app:connectedAndroidTest"
dependsOn ":db:connectedAndroidTest" dependsOn ":db:connectedAndroidTest"*/
final fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', 'android/**/*.*'] //final fileFilter = ["**/R.class", "**/R\$*.class", "**/BuildConfig.*", "**/Manifest*.*", "android/**/*.*"]
classDirectories.setFrom files([ /* classDirectories.setFrom files([
//fileTree(dir: "$project.rootDir/app/build/intermediates/javac/debug", excludes: fileFilter), //fileTree(dir: "$project.rootDir/app/build/intermediates/javac/debug", excludes: fileFilter),
//fileTree(dir: "$project.rootDir/app/build/tmp/kotlin-classes/debug", excludes: fileFilter), //fileTree(dir: "$project.rootDir/app/build/tmp/kotlin-classes/debug", excludes: fileFilter),
fileTree(dir: "$project.rootDir/api/build/intermediates/javac/debug", excludes: fileFilter), fileTree(dir: "$project.rootDir/api/build/intermediates/javac/debug", excludes: fileFilter),
@ -84,10 +84,10 @@ tasks.register('jacocoFullReport', JacocoReport) {
additionalSourceDirs.setFrom files(coverageSourceDirs) additionalSourceDirs.setFrom files(coverageSourceDirs)
sourceDirectories.setFrom files(coverageSourceDirs) sourceDirectories.setFrom files(coverageSourceDirs)
executionData.setFrom fileTree(dir: project.rootDir, includes: [ executionData.setFrom fileTree(dir: project.rootDir, includes: [
'app/jacoco.exec', "app/jacoco.exec",
'db/jacoco.exec', "db/jacoco.exec",
'api/jacoco.exec', "api/jacoco.exec",
'app/build/outputs/code_coverage/debugAndroidTest/connected/*-coverage.ec', "app/build/outputs/code_coverage/debugAndroidTest/connected/*-coverage.ec",
'db/build/outputs/code_coverage/debugAndroidTest/connected/*-coverage.ec' "db/build/outputs/code_coverage/debugAndroidTest/connected/*-coverage.ec"
]) ])
} }*/