Add Android library build plugin

This commit is contained in:
Wolf Montwé 2023-02-16 10:08:34 +01:00
parent e7e1d9ca9d
commit 864ee60c63
No known key found for this signature in database
GPG key ID: 6D45B21512ACBF72
7 changed files with 67 additions and 25 deletions

View file

@ -9,5 +9,5 @@ insert_final_newline = true
[*.{kt,kts}]
ij_kotlin_imports_layout = *,^*
[*.{yml,yaml,json}]
[*.{yml,yaml,json,toml}]
indent_size = 2

View file

@ -6,12 +6,12 @@ dependencies {
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
implementation(plugin(libs.plugins.kotlin.jvm))
implementation(plugin(libs.plugins.spotless))
implementation(plugin(libs.plugins.kotlin.android))
implementation(plugin(libs.plugins.android.application))
implementation(plugin(libs.plugins.android.library))
implementation(plugin(libs.plugins.spotless))
}
fun plugin(provider: Provider<PluginDependency>) = with(provider.get()) {

View file

@ -0,0 +1,33 @@
import com.android.build.api.dsl.CommonExtension
fun CommonExtension<*, *, *, *>.configureSharedConfig() {
compileSdk = ThunderbirdProjectConfig.androidSdkCompile
defaultConfig {
compileSdk = ThunderbirdProjectConfig.androidSdkCompile
minSdk = ThunderbirdProjectConfig.androidSdkMin
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildFeatures {
buildConfig = true
}
compileOptions {
sourceCompatibility = ThunderbirdProjectConfig.javaVersion
targetCompatibility = ThunderbirdProjectConfig.javaVersion
}
lint {
checkDependencies = true
abortOnError = false
}
testOptions {
unitTests {
isIncludeAndroidResources = true
}
}
}

View file

@ -5,5 +5,6 @@ object ThunderbirdPlugins {
}
object Library {
const val jvm = "thunderbird.library.jvm"
const val android = "thunderbird.library.android"
}
}

View file

@ -4,25 +4,14 @@ plugins {
}
android {
compileSdk = ThunderbirdProjectConfig.androidSdkCompile
configureSharedConfig()
defaultConfig {
minSdk = ThunderbirdProjectConfig.androidSdkMin
targetSdk = ThunderbirdProjectConfig.androidSdkTarget
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildFeatures {
buildConfig = true
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = ThunderbirdProjectConfig.javaVersion
targetCompatibility = ThunderbirdProjectConfig.javaVersion
}
kotlinOptions {
@ -30,18 +19,9 @@ android {
}
lint {
checkDependencies = true
abortOnError = false
lintConfig = file("${rootProject.projectDir}/config/lint/lint.xml")
}
testOptions {
unitTests {
isIncludeAndroidResources = true
}
}
dependenciesInfo {
includeInApk = false
includeInBundle = false

View file

@ -0,0 +1,26 @@
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
}
android {
configureSharedConfig()
kotlinOptions {
jvmTarget = ThunderbirdProjectConfig.javaVersion.toString()
}
lint {
lintConfig = file("${rootProject.projectDir}/config/lint/lint.xml")
}
testOptions {
unitTests {
isIncludeAndroidResources = true
}
}
}
dependencies {
testImplementation(libs.bundles.shared.jvm.test)
}

View file

@ -134,4 +134,6 @@ shared-jvm-test = [
"truth",
"mockito-inline",
"mockito-kotlin",
"koin-test",
"koin-test-junit4",
]