Skip to content

Commit bc3f54a

Browse files
committed
Configure Android applications using build conventions
1 parent 87e5be6 commit bc3f54a

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

buildSrc/src/main/kotlin/EvasBuildPlugin.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import conventions.androidLibraryConventions
1+
import conventions.androidConventions
22
import conventions.binaryCompatibilityValidatorConventions
33
import conventions.kotlinMultiplatformConventions
44
import org.gradle.api.Plugin
@@ -10,7 +10,7 @@ class EvasBuildPlugin : Plugin<Project> {
1010
group = "io.sellmair"
1111

1212
target.kotlinMultiplatformConventions()
13-
target.androidLibraryConventions()
13+
target.androidConventions()
1414
target.binaryCompatibilityValidatorConventions()
1515
}
1616
}
Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
11
package conventions
22

3-
import com.android.build.gradle.LibraryExtension
3+
import com.android.build.gradle.TestedExtension
44
import org.gradle.api.JavaVersion
55
import org.gradle.api.Project
66
import org.gradle.kotlin.dsl.configure
77
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
88

9-
fun Project.androidLibraryConventions() {
10-
plugins.withId("com.android.library") {
11-
extensions.configure<LibraryExtension> {
12-
compileSdk = 34
9+
fun Project.androidConventions() {
10+
fun configureDefaults() {
11+
extensions.configure<TestedExtension> {
12+
setCompileSdkVersion(35)
1313
defaultConfig {
1414
minSdk = 15
15-
namespace = "io.sellmair.${project.name}"
15+
namespace = "io.sellmair.${project.name.replace("-", ".")}"
1616
}
1717

1818
compileOptions {
1919
this.sourceCompatibility = JavaVersion.VERSION_11
2020
this.targetCompatibility = JavaVersion.VERSION_11
2121
}
2222
}
23+
}
24+
25+
plugins.withId("com.android.library") {
26+
configureDefaults()
2327

2428
extensions.configure<KotlinMultiplatformExtension> {
2529
androidTarget().publishLibraryVariants("release")
2630
}
2731
}
32+
33+
plugins.withId("com.android.application") {
34+
configureDefaults()
35+
}
2836
}

0 commit comments

Comments
 (0)