Skip to content

Commit deee072

Browse files
Merge pull request #2812 from HrBDev/gradle-kts
Migrate to Gradle Kotlin DSL
2 parents 0702320 + 8d37142 commit deee072

10 files changed

Lines changed: 779 additions & 867 deletions

File tree

‎app/build.gradle‎

Lines changed: 0 additions & 770 deletions
This file was deleted.

‎app/build.gradle.kts‎

Lines changed: 664 additions & 0 deletions
Large diffs are not rendered by default.

‎app/src/main/java/com/celzero/bravedns/database/AppDatabase.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ abstract class AppDatabase : RoomDatabase() {
13481348
}
13491349
}
13501350

1351-
val MIGRATION_30_31: Migration =
1351+
internal val MIGRATION_30_31: Migration =
13521352
object : Migration(30, 31) {
13531353
override fun migrate(db: SupportSQLiteDatabase) {
13541354
if (!doesColumnExistInTable(db, "AppInfo", "notes")) {

‎app/src/tv/AndroidManifest.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
This file mirrors `app/src/full/AndroidManifest.xml` because the `tv`
66
flavor inherits the entire `app/src/full/java` source set (see
7-
`sourceSets.tv` in `app/build.gradle`). Every activity / receiver /
7+
`sourceSets.tv` in `app/build.gradle.kts`). Every activity / receiver /
88
service that upstream's Kotlin code references must be declared, or
99
startActivity / PackageManager calls from the inherited classes will
1010
crash at runtime with ActivityNotFoundException / NameNotFoundException.

‎benchmark/build.gradle‎

Lines changed: 0 additions & 33 deletions
This file was deleted.

‎benchmark/build.gradle.kts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
plugins {
2+
id("com.android.test")
3+
}
4+
5+
android {
6+
namespace = "com.celzero.bravedns.benchmark"
7+
compileSdk = 37
8+
9+
defaultConfig {
10+
minSdk = 23
11+
targetSdk = 37
12+
13+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
14+
}
15+
16+
buildTypes {
17+
// This benchmark build type is used for keyboard benchmarks
18+
create("benchmark") {
19+
isDebuggable = false
20+
signingConfig = signingConfigs.getByName("debug")
21+
matchingFallbacks += listOf("release")
22+
}
23+
}
24+
25+
targetProjectPath = ":app"
26+
experimentalProperties["android.experimental.self-instrumenting"] = true
27+
}
28+
29+
dependencies {
30+
implementation("androidx.benchmark:benchmark-macro-junit4:1.3.3")
31+
implementation("androidx.test.ext:junit:1.3.0")
32+
implementation("androidx.test.uiautomator:uiautomator:2.3.0")
33+
}

‎build.gradle‎

Lines changed: 0 additions & 55 deletions
This file was deleted.

‎build.gradle.kts‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
3+
buildscript {
4+
val kotlinVersion = "2.3.21"
5+
repositories {
6+
google()
7+
// https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/
8+
// jcenter() is no longer getting updates, instead using mavenCentral
9+
mavenCentral()
10+
}
11+
dependencies {
12+
classpath("com.android.tools.build:gradle:9.4.0")
13+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
14+
// Required by the TV flavor's Compose UI.
15+
classpath("org.jetbrains.kotlin:compose-compiler-gradle-plugin:$kotlinVersion")
16+
17+
// add firebase plugins - will be conditionally applied in app/build.gradle
18+
val taskNames = gradle.startParameter.taskNames.joinToString(",").lowercase()
19+
val apkBuild = taskNames.contains("full")
20+
val fdroidBuild = taskNames.contains("fdroid")
21+
22+
// check for fdroidserver value is set in system env
23+
val fdroidBuildServer = System.getenv("fdroidserver")
24+
val isFdroidBuildServer = !fdroidBuildServer.isNullOrEmpty() && fdroidBuildServer != "null"
25+
val deGoogled = !apkBuild || fdroidBuild || isFdroidBuildServer
26+
27+
println("app-task names: '$taskNames'")
28+
println("app; deGoogled? $deGoogled (fdroidBuild: $fdroidBuild, fdroidBuildServer: $isFdroidBuildServer, apkBuild: $apkBuild)")
29+
30+
if (!deGoogled) {
31+
classpath("com.google.gms:google-services:4.4.4")
32+
classpath("com.google.firebase:firebase-crashlytics-gradle:3.0.7")
33+
}
34+
}
35+
}
36+
37+
plugins {
38+
id("com.google.devtools.ksp") version "2.3.9" apply false
39+
}
40+
41+
allprojects {
42+
repositories {
43+
val firestackRepo = project.findProperty("firestackRepo")?.toString() ?: "github"
44+
45+
when (firestackRepo) {
46+
"jitpack" -> {
47+
// jitpack.io/#celzero/firestack
48+
maven { url = uri("https://jitpack.io") }
49+
}
50+
"github" -> {
51+
// maven.pkg.github.com/celzero/firestack
52+
maven {
53+
name = "GitHubPackages"
54+
url = uri("https://maven.pkg.github.com/celzero/firestack")
55+
credentials {
56+
username =
57+
project.findProperty("gpr.user")?.toString() ?: System.getenv("USERNAME_GITHUB")
58+
password =
59+
project.findProperty("gpr.key")?.toString() ?: System.getenv("TOKEN_GITHUB")
60+
}
61+
}
62+
}
63+
else -> {
64+
// ossrh: https://central.sonatype.com/artifact/com.celzero/firestack/
65+
// no-op; mavenCentral is already included
66+
}
67+
}
68+
}
69+
}
70+
71+
tasks.register<Delete>("clean") {
72+
delete(layout.buildDirectory)
73+
}

‎gradle/wrapper/gradle-wrapper.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.0-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.0-bin.zip
44
networkTimeout=10000
55
retries=0
66
retryBackOffMs=500

settings.gradle renamed to settings.gradle.kts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
rootProject.name='rethink'
2-
include ':app'
3-
include ':benchmark'
1+
rootProject.name = "rethink"
2+
include(":app")
3+
include(":benchmark")
44

55
dependencyResolutionManagement {
66
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
@@ -13,15 +13,15 @@ dependencyResolutionManagement {
1313
// from the repository selected via `firestackRepo` in gradle.properties.
1414
// NOTE: with RepositoriesMode.PREFER_SETTINGS, repositories declared in
1515
// project build.gradle files are ignored
16-
def firestackRepo = providers.gradleProperty("firestackRepo").orElse("github").get()
16+
val firestackRepo = providers.gradleProperty("firestackRepo").orElse("github").get()
1717

1818
if (firestackRepo == "jitpack") {
1919
// jitpack.io/#celzero/firestack
20-
maven { url 'https://jitpack.io' }
20+
maven { url = uri("https://jitpack.io") }
2121
} else if (firestackRepo == "github") {
2222
// maven.pkg.github.com/celzero/firestack
2323
maven {
24-
name = 'GitHubPackages'
24+
name = "GitHubPackages"
2525
url = uri("https://maven.pkg.github.com/celzero/firestack")
2626
credentials {
2727
username = providers.gradleProperty("gpr.user").orElse(providers.environmentVariable("USERNAME_GITHUB")).getOrNull()

0 commit comments

Comments
 (0)