Skip to content

Commit 242b975

Browse files
committed
refactor: buildSrc + SDK 33
1 parent c728e4c commit 242b975

15 files changed

Lines changed: 158 additions & 122 deletions

app/build.gradle.kts

Lines changed: 50 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import org.jetbrains.kotlin.config.KotlinCompilerVersion
22
import java.util.Properties
33

4-
val devCycle = false
5-
64
plugins {
75
id("com.android.application")
86
kotlin("android")
@@ -11,15 +9,25 @@ plugins {
119
}
1210

1311
android {
14-
namespace = "com.androidvip.sysctlgui"
15-
compileSdk = 32
16-
compileOptions {
17-
sourceCompatibility = JavaVersion.VERSION_1_8
18-
targetCompatibility = JavaVersion.VERSION_1_8
19-
}
12+
namespace = AppConfig.appId
13+
compileSdk = AppConfig.compileSdkVersion
2014

21-
kotlinOptions {
22-
jvmTarget = "1.8"
15+
defaultConfig {
16+
applicationId = AppConfig.appId
17+
minSdk = AppConfig.minSdkVersion
18+
targetSdk = AppConfig.targetSdlVersion
19+
versionCode = 11
20+
versionName = "2.0.0"
21+
vectorDrawables.useSupportLibrary = true
22+
resourceConfigurations.addAll(listOf("en", "de", "pt-rBR"))
23+
javaCompileOptions {
24+
annotationProcessorOptions {
25+
arguments += mapOf(
26+
"room.incremental" to "true",
27+
"room.schemaLocation" to "$projectDir/schemas"
28+
)
29+
}
30+
}
2331
}
2432

2533
signingConfigs {
@@ -36,29 +44,11 @@ android {
3644
}
3745
}
3846

39-
defaultConfig {
40-
applicationId = "com.androidvip.sysctlgui"
41-
minSdk = 21
42-
targetSdk = 32
43-
versionCode = 11
44-
versionName = "2.0.0"
45-
vectorDrawables.useSupportLibrary = true
46-
resourceConfigurations.addAll(listOf("en", "de", "pt-rBR"))
47-
javaCompileOptions {
48-
annotationProcessorOptions {
49-
arguments += mapOf(
50-
"room.incremental" to "true",
51-
"room.schemaLocation" to "$projectDir/schemas"
52-
)
53-
}
54-
}
55-
}
56-
5747
buildTypes {
5848
getByName("release") {
59-
isMinifyEnabled = !devCycle
60-
isShrinkResources = !devCycle
61-
isDebuggable = devCycle
49+
isMinifyEnabled = !AppConfig.devCycle
50+
isShrinkResources = !AppConfig.devCycle
51+
isDebuggable = AppConfig.devCycle
6252
signingConfig = signingConfigs.getByName("release")
6353
proguardFiles(
6454
getDefaultProguardFile("proguard-android-optimize.txt"),
@@ -69,8 +59,8 @@ android {
6959
}
7060

7161
buildFeatures {
72-
viewBinding = true
73-
dataBinding = true
62+
android.buildFeatures.viewBinding = true
63+
android.buildFeatures.dataBinding = true
7464
}
7565

7666
sourceSets {
@@ -92,16 +82,14 @@ android {
9282
)
9383
)
9484
}
95-
}
9685

97-
android.applicationVariants.forEach { variant ->
98-
val defaultConfig = android.defaultConfig
99-
variant.outputs.all {
100-
var fileName = "sysctlgui"
101-
fileName += "-v${defaultConfig.versionName}(${defaultConfig.versionCode})"
102-
fileName += if (variant.buildType.name == "release") ".apk" else "-SNAPSHOT.apk"
86+
compileOptions {
87+
sourceCompatibility = JavaVersion.VERSION_1_8
88+
targetCompatibility = JavaVersion.VERSION_1_8
89+
}
10390

104-
outputFile.renameTo(File(outputFile.path, fileName))
91+
kotlinOptions {
92+
jvmTarget = "1.8"
10593
}
10694
}
10795

@@ -110,35 +98,27 @@ kapt {
11098
}
11199

112100
dependencies {
113-
implementation(project(":domain"))
114-
implementation(project(":data"))
115-
implementation(project(":common:utils"))
116-
implementation(project(":common:design"))
117-
118101
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
119102
implementation(kotlin("stdlib-jdk8", KotlinCompilerVersion.VERSION))
120-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2")
121-
122-
implementation("io.insert-koin:koin-android:3.1.3")
123-
124-
implementation("androidx.appcompat:appcompat:1.6.0-alpha05")
125-
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
126-
implementation("androidx.core:core-ktx:1.8.0")
127-
implementation("androidx.core:core-splashscreen:1.0.0")
128-
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.4.0")
129-
implementation("androidx.navigation:navigation-fragment-ktx:2.4.0")
130-
implementation("androidx.navigation:navigation-ui-ktx:2.4.0")
131-
implementation("androidx.preference:preference-ktx:1.2.0")
132-
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
133-
implementation("androidx.room:room-ktx:2.4.0")
134-
implementation("androidx.room:room-runtime:2.4.0")
135-
136-
implementation("com.google.android.material:material:1.7.0-alpha03")
137-
implementation("com.google.code.gson:gson:2.8.6")
138-
139-
implementation("com.getkeepsafe.taptargetview:taptargetview:1.13.3")
140-
implementation("com.github.topjohnwu.libsu:core:2.5.1")
141-
implementation("com.github.hadilq:live-event:1.3.0")
142-
143-
kapt("androidx.room:room-compiler:2.4.0")
103+
104+
implementation(project(Modules.domain))
105+
implementation(project(Modules.data))
106+
implementation(project(Modules.utils))
107+
implementation(project(Modules.design))
108+
109+
implementation(AndroidX.splashScreen)
110+
implementation(AndroidX.lifecycleLiveData)
111+
implementation(AndroidX.navigationFragment)
112+
implementation(AndroidX.navigationUi)
113+
implementation(AndroidX.preference)
114+
implementation(AndroidX.room)
115+
implementation(AndroidX.roomRuntime)
116+
kapt(AndroidX.roomCompiler)
117+
118+
implementation(Google.gson)
119+
120+
implementation(Dependencies.koinAndroid)
121+
implementation(Dependencies.libSuCore)
122+
implementation(Dependencies.liveEvent)
123+
implementation(Dependencies.tapTargetView)
144124
}

build.gradle.kts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
val kotlinVersion = "1.6.21"
5-
64
repositories {
75
google()
86
mavenCentral()
97
}
108

119
dependencies {
12-
classpath("com.android.tools.build:gradle:7.4.2")
13-
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
14-
// NOTE: Do not place your application dependencies here; they belong
15-
// in the individual module build.gradle files
10+
classpath(BuildPlugins.gradle)
11+
classpath(BuildPlugins.kotlin)
1612
}
1713
}
1814

buildSrc/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

buildSrc/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
object AndroidX {
2+
const val appCompat = "androidx.appcompat:appcompat:1.6.1"
3+
const val constraintLayout = "androidx.constraintlayout:constraintlayout:2.1.4"
4+
const val core = "androidx.core:core-ktx:1.10.1"
5+
const val splashScreen = "androidx.core:core-splashscreen:1.0.1"
6+
const val lifecycleLiveData = "androidx.lifecycle:lifecycle-livedata-ktx:2.6.1"
7+
const val preference = "androidx.preference:preference-ktx:1.2.0"
8+
const val swipeRefreshLayout = "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
9+
10+
private const val navigationVersion = "2.6.0"
11+
const val navigationFragment = "androidx.navigation:navigation-fragment-ktx:$navigationVersion"
12+
const val navigationUi = "androidx.navigation:navigation-ui-ktx:$navigationVersion"
13+
14+
private const val roomVersion = "2.5.2"
15+
const val room = "androidx.room:room-ktx:$roomVersion"
16+
const val roomRuntime = "androidx.room:room-runtime:$roomVersion"
17+
const val roomCompiler = "androidx.room:room-compiler:$roomVersion"
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
object AppConfig {
2+
val devCycle = true
3+
4+
const val appId = "com.androidvip.sysctlgui"
5+
const val compileSdkVersion = 33
6+
const val minSdkVersion = 21
7+
const val targetSdlVersion = 33
8+
9+
const val testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
10+
const val proguardConsumerRules = "consumer-rules.pro"
11+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
object BuildPlugins {
2+
private const val agpVersion = "7.4.2"
3+
const val gradle = "com.android.tools.build:gradle:$agpVersion"
4+
5+
private const val kotlinVersion = "1.7.20"
6+
const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
object Dependencies {
3+
private const val koinVersion = "3.4.2"
4+
const val koinAndroid = "io.insert-koin:koin-android:$koinVersion"
5+
const val koinCore = "io.insert-koin:koin-core:$koinVersion"
6+
7+
const val tapTargetView = "com.getkeepsafe.taptargetview:taptargetview:1.13.3"
8+
const val libSuCore = "com.github.topjohnwu.libsu:core:2.5.1"
9+
const val liveEvent = "com.github.hadilq:live-event:1.3.0"
10+
}

buildSrc/src/main/kotlin/Google.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object Google {
2+
const val material = "com.google.android.material:material:1.9.0"
3+
const val gson = "com.google.code.gson:gson:2.8.9"
4+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
object Modules {
2+
const val main = ":app"
3+
const val domain = ":domain"
4+
const val data = ":data"
5+
const val utils = ":common:utils"
6+
const val design = ":common:design"
7+
}

0 commit comments

Comments
 (0)