Rework convention plugins

This commit is contained in:
T8RIN
2024-11-15 02:33:43 +03:00
parent 78fd43f8b2
commit eb87d1ca6e
6 changed files with 91 additions and 61 deletions

View File

@ -17,32 +17,20 @@
@file:Suppress("UnstableApiUsage")
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("kotlin-parcelize")
id("kotlin-kapt")
id("com.google.dagger.hilt.android")
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
id("com.mikepenz.aboutlibraries.plugin")
id("org.jetbrains.kotlin.plugin.compose")
alias(libs.plugins.image.toolbox.application)
alias(libs.plugins.image.toolbox.hilt)
}
android {
var isFoss = false
namespace = "ru.tech.imageresizershrinker"
compileSdk = libs.versions.androidCompileSdk.get().toIntOrNull()
defaultConfig {
vectorDrawables.useSupportLibrary = true
applicationId = "ru.tech.imageresizershrinker"
minSdk = libs.versions.androidMinSdk.get().toIntOrNull()
targetSdk = libs.versions.androidTargetSdk.get().toIntOrNull()
versionCode = libs.versions.versionCode.get().toIntOrNull()
versionName = System.getenv("VERSION_NAME") ?: libs.versions.versionName.get()
@ -85,24 +73,6 @@ android {
}
}
val javaVersion = JavaVersion.toVersion(libs.versions.jvmTarget.get())
compileOptions {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
isCoreLibraryDesugaringEnabled = true
}
kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(libs.versions.jvmTarget.get()))
}
}
buildFeatures {
compose = true
}
splits {
abi {
isEnable = true
@ -126,24 +96,6 @@ android {
}
dependencies {
coreLibraryDesugaring(libs.desugaring)
implementation(libs.hilt)
kapt(libs.dagger.hilt.compiler)
implementation(libs.androidx.material3)
implementation(libs.androidx.material3.window.sizeclass)
implementation(libs.androidx.material.icons.extended)
implementation(libs.androidx.material)
implementation(projects.core.domain)
implementation(projects.core.ui)
implementation(projects.core.data)
implementation(projects.core.resources)
implementation(projects.core.settings)
implementation(projects.core.filters)
implementation(projects.core.crash)
implementation(projects.feature.root)
implementation(projects.feature.mediaPicker)
implementation(projects.feature.quickTiles)

View File

@ -50,9 +50,9 @@ gradlePlugin {
id = "image.toolbox.library"
implementationClass = "ImageToolboxLibraryPlugin"
}
register("imageToolboxLibraryHilt") {
register("imageToolboxHiltPlugin") {
id = "image.toolbox.hilt"
implementationClass = "ImageToolboxLibraryHiltPlugin"
implementationClass = "ImageToolboxHiltPlugin"
}
register("imageToolboxLibraryFeature") {
id = "image.toolbox.feature"
@ -62,5 +62,9 @@ gradlePlugin {
id = "image.toolbox.compose"
implementationClass = "ImageToolboxLibraryComposePlugin"
}
register("imageToolboxApplicationPlugin") {
id = "image.toolbox.application"
implementationClass = "ImageToolboxApplicationPlugin"
}
}
}

View File

@ -0,0 +1,70 @@
import com.android.build.api.dsl.ApplicationExtension
import com.t8rin.imagetoolbox.configureCompose
import com.t8rin.imagetoolbox.configureDetekt
import com.t8rin.imagetoolbox.configureKotlinAndroid
import com.t8rin.imagetoolbox.libs
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.getByType
/*
* ImageToolbox is an image editor for android
* Copyright (c) 2024 T8RIN (Malik Mukhametzyanov)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* You should have received a copy of the Apache License
* along with this program. If not, see <http://www.apache.org/licenses/LICENSE-2.0>.
*/
@Suppress("UNUSED")
class ImageToolboxApplicationPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
apply(plugin = "com.android.application")
apply(plugin = "org.jetbrains.kotlin.android")
apply(plugin = "kotlin-parcelize")
apply(plugin = "kotlin-kapt")
apply(plugin = "com.google.gms.google-services")
apply(plugin = "com.google.firebase.crashlytics")
apply(plugin = "com.mikepenz.aboutlibraries.plugin")
apply(plugin = "org.jetbrains.kotlin.plugin.compose")
apply(plugin = "io.gitlab.arturbosch.detekt")
configureDetekt(extensions.getByType<DetektExtension>())
extensions.configure<ApplicationExtension> {
configureKotlinAndroid(
commonExtension = this,
createFlavors = false
)
defaultConfig.targetSdk =
libs.findVersion("androidTargetSdk").get().toString().toIntOrNull()
}
dependencies {
"implementation"(libs.findLibrary("androidxCore").get())
"implementation"(project(":core:data"))
"implementation"(project(":core:ui"))
"implementation"(project(":core:domain"))
"implementation"(project(":core:resources"))
"implementation"(project(":core:settings"))
"implementation"(project(":core:di"))
"implementation"(project(":core:crash"))
}
configureCompose(extensions.getByType<ApplicationExtension>())
}
}
}

View File

@ -21,7 +21,7 @@ import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
@Suppress("UNUSED")
class ImageToolboxLibraryHiltPlugin : Plugin<Project> {
class ImageToolboxHiltPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {

View File

@ -33,6 +33,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
internal fun Project.configureKotlinAndroid(
commonExtension: CommonExtension<*, *, *, *, *, *>,
createFlavors: Boolean = true
) {
commonExtension.apply {
compileSdk = libs.findVersion("androidCompileSdk").get().toString().toIntOrNull()
@ -41,14 +42,16 @@ internal fun Project.configureKotlinAndroid(
minSdk = libs.findVersion("androidMinSdk").get().toString().toIntOrNull()
}
flavorDimensions += "app"
if (createFlavors) {
flavorDimensions += "app"
productFlavors {
create("foss") {
dimension = "app"
}
create("market") {
dimension = "app"
productFlavors {
create("foss") {
dimension = "app"
}
create("market") {
dimension = "app"
}
}
}

View File

@ -194,4 +194,5 @@ compose-compiler-gradle = { module = "org.jetbrains.kotlin:compose-compiler-grad
image-toolbox-library = { id = "image.toolbox.library", version = "unspecified" }
image-toolbox-hilt = { id = "image.toolbox.hilt", version = "unspecified" }
image-toolbox-feature = { id = "image.toolbox.feature", version = "unspecified" }
image-toolbox-compose = { id = "image.toolbox.compose", version = "unspecified" }
image-toolbox-compose = { id = "image.toolbox.compose", version = "unspecified" }
image-toolbox-application = { id = "image.toolbox.application", version = "unspecified" }