Initial commit
This commit is contained in:
39
buildlogic/convention/build.gradle.kts
Normal file
39
buildlogic/convention/build.gradle.kts
Normal file
@@ -0,0 +1,39 @@
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
group = "dev.carlosmartino.plugins.buildlogic"
|
||||
|
||||
dependencies {
|
||||
implementation(libs.plugins.kotlinMultiplatform.toDep())
|
||||
implementation(libs.plugins.kotlinSerialization.toDep())
|
||||
implementation(libs.plugins.androidApplication.toDep())
|
||||
implementation(libs.plugins.androidLibrary.toDep())
|
||||
implementation(libs.plugins.composeCompiler.toDep())
|
||||
implementation(libs.plugins.composeMultiplatform.toDep())
|
||||
}
|
||||
|
||||
fun Provider<PluginDependency>.toDep() =
|
||||
map {
|
||||
"${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version}"
|
||||
}
|
||||
|
||||
tasks {
|
||||
validatePlugins {
|
||||
enableStricterValidation = true
|
||||
failOnWarning = true
|
||||
}
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
register("kotlinMultiplatform") {
|
||||
id = "dev.carlosmartino.plugins.kotlinMultiplatform"
|
||||
implementationClass = "KotlinMultiplatformConventionPlugin"
|
||||
}
|
||||
register("composeMultiplatform") {
|
||||
id = "dev.carlosmartino.plugins.composeMultiplatform"
|
||||
implementationClass = "ComposeMultiplatformConventionPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import dev.carlosmartino.plugins.libs
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.getByType
|
||||
import org.jetbrains.compose.ComposeExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
|
||||
class ComposeMultiplatformConventionPlugin : Plugin<Project> {
|
||||
override fun apply(target: Project) =
|
||||
with(target) {
|
||||
with(pluginManager) {
|
||||
apply(libs.findPlugin("compose.plugin").get().get().pluginId)
|
||||
apply(libs.findPlugin("compose.multiplatform").get().get().pluginId)
|
||||
}
|
||||
|
||||
val composeDeps = extensions.getByType<ComposeExtension>().dependencies
|
||||
|
||||
extensions.configure<KotlinMultiplatformExtension> {
|
||||
sourceSets.apply {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation(composeDeps.runtime)
|
||||
implementation(composeDeps.foundation)
|
||||
implementation(composeDeps.material3)
|
||||
implementation(composeDeps.ui)
|
||||
implementation(composeDeps.uiUtil)
|
||||
implementation(composeDeps.animation)
|
||||
implementation(composeDeps.animationGraphics)
|
||||
implementation(composeDeps.components.resources)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import com.android.build.api.dsl.LibraryExtension
|
||||
import dev.carlosmartino.plugins.configureKotlinAndroid
|
||||
import dev.carlosmartino.plugins.configureKotlinMultiplatform
|
||||
import dev.carlosmartino.plugins.libs
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
|
||||
class KotlinMultiplatformConventionPlugin : Plugin<Project> {
|
||||
override fun apply(target: Project) =
|
||||
with(target) {
|
||||
with(pluginManager) {
|
||||
apply(
|
||||
libs
|
||||
.findPlugin("android.library")
|
||||
.get()
|
||||
.get()
|
||||
.pluginId,
|
||||
)
|
||||
apply(
|
||||
libs
|
||||
.findPlugin("kotlin.multiplatform")
|
||||
.get()
|
||||
.get()
|
||||
.pluginId,
|
||||
)
|
||||
apply(
|
||||
libs
|
||||
.findPlugin("kotlin.serialization")
|
||||
.get()
|
||||
.get()
|
||||
.pluginId,
|
||||
)
|
||||
}
|
||||
|
||||
extensions.configure<KotlinMultiplatformExtension>(::configureKotlinMultiplatform)
|
||||
extensions.configure<LibraryExtension>(::configureKotlinAndroid)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package dev.carlosmartino.plugins
|
||||
|
||||
import com.android.build.api.dsl.LibraryExtension
|
||||
import org.gradle.api.JavaVersion
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.get
|
||||
|
||||
internal fun Project.configureKotlinAndroid(
|
||||
extension: LibraryExtension,
|
||||
) = extension.apply {
|
||||
val moduleName = path.split(":").drop(2).joinToString(".")
|
||||
namespace = if (moduleName.isNotEmpty()) "dev.carlosmartino.platform.$moduleName" else "dev.carlosmartino.platform"
|
||||
|
||||
compileSdk = libs
|
||||
.findVersion("android.compileSdk")
|
||||
.get()
|
||||
.requiredVersion
|
||||
.toInt()
|
||||
defaultConfig {
|
||||
minSdk = libs
|
||||
.findVersion("android.minSdk")
|
||||
.get()
|
||||
.requiredVersion
|
||||
.toInt()
|
||||
consumerProguardFiles("consumer-proguard-rules.pro")
|
||||
}
|
||||
|
||||
sourceSets["main"].resources.srcDirs("src/commonMain/composeResources")
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
packaging {
|
||||
resources {
|
||||
excludes += "/META-INF/{AL2.0,LGPL2.1}"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package dev.carlosmartino.plugins
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
|
||||
@OptIn(ExperimentalWasmDsl::class)
|
||||
internal fun Project.configureKotlinMultiplatform(
|
||||
extension: KotlinMultiplatformExtension,
|
||||
) = extension.apply {
|
||||
applyDefaultHierarchyTemplate()
|
||||
|
||||
jvmToolchain(17)
|
||||
|
||||
androidTarget {
|
||||
compilerOptions {
|
||||
jvmTarget.set(JvmTarget.JVM_17)
|
||||
}
|
||||
}
|
||||
|
||||
listOf(iosArm64(), iosSimulatorArm64())
|
||||
|
||||
sourceSets.apply {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation(libs.findLibrary("kotlinx.coroutines.core").get())
|
||||
api(libs.findLibrary("koin.core").get())
|
||||
}
|
||||
|
||||
androidMain {
|
||||
dependencies {
|
||||
implementation(libs.findLibrary("koin.android").get())
|
||||
implementation(libs.findLibrary("kotlinx.coroutines.android").get())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package dev.carlosmartino.plugins
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.VersionCatalog
|
||||
import org.gradle.api.artifacts.VersionCatalogsExtension
|
||||
import org.gradle.kotlin.dsl.getByType
|
||||
|
||||
val Project.libs
|
||||
get(): VersionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")
|
||||
4
buildlogic/gradle.properties
Normal file
4
buildlogic/gradle.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
# Gradle properties are not passed to included builds https://github.com/gradle/gradle/issues/2534
|
||||
org.gradle.parallel=true
|
||||
org.gradle.caching=true
|
||||
org.gradle.configureondemand=true
|
||||
14
buildlogic/settings.gradle.kts
Normal file
14
buildlogic/settings.gradle.kts
Normal file
@@ -0,0 +1,14 @@
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
versionCatalogs {
|
||||
create("libs") {
|
||||
from(files("../gradle/libs.versions.toml"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "buildlogic"
|
||||
include(":convention")
|
||||
@@ -1,17 +1,17 @@
|
||||
[versions]
|
||||
agp = "8.10.1"
|
||||
agp = "8.13.0"
|
||||
android-compileSdk = "36"
|
||||
android-minSdk = "24"
|
||||
android-targetSdk = "36"
|
||||
androidx-activity = "1.10.1"
|
||||
androidx-activity = "1.11.0"
|
||||
androidx-appcompat = "1.7.1"
|
||||
androidx-core = "1.17.0"
|
||||
androidx-espresso = "3.7.0"
|
||||
androidx-lifecycle = "2.9.3"
|
||||
androidx-lifecycle = "2.9.4"
|
||||
androidx-testExt = "1.3.0"
|
||||
composeMultiplatform = "1.8.2"
|
||||
compose-multiplatform = "1.9.0"
|
||||
junit = "4.13.2"
|
||||
kotlin = "2.2.10"
|
||||
kotlin = "2.2.20"
|
||||
|
||||
[libraries]
|
||||
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
|
||||
@@ -29,11 +29,11 @@ androidx-lifecycle-runtimeCompose = { module = "org.jetbrains.androidx.lifecycle
|
||||
androidApplication = { id = "com.android.application", version.ref = "agp" }
|
||||
androidLibrary = { id = "com.android.library", version.ref = "agp" }
|
||||
androidMultiplatform = { id = "com.android.kotlin.multiplatform.library", version.ref = "agp" }
|
||||
composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "composeMultiplatform" }
|
||||
composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "compose-multiplatform" }
|
||||
composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
|
||||
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||
kotlinSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
||||
|
||||
composeMultiplatformKit = { id = "dev.carlosmartino.plugins.composeMultiplatform", version = "unspecified" }
|
||||
kotlinMultiplatformKit = { id = "dev.carlosmartino.plugins.kotlinMultiplatform", version = "unspecified" }
|
||||
# Buildlogic defined plugins -> buildlogic/convention/build.gradle.kts
|
||||
composeKit = { id = "dev.carlosmartino.plugins.composeMultiplatform", version = "unspecified" }
|
||||
kotlinKit = { id = "dev.carlosmartino.plugins.kotlinMultiplatform", version = "unspecified" }
|
||||
@@ -2,6 +2,7 @@ rootProject.name = "Template"
|
||||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
|
||||
pluginManagement {
|
||||
includeBuild("buildlogic")
|
||||
repositories {
|
||||
google {
|
||||
mavenContent {
|
||||
|
||||
Reference in New Issue
Block a user