-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from stslex/dev
libs and build process
- Loading branch information
Showing
491 changed files
with
3,479 additions
and
2,912 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
*.iml | ||
.gradle | ||
**/build/ | ||
**/release/ | ||
xcuserdata | ||
!src/**/build/ | ||
local.properties | ||
.idea | ||
.kotlin | ||
.fleet | ||
.DS_Store | ||
build | ||
captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties | ||
xcuserdata | ||
play_config.* | ||
keystore.* | ||
Gemfile.lock | ||
|
||
**/*.podspec | ||
|
||
*.xcodeproj/* | ||
!*.xcodeproj/project.pbxproj | ||
!*.xcodeproj/xcshareddata/ | ||
!*.xcodeproj/project.xcworkspace/ | ||
!*.xcworkspace/contents.xcworkspacedata | ||
**/xcshareddata/WorkspaceSettings.xcsettings | ||
.fleet | ||
**/*.podspec | ||
/iosApp/Podfile.lock | ||
/iosApp/Pods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/build | ||
/.gradle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/build | ||
/.gradle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
group = "com.stslex.wizard.buildlogic" | ||
|
||
dependencies { | ||
compileOnly(libs.android.gradlePlugin) | ||
compileOnly(libs.kotlin.gradlePlugin) | ||
compileOnly(libs.compose.gradlePlugin) | ||
compileOnly(libs.ksp.gradlePlugin) | ||
compileOnly(libs.room.gradlePlugin) | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
register("kotlinLibraryMultiplatform") { | ||
id = "convention.kmp.library" | ||
implementationClass = "KMPLibraryConventionPlugin" | ||
} | ||
register("kotlinApplicationMultiplatform") { | ||
id = "convention.kmp.application" | ||
implementationClass = "KMPApplicationConventionPlugin" | ||
} | ||
register("kotlinLibraryComposeMultiplatform") { | ||
id = "convention.kmp.library.compose" | ||
implementationClass = "KMPLibraryComposeConventionPlugin" | ||
} | ||
register("kotlinLibraryComposeAndroid") { | ||
id = "convention.android.library.compose" | ||
implementationClass = "KotlinLibraryComposePlugin" | ||
} | ||
register("kotlinLibraryRoom") { | ||
id = "convention.kmp.library.room" | ||
implementationClass = "RoomLibraryConventionPlugin" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.VersionCatalog | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
internal object AppExt { | ||
|
||
const val APP_PREFIX = "com.stslex.wizard" | ||
|
||
/** | ||
* Get the version catalog for the project | ||
* */ | ||
val Project.libs: VersionCatalog | ||
get() = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
|
||
/** | ||
* Find the version of the library | ||
*/ | ||
fun VersionCatalog.findVersionInt(name: String) = findVersion(name) | ||
.get() | ||
.requiredVersion | ||
.toInt() | ||
|
||
/** | ||
* Find the id of plugin | ||
*/ | ||
fun VersionCatalog.findPluginId(name: String): String = findPlugin(name) | ||
.get() | ||
.get() | ||
.pluginId | ||
|
||
/** | ||
* Find the version of the library | ||
*/ | ||
fun VersionCatalog.findVersionString(name: String) = findVersion(name).get().toString() | ||
} |
57 changes: 57 additions & 0 deletions
57
build-logic/convention/src/main/kotlin/KMPApplicationConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import AppExt.APP_PREFIX | ||
import AppExt.findPluginId | ||
import AppExt.findVersionInt | ||
import AppExt.findVersionString | ||
import AppExt.libs | ||
import com.android.build.api.dsl.ApplicationExtension | ||
import com.google.devtools.ksp.gradle.KspExtension | ||
import com.stslex.wizard.convention.configureKMPCompose | ||
import com.stslex.wizard.convention.configureKotlin | ||
import com.stslex.wizard.convention.configureKotlinAndroid | ||
import com.stslex.wizard.convention.configureKotlinAndroidCompose | ||
import com.stslex.wizard.convention.configureKotlinMultiplatform | ||
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 KMPApplicationConventionPlugin : Plugin<Project> { | ||
|
||
override fun apply(target: Project): Unit = with(target) { | ||
with(pluginManager) { | ||
apply(libs.findPluginId("kotlinMultiplatform")) | ||
apply(libs.findPluginId("kotlinCocoapods")) | ||
apply(libs.findPluginId("androidApplication")) | ||
apply(libs.findPluginId("jetbrainsCompose")) | ||
apply(libs.findPluginId("composeCompiler")) | ||
apply(libs.findPluginId("ksp")) | ||
apply(libs.findPluginId("serialization")) | ||
} | ||
|
||
extensions.configure<KotlinMultiplatformExtension> { | ||
val kspExtension = extensions.getByType<KspExtension>() | ||
configureKotlinMultiplatform(this, kspExtension) | ||
configureKMPCompose( | ||
extension = this, | ||
compose = extensions.getByType<ComposeExtension>().dependencies | ||
) | ||
} | ||
|
||
extensions.configure<ApplicationExtension> { | ||
configureKotlin() | ||
configureKotlinAndroid( | ||
extension = this, | ||
isApp = true | ||
) | ||
configureKotlinAndroidCompose(this) | ||
defaultConfig.apply { | ||
applicationId = APP_PREFIX | ||
targetSdk = libs.findVersionInt("targetSdk") | ||
versionName = libs.findVersionString("versionName") | ||
versionCode = libs.findVersionInt("versionCode") | ||
} | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
build-logic/convention/src/main/kotlin/KMPLibraryComposeConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import AppExt.findPluginId | ||
import AppExt.libs | ||
import com.android.build.api.dsl.LibraryExtension | ||
import com.stslex.wizard.convention.configureKMPCompose | ||
import com.stslex.wizard.convention.configureKotlin | ||
import com.stslex.wizard.convention.configureKotlinAndroid | ||
import com.stslex.wizard.convention.configureKotlinMultiplatform | ||
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 KMPLibraryComposeConventionPlugin : Plugin<Project> { | ||
|
||
override fun apply(target: Project): Unit = with(target) { | ||
with(pluginManager) { | ||
apply(libs.findPluginId("kotlinMultiplatform")) | ||
apply(libs.findPluginId("jetbrainsCompose")) | ||
apply(libs.findPluginId("composeCompiler")) | ||
apply(libs.findPluginId("kotlinCocoapods")) | ||
apply(libs.findPluginId("androidLibrary")) | ||
apply(libs.findPluginId("ksp")) | ||
apply(libs.findPluginId("serialization")) | ||
} | ||
|
||
extensions.configure<KotlinMultiplatformExtension> { | ||
configureKMPCompose( | ||
extension = this, | ||
compose = extensions.getByType<ComposeExtension>().dependencies | ||
) | ||
configureKotlinMultiplatform( | ||
extension = this, | ||
kspExtension = extensions.getByType() | ||
) | ||
} | ||
|
||
extensions.configure<LibraryExtension> { | ||
configureKotlin() | ||
configureKotlinAndroid(this) | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
build-logic/convention/src/main/kotlin/KMPLibraryConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import AppExt.findPluginId | ||
import AppExt.libs | ||
import com.android.build.api.dsl.LibraryExtension | ||
import com.stslex.wizard.convention.configureKotlin | ||
import com.stslex.wizard.convention.configureKotlinAndroid | ||
import com.stslex.wizard.convention.configureKotlinMultiplatform | ||
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.kotlin.gradle.dsl.KotlinMultiplatformExtension | ||
|
||
class KMPLibraryConventionPlugin : Plugin<Project> { | ||
|
||
override fun apply(target: Project): Unit = with(target) { | ||
with(pluginManager) { | ||
apply(libs.findPluginId("kotlinMultiplatform")) | ||
apply(libs.findPluginId("kotlinCocoapods")) | ||
apply(libs.findPluginId("androidLibrary")) | ||
apply(libs.findPluginId("ksp")) | ||
apply(libs.findPluginId("serialization")) | ||
} | ||
|
||
extensions.configure<KotlinMultiplatformExtension> { | ||
configureKotlinMultiplatform( | ||
extension = this, | ||
kspExtension = extensions.getByType() | ||
) | ||
} | ||
extensions.configure<LibraryExtension> { | ||
configureKotlinAndroid(this) | ||
configureKotlin() | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
build-logic/convention/src/main/kotlin/KotlinLibraryComposePlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import AppExt.findPluginId | ||
import AppExt.libs | ||
import com.android.build.api.dsl.LibraryExtension | ||
import com.stslex.wizard.convention.configureKotlin | ||
import com.stslex.wizard.convention.configureKotlinAndroidCompose | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
|
||
class KotlinLibraryComposePlugin : Plugin<Project> { | ||
|
||
override fun apply(target: Project): Unit = with(target) { | ||
with(pluginManager) { | ||
apply(libs.findPluginId("androidLibrary")) | ||
apply(libs.findPluginId("composeCompiler")) | ||
apply(libs.findPluginId("ksp")) | ||
} | ||
extensions.configure<LibraryExtension> { | ||
configureKotlin() | ||
configureKotlinAndroidCompose(this) | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
build-logic/convention/src/main/kotlin/RoomLibraryConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import AppExt.findPluginId | ||
import AppExt.libs | ||
import androidx.room.gradle.RoomExtension | ||
import com.google.devtools.ksp.gradle.KspExtension | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension | ||
|
||
class RoomLibraryConventionPlugin : Plugin<Project> { | ||
|
||
override fun apply(target: Project) { | ||
with(target) { | ||
pluginManager.apply { | ||
apply(libs.findPluginId("room")) | ||
apply(libs.findPluginId("ksp")) | ||
apply(libs.findPluginId("kotlinMultiplatform")) | ||
apply(libs.findPluginId("serialization")) | ||
} | ||
|
||
extensions.configure<KspExtension> { | ||
arg("room.generateKotlin", "true") | ||
} | ||
|
||
extensions.configure<RoomExtension> { | ||
// The schemas directory contains a schema file for each version of the Room database. | ||
// This is required to enable Room auto migrations. | ||
// See https://developer.android.com/reference/kotlin/androidx/room/AutoMigration. | ||
schemaDirectory("$projectDir/schemas") | ||
} | ||
|
||
extensions.configure<KotlinMultiplatformExtension> { | ||
dependencies { | ||
val roomCompiler = libs.findLibrary("room-compiler").get() | ||
add("kspAndroid", roomCompiler) | ||
add("kspIosSimulatorArm64", roomCompiler) | ||
add("kspIosX64", roomCompiler) | ||
add("kspIosArm64", roomCompiler) | ||
} | ||
sourceSets.apply { | ||
commonMain.dependencies { | ||
implementation(libs.findLibrary("room-runtime").get()) | ||
implementation(libs.findLibrary("sqlite-bundled").get()) | ||
implementation(libs.findLibrary("sqlite").get()) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.