Jelajahi Sumber

update build.gradle

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 1 tahun lalu
induk
melakukan
6af9b719f2
2 mengubah file dengan 22 tambahan dan 21 penghapusan
  1. 20 19
      app/build.gradle
  2. 2 2
      build.gradle

+ 20 - 19
app/build.gradle

@@ -17,6 +17,7 @@ buildscript {
 
 plugins {
     id "com.diffplug.spotless" version "6.20.0"
+    id 'com.google.devtools.ksp' version '1.8.22-1.0.11' apply false
 }
 
 apply plugin: 'com.android.application'
@@ -30,11 +31,13 @@ apply from: "$rootProject.projectDir/jacoco.gradle"
 apply plugin: 'com.github.spotbugs'
 apply plugin: 'io.gitlab.arturbosch.detekt'
 apply plugin: 'shot'
+apply plugin: 'com.google.devtools.ksp'
+
 
 println "Gradle uses Java ${Jvm.current()}"
 
 configurations {
-    all {
+    configureEach {
         exclude group: 'org.jetbrains', module: 'annotations-java5' // via prism4j, already using annotations explicitly
 
         // check for updates every build
@@ -71,8 +74,6 @@ file("$project.rootDir/ndk.env").readLines().each() {
 def perfAnalysis = project.hasProperty('perfAnalysis')
 
 android {
-
-    compileSdkVersion 33
     // install this NDK version and Cmake to produce smaller APKs. Build will still work if not installed
     ndkVersion "${ndkEnv.get("NDK_VERSION")}"
 
@@ -84,6 +85,7 @@ android {
     defaultConfig {
         minSdkVersion 24
         targetSdkVersion 33
+        compileSdk 33
 
         buildConfigField 'boolean', 'CI', ciBuild.toString()
         buildConfigField 'boolean', 'RUNTIME_PERF_ANALYSIS', perfAnalysis.toString()
@@ -116,7 +118,7 @@ android {
         // adapt structure from Eclipse to Gradle/Android Studio expectations;
         // see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
 
-        flavorDimensions "default"
+        flavorDimensions += "default"
 
         buildTypes {
             debug {
@@ -191,8 +193,8 @@ android {
         exclude '**/gen/**'
 
         reports {
-            xml.enabled = false
-            html.enabled = true
+            //xml.enabled = false
+            //html.enabled = true
             xml {
                 destination = file("$project.buildDir/reports/pmd/pmd.xml")
             }
@@ -379,7 +381,7 @@ dependencies {
     implementation 'com.github.nextcloud.android-common:ui:0.12.0'
 
     implementation "androidx.room:room-runtime:$roomVersion"
-    kapt "androidx.room:room-compiler:$roomVersion"
+    ksp "androidx.room:room-compiler:$roomVersion"
     androidTestImplementation "androidx.room:room-testing:$roomVersion"
 
     implementation "io.coil-kt:coil:2.4.0"
@@ -388,7 +390,7 @@ dependencies {
     implementation 'androidx.core:core-splashscreen:1.0.1'
 }
 
-configurations.all {
+configurations.configureEach {
     resolutionStrategy {
         cacheChangingModulesFor 0, 'seconds'
         force 'org.objenesis:objenesis:2.6'
@@ -400,15 +402,15 @@ configurations.all {
     }
 }
 
-tasks.withType(Test) {
+tasks.withType(Test).configureEach {
     // increased logging for tests
     testLogging {
         events "passed", "skipped", "failed"
     }
 }
 
-android.applicationVariants.all { variant ->
-    variant.outputs.all { output ->
+android.applicationVariants.configureEach { variant ->
+    variant.outputs.configureEach { output ->
         outputFileName = "${output.baseName}-${variant.versionCode}.apk"
     }
 }
@@ -421,12 +423,7 @@ spotless {
 }
 
 detekt {
-    reports {
-        xml {
-            enabled = false
-        }
-    }
-    config = files("detekt.yml")
+    config.setFrom("detekt.yml")
 }
 
 shot {
@@ -446,13 +443,13 @@ spotbugs {
     reportLevel = "medium"
 }
 
-tasks.withType(SpotBugsTask) { task ->
+tasks.withType(SpotBugsTask).configureEach { task ->
     String variantNameCap = task.name.replace("spotbugs", "")
     String variantName = variantNameCap.substring(0, 1).toLowerCase() + variantNameCap.substring(1)
 
     dependsOn "compile${variantNameCap}Sources"
 
-    excludeFilter = file("${project.rootDir}/spotbugs-filter.xml")
+    excludeFilter.set(file("${project.rootDir}/spotbugs-filter.xml"))
     classes = fileTree("$project.buildDir/intermediates/javac/${variantName}/classes/")
     reports {
         xml {
@@ -465,3 +462,7 @@ tasks.withType(SpotBugsTask) { task ->
         }
     }
 }
+
+ksp {
+    arg('room.schemaLocation', "$projectDir/schemas")
+}

+ 2 - 2
build.gradle

@@ -39,11 +39,11 @@ subprojects {
     }
 }
 
-task clean(type: Delete) {
+tasks.register('clean', Delete) {
     delete rootProject.buildDir
 }
 
-task installGitHooks(type: Copy, group: "development") {
+tasks.register('installGitHooks', Copy) {
     def sourceFolder = "${rootProject.projectDir}/scripts/hooks"
     def destFolder = "${rootProject.projectDir}/.git/hooks"