Skip to content

Commit 00c3729

Browse files
committed
build: rewrite build.gradle files to Kotlin DSL
1 parent b4474a2 commit 00c3729

File tree

6 files changed

+164
-154
lines changed

6 files changed

+164
-154
lines changed

app/build.gradle

-102
This file was deleted.

app/build.gradle.kts

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
@file:Suppress("UnstableApiUsage")
2+
3+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
4+
5+
plugins {
6+
id("com.android.application")
7+
id("kotlin-android")
8+
id("org.jmailen.kotlinter") version "4.3.0"
9+
}
10+
11+
android {
12+
namespace = "com.github.gotify"
13+
compileSdk = 34
14+
defaultConfig {
15+
applicationId = "com.github.gotify"
16+
minSdk = 23
17+
targetSdk = 34
18+
versionCode = 32
19+
versionName = "2.8.1"
20+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
21+
vectorDrawables.useSupportLibrary = true
22+
signingConfig = signingConfigs.getByName("debug")
23+
resValue("string", "app_name", "Gotify")
24+
}
25+
buildTypes {
26+
release {
27+
isMinifyEnabled = false
28+
proguardFiles(
29+
getDefaultProguardFile("proguard-android.txt"),
30+
"proguard-rules.pro"
31+
)
32+
}
33+
register("development") {
34+
applicationIdSuffix = ".dev"
35+
isDebuggable = true
36+
resValue("string", "app_name", "Gotify DEV")
37+
}
38+
}
39+
buildFeatures {
40+
viewBinding = true
41+
buildConfig = true
42+
}
43+
compileOptions {
44+
sourceCompatibility = JavaVersion.VERSION_17
45+
targetCompatibility = JavaVersion.VERSION_17
46+
}
47+
kotlin {
48+
compilerOptions {
49+
jvmTarget.set(JvmTarget.JVM_17)
50+
}
51+
}
52+
packaging {
53+
resources {
54+
excludes.add("META-INF/DEPENDENCIES")
55+
}
56+
}
57+
lint {
58+
disable.add("GoogleAppIndexingWarning")
59+
lintConfig = file("../lint.xml")
60+
}
61+
}
62+
63+
if (project.hasProperty("sign")) {
64+
android {
65+
signingConfigs {
66+
create("release") {
67+
storeFile = file(System.getenv("RELEASE_STORE_FILE"))
68+
storePassword = System.getenv("RELEASE_STORE_PASSWORD")
69+
keyAlias = System.getenv("RELEASE_KEY_ALIAS")
70+
keyPassword = System.getenv("RELEASE_KEY_PASSWORD")
71+
}
72+
}
73+
}
74+
android.buildTypes.getByName("release").signingConfig = android.signingConfigs.getByName("release")
75+
}
76+
77+
dependencies {
78+
val coilVersion = "2.6.0"
79+
val markwonVersion = "4.6.2"
80+
val tinylogVersion = "2.7.0"
81+
implementation(project(":client"))
82+
implementation("androidx.appcompat:appcompat:1.7.0")
83+
implementation("androidx.core:core-splashscreen:1.0.1")
84+
implementation("com.google.android.material:material:1.12.0")
85+
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
86+
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
87+
implementation("androidx.vectordrawable:vectordrawable:1.2.0")
88+
implementation("androidx.preference:preference-ktx:1.2.1")
89+
90+
implementation("com.github.cyb3rko:QuickPermissions-Kotlin:1.1.3")
91+
implementation("io.coil-kt:coil:$coilVersion")
92+
implementation("io.coil-kt:coil-svg:$coilVersion")
93+
implementation("io.noties.markwon:core:$markwonVersion")
94+
implementation("io.noties.markwon:image-coil:$markwonVersion")
95+
implementation("io.noties.markwon:image:$markwonVersion")
96+
implementation("io.noties.markwon:ext-tables:$markwonVersion")
97+
implementation("io.noties.markwon:ext-strikethrough:$markwonVersion")
98+
99+
implementation("org.tinylog:tinylog-api-kotlin:$tinylogVersion")
100+
implementation("org.tinylog:tinylog-impl:$tinylogVersion")
101+
102+
implementation("com.google.code.gson:gson:2.11.0")
103+
implementation("com.squareup.retrofit2:retrofit:2.11.0")
104+
implementation("org.threeten:threetenbp:1.7.0")
105+
}
106+
107+
configurations {
108+
configureEach {
109+
exclude(group = "androidx.lifecycle", module = "lifecycle-viewmodel-ktx")
110+
}
111+
}

app/proguard-rules.pro

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Add project specific ProGuard rules here.
22
# You can control the set of applied configuration files using the
3-
# proguardFiles setting in build.gradle.
3+
# proguardFiles setting in build.gradle.kts.
44
#
55
# For more details, see
66
# http://developer.android.com/guide/developing/tools/proguard.html

build.gradle

-48
This file was deleted.

build.gradle.kts

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import com.android.build.gradle.internal.tasks.factory.dependsOn
2+
import java.io.File
3+
import java.net.URI
4+
5+
plugins {
6+
id("com.android.application") version "8.5.0" apply false
7+
id("org.jetbrains.kotlin.android") version "2.0.0" apply false
8+
id("org.hidetake.swagger.generator") version "2.19.2"
9+
}
10+
11+
fun download(url: String, filename: String) {
12+
URI(url).toURL().openConnection().let { conn ->
13+
File(filename).outputStream().use { out ->
14+
conn.inputStream.use { inp ->
15+
inp.copyTo(out)
16+
}
17+
}
18+
}
19+
}
20+
21+
tasks.register("downloadSpec") {
22+
val gotifyVersion = "master"
23+
val url = "https://raw.githubusercontent.com/gotify/server/$gotifyVersion/docs/spec.json"
24+
val buildDir = project.layout.buildDirectory.get()
25+
val specLocation = buildDir.file("gotify.spec.json").asFile.absolutePath
26+
doFirst {
27+
buildDir.asFile.mkdirs()
28+
download(url, specLocation)
29+
}
30+
}
31+
32+
swaggerSources {
33+
create("swagger") {
34+
setInputFile(file("$projectDir/build/gotify.spec.json"))
35+
code.apply {
36+
language = "java"
37+
configFile = file("$projectDir/swagger.config.json")
38+
outputDir = file("$projectDir/client")
39+
}
40+
}
41+
}
42+
43+
dependencies {
44+
"swaggerCodegen"("io.swagger.codegen.v3:swagger-codegen-cli:3.0.63")
45+
}
46+
47+
tasks.named("generateSwaggerCode").dependsOn("downloadSpec")

settings.gradle renamed to settings.gradle.kts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@file:Suppress("UnstableApiUsage")
2+
13
pluginManagement {
24
repositories {
35
gradlePluginPortal()
@@ -9,9 +11,9 @@ dependencyResolutionManagement {
911
repositories {
1012
google()
1113
mavenCentral()
12-
maven { url "https://jitpack.io/" }
14+
maven { url = uri("https://jitpack.io/") }
1315
}
1416
}
1517
rootProject.name = "Gotify Android"
16-
include ':app'
17-
include ':client'
18+
include(":app")
19+
include(":client")

0 commit comments

Comments
 (0)