diff --git a/.scripts/locales.py b/.scripts/locales.py index 6d24430477..7e3bb0112f 100755 --- a/.scripts/locales.py +++ b/.scripts/locales.py @@ -19,8 +19,8 @@ sed = [ "sed", "-i", - f"s/resourceConfigurations .*/resourceConfigurations += [{res}]/", - "app/build.gradle" + f"s/resourceConfigurations .*/resourceConfigurations += listOf({res})/", + "app/build.gradle.kts" ] subprocess.run(sed, check=True) diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index d8022aabda..0000000000 --- a/app/build.gradle +++ /dev/null @@ -1,146 +0,0 @@ -import com.github.spotbugs.snom.SpotBugsTask - -plugins { - id 'com.android.application' - id 'com.github.spotbugs' -} - -spotbugs { - ignoreFailures = false - effort = 'max' - excludeFilter = file("./config/spotbugs/exclude.xml") - reportsDir = file("$buildDir/reports/spotbugs/") -} - -android { - compileSdk 33 - - defaultConfig { - applicationId "me.hackerchick.catima" - minSdk 21 - targetSdk 33 - versionCode 131 - versionName "2.26.0" - - vectorDrawables.useSupportLibrary true - multiDexEnabled true - - resourceConfigurations += ["ar", "bg", "bn", "bn-rIN", "bs", "cs", "da", "de", "el-rGR", "en", "eo", "es", "es-rAR", "fi", "fr", "he-rIL", "hi", "hr", "hu", "in-rID", "is", "it", "ja", "ko", "lt", "lv", "nb-rNO", "nl", "oc", "pl", "pt", "ro-rRO", "ru", "sk", "sl", "sv", "tr", "uk", "zh-rTW", "zh-rCN"] - } - - buildTypes { - release { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - resValue "string", "app_name", "Catima" - } - debug { - applicationIdSuffix ".debug" - resValue "string", "app_name", "Catima Debug" - } - } - - buildFeatures { - viewBinding true - } - - bundle { - language { - enableSplit = false - } - } - - compileOptions { - encoding "UTF-8" - - // Flag to enable support for the new language APIs - coreLibraryDesugaringEnabled true - - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } - - - sourceSets { - test { - resources.srcDirs += ['src/test/res'] - } - } - - // Starting with Android Studio 3 Robolectric is unable to find resources. - // The following allows it to find the resources. - testOptions { - unitTests { - all { - testLogging { - events 'started', 'passed', 'skipped', 'failed' - } - } - includeAndroidResources true - } - } - lint { - lintConfig file('lint.xml') - } - namespace 'protect.card_locker' -} - -dependencies { -// AndroidX - implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'androidx.exifinterface:exifinterface:1.3.6' - implementation 'androidx.palette:palette:1.0.0' - implementation 'androidx.preference:preference:1.2.1' - implementation 'com.google.android.material:material:1.9.0' - implementation 'com.github.yalantis:ucrop:2.2.8' - coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3' - -// Splash Screen - implementation 'androidx.core:core-splashscreen:1.0.1' - -// Third-party - implementation 'com.journeyapps:zxing-android-embedded:4.3.0@aar' - implementation 'com.google.zxing:core:3.5.2' - implementation 'org.apache.commons:commons-csv:1.9.0' - implementation 'com.jaredrummler:colorpicker:1.1.0' - implementation 'net.lingala.zip4j:zip4j:2.11.5' - -// SpotBugs - implementation 'io.wcm.tooling.spotbugs:io.wcm.tooling.spotbugs.annotations:1.0.0' - -// Testing - testImplementation 'androidx.test:core:1.5.0' - testImplementation 'junit:junit:4.13.2' - testImplementation 'org.robolectric:robolectric:4.10.3' -} - -tasks.withType(SpotBugsTask) { - - description 'Run spotbugs' - group 'verification' - - //classes = fileTree('build/intermediates/javac/debug/compileDebugJavaWithJavac/classes') - //source = fileTree('src/main/java') - //classpath = files() - - reports { - xml.enabled = false - html.enabled = true - } -} - -tasks.register('copyRawResFiles', Copy) { - from layout.projectDirectory.file("../CHANGELOG.md"), - layout.projectDirectory.file("../PRIVACY.md") - into layout.projectDirectory.dir("src/main/res/raw") - rename { String fileName -> fileName.toLowerCase() } -} - -project.afterEvaluate { - tasks.each { task -> - if (task != copyRawResFiles) { - task.dependsOn(copyRawResFiles) - } - } -} diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000000..1ee7d0e6d3 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,147 @@ +import com.android.build.gradle.internal.tasks.factory.dependsOn +import com.github.spotbugs.snom.SpotBugsTask + +plugins { + id("com.android.application") + id("com.github.spotbugs") +} + +spotbugs { + ignoreFailures.set(false) + setEffort("max") + excludeFilter.set(file("./config/spotbugs/exclude.xml")) + reportsDir.set(layout.buildDirectory.file("reports/spotbugs/").get().asFile) +} + +android { + namespace = "protect.card_locker" + compileSdk = 33 + + defaultConfig { + applicationId = "me.hackerchick.catima" + minSdk = 21 + targetSdk = 33 + versionCode = 131 + versionName = "2.26.0" + + vectorDrawables.useSupportLibrary = true + multiDexEnabled = true + + resourceConfigurations += listOf("ar", "bg", "bn", "bn-rIN", "bs", "cs", "da", "de", "el-rGR", "en", "eo", "es", "es-rAR", "fi", "fr", "he-rIL", "hi", "hr", "hu", "in-rID", "is", "it", "ja", "ko", "lt", "lv", "nb-rNO", "nl", "oc", "pl", "pt", "ro-rRO", "ru", "sk", "sl", "sv", "tr", "uk", "zh-rTW", "zh-rCN") + } + + buildTypes { + release { + isMinifyEnabled = true + proguardFiles( + getDefaultProguardFile("proguard-android.txt"), + "proguard-rules.pro" + ) + resValue("string", "app_name", "Catima") + } + debug { + applicationIdSuffix = ".debug" + resValue("string", "app_name", "Catima Debug") + } + } + + buildFeatures { + buildConfig = true + viewBinding = true + } + + bundle { + language { + enableSplit = false + } + } + + compileOptions { + encoding = "UTF-8" + + // Flag to enable support for the new language APIs + isCoreLibraryDesugaringEnabled = true + + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + + sourceSets { + getByName("test") { + resources.srcDirs("src/test/res") + } + } + + // Starting with Android Studio 3 Robolectric is unable to find resources. + // The following allows it to find the resources. + testOptions.unitTests.isIncludeAndroidResources = true + tasks.withType<Test>().configureEach { + testLogging { + events("started", "passed", "skipped", "failed") + } + } + + lint { + lintConfig = file("lint.xml") + } +} + +dependencies { + + // AndroidX + implementation("androidx.appcompat:appcompat:1.6.1") + implementation("androidx.constraintlayout:constraintlayout:2.1.4") + implementation("androidx.exifinterface:exifinterface:1.3.6") + implementation("androidx.palette:palette:1.0.0") + implementation("androidx.preference:preference:1.2.1") + implementation("com.google.android.material:material:1.9.0") + implementation("com.github.yalantis:ucrop:2.2.8") + coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3") + + // Splash Screen + implementation("androidx.core:core-splashscreen:1.0.1") + + // Third-party + implementation("com.journeyapps:zxing-android-embedded:4.3.0@aar") + implementation("com.google.zxing:core:3.5.2") + implementation("org.apache.commons:commons-csv:1.9.0") + implementation("com.jaredrummler:colorpicker:1.1.0") + implementation("net.lingala.zip4j:zip4j:2.11.5") + + // SpotBugs + implementation("io.wcm.tooling.spotbugs:io.wcm.tooling.spotbugs.annotations:1.0.0") + + // Testing + testImplementation("androidx.test:core:1.5.0") + testImplementation("junit:junit:4.13.2") + testImplementation("org.robolectric:robolectric:4.10.3") +} + +tasks.withType<SpotBugsTask>().configureEach { + description = "Run spotbugs" + group = "verification" + + //classes = fileTree("build/intermediates/javac/debug/compileDebugJavaWithJavac/classes") + //source = fileTree("src/main/java") + //classpath = files() + + reports.maybeCreate("xml").required.set(false) + reports.maybeCreate("html").required.set(true) +} + +tasks.register("copyRawResFiles", Copy::class) { + from( + layout.projectDirectory.file("../CHANGELOG.md"), + layout.projectDirectory.file("../PRIVACY.md") + ) + into(layout.projectDirectory.dir("src/main/res/raw")) + rename { it.lowercase() } +}.also { + tasks.preBuild.dependsOn(it) + tasks.getByName<Delete>("clean") { + val filesNamesToDelete = listOf("CHANGELOG", "PRIVACY") + filesNamesToDelete.forEach { fileName -> + delete(layout.projectDirectory.file("src/main/res/raw/${fileName.lowercase()}.md")) + } + } +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 3911b02911..630cbe09c3 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -2,7 +2,7 @@ # By default, the flags in this file are appended to flags specified # in /Users/brarcher/Library/Android/sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. +# directive in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/build.gradle b/build.gradle deleted file mode 100644 index a1d1fd2215..0000000000 --- a/build.gradle +++ /dev/null @@ -1,16 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -plugins { - id 'com.android.application' version '8.1.2' apply false - id 'com.github.spotbugs' version "5.1.3" apply false -} - -allprojects { - tasks.withType(JavaCompile) { - options.compilerArgs << "-Xlint:deprecation" - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000000..6c446aa9e3 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,12 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +plugins { + id("com.android.application") version "8.1.2" apply false + id("com.github.spotbugs") version "5.1.3" apply false +} + +allprojects { + tasks.withType<JavaCompile> { + options.compilerArgs.add("-Xlint:deprecation") + } +} diff --git a/gradle.properties b/gradle.properties index 7a211799e2..469c55a65b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,22 +1,17 @@ # Project-wide Gradle settings. - # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* # any settings specified in this file. - # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html - # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -# Default value: -Xmx10248m -XX:MaxPermSize=256m -# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 - +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -android.defaults.buildfeatures.buildconfig=true -android.nonFinalResIds=true -android.nonTransitiveRClass=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true diff --git a/settings.gradle b/settings.gradle.kts similarity index 67% rename from settings.gradle rename to settings.gradle.kts index 67c69b4726..0e3d9b9c39 100644 --- a/settings.gradle +++ b/settings.gradle.kts @@ -11,16 +11,14 @@ dependencyResolutionManagement { google() mavenCentral() exclusiveContent { - forRepository { - maven { url "https://jitpack.io" } - } + forRepositories(maven("https://jitpack.io")) filter { // limit jitpack repository to these groups - includeGroup "com.github.yalantis" - includeGroup "com.github.invissvenska" + includeGroup("com.github.yalantis") + includeGroup("com.github.invissvenska") } } } } rootProject.name = "Catima" -include ':app' +include(":app")