Skip to content

Commit

Permalink
update libs
Browse files Browse the repository at this point in the history
  • Loading branch information
stslex committed Aug 8, 2024
1 parent 77e04d2 commit a58ecfc
Show file tree
Hide file tree
Showing 22 changed files with 271 additions and 116 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.iml
.gradle
.idea
.kotlin
/local.properties
.DS_Store
/build
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
alias(libs.plugins.convention.application)
alias(libs.plugins.convention.application.compose)
alias(libs.plugins.composeCompiler)
}

dependencies {
Expand Down
4 changes: 3 additions & 1 deletion build-logic/dependencies/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ dependencies {
compileOnly(libs.ksp.gradlePlugin)
compileOnly(libs.room.gradlePlugin)
compileOnly(libs.android.tools.common)
compileOnly(libs.vkompose.gradlePlugin)
compileOnly(libs.composeCompiler.gradlePlugin)
}

tasks {
Expand Down Expand Up @@ -38,7 +40,7 @@ gradlePlugin {
id = "csplashscreen.android.library"
implementationClass = "AndroidLibraryConventionPlugin"
}
register("roomLibrary"){
register("roomLibrary") {
id = "csplashscreen.room.library"
implementationClass = "RoomLibraryConventionPlugin"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import AppExt.findPluginId
import AppExt.libs
import com.android.build.api.dsl.ApplicationExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
Expand All @@ -7,11 +9,15 @@ import st.slex.csplashscreen.configureAndroidCompose
class AndroidApplicationComposeConventionPlugin : Plugin<Project> {

override fun apply(target: Project) {

with(target) {
pluginManager.apply("com.android.application")
val extension = extensions.getByType<ApplicationExtension>()
configureAndroidCompose(extension)
pluginManager.apply(libs.findPluginId("kotlin"))
pluginManager.apply(libs.findPluginId("composeCompiler"))
pluginManager.apply(libs.findPluginId("vkompose"))

configureAndroidCompose(
commonExtension = extensions.getByType<ApplicationExtension>()
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import AppExt.currentLibs
import AppExt.findVersionInt
import AppExt.findVersionString
import AppExt.libs
import com.android.build.api.dsl.ApplicationExtension
import com.google.devtools.ksp.gradle.KspExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
Expand All @@ -16,7 +15,6 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {

override fun apply(target: Project) {
with(target) {
val libs = currentLibs
with(pluginManager) {
apply("com.android.application")
apply("org.jetbrains.kotlin.android")
Expand All @@ -36,10 +34,6 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {
configureSigning(target)
}
}

extensions.configure<KspExtension> {
arg("KOIN_CONFIG_CHECK", "true")
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import AppExt.findPluginId
import AppExt.libs
import com.android.build.gradle.LibraryExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
Expand All @@ -9,8 +11,13 @@ class AndroidLibraryComposeConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
pluginManager.apply("com.android.library")
val extension = extensions.getByType<LibraryExtension>()
configureAndroidCompose(extension)
pluginManager.apply(libs.findPluginId("kotlin"))
pluginManager.apply(libs.findPluginId("composeCompiler"))
pluginManager.apply(libs.findPluginId("vkompose"))

configureAndroidCompose(
commonExtension = extensions.getByType<LibraryExtension>()
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import AppExt.findPluginId
import AppExt.libs
import com.android.build.gradle.LibraryExtension
import com.google.devtools.ksp.gradle.KspExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
Expand Down Expand Up @@ -37,10 +38,6 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
}
}

extensions.configure<KspExtension> {
arg("KOIN_CONFIG_CHECK", "true")
}

val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")
configurations.configureEach {
resolutionStrategy {
Expand Down
115 changes: 114 additions & 1 deletion build-logic/dependencies/src/main/kotlin/AppExt.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalog
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.getByType

object AppExt {

/**
* Get the version catalog for the project
* */
val Project.currentLibs: VersionCatalog
val Project.libs: VersionCatalog
get() = extensions.getByType<VersionCatalogsExtension>().named("libs")

/**
Expand All @@ -20,4 +21,116 @@ object AppExt {
* Find the version of the library
*/
fun VersionCatalog.findVersionString(name: String) = findVersion(name).get().toString()

/**
* Find the plugin id
*/
fun VersionCatalog.findPluginId(alias: String) = findPlugin("vkompose").get().get().pluginId

/**
* Find the library by alias
*/
fun Project.implementation(vararg alias: String) {
dependencies {
alias.forEach {
add("implementation", libs.findLibrary(it).get())
}
}
}

fun Project.debugImplementation(vararg alias: String) {
dependencies {
alias.forEach {
add("debugImplementation", libs.findLibrary(it).get())
}
}
}

fun Project.implementationPlatform(vararg alias: String) {
dependencies {
alias.forEach {
add(
"debugImplementation",
platform(libs.findLibrary(it).get())
)
}
}
}

/**
* Find the bundle by alias
*/
fun Project.implementationBundle(vararg alias: String) {
dependencies {
alias.forEach {
add("implementation", libs.findBundle(it).get())
}
}
}

/**
* Find the library by alias
*/
fun Project.androidTestImplementation(vararg alias: String) {
dependencies {
alias.forEach {
add("androidTestImplementation", libs.findLibrary(it).get())
}
}
}

/**
* Find the library by alias
*/
fun Project.androidTestImplementationBundle(vararg alias: String) {
dependencies {
alias.forEach {
add("androidTestImplementation", libs.findBundle(it).get())
}
}
}

fun Project.androidTestImplementationPlatform(vararg alias: String) {
dependencies {
alias.forEach {
add(
"androidTestImplementation",
dependencies.platform(libs.findLibrary(it).get())
)
}
}
}

/**
* Find the library by alias
*/
fun Project.testImplementationBundle(vararg alias: String) {
dependencies {
alias.forEach {
add("testImplementation", libs.findBundle(it).get())
}
}
}

/**
* Find the library by alias
*/
fun Project.coreLibraryDesugaring(vararg alias: String) {
dependencies {
alias.forEach {
add("coreLibraryDesugaring", libs.findLibrary(it).get())
}
}
}

/**
* Find the library by alias
*/
fun Project.ksp(vararg alias: String) {
dependencies {
alias.forEach {
add("ksp", libs.findLibrary(it).get())
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import AppExt.currentLibs
import AppExt.libs
import androidx.room.gradle.RoomExtension
import com.google.devtools.ksp.gradle.KspExtension
import org.gradle.api.Plugin
Expand All @@ -25,11 +25,11 @@ class RoomLibraryConventionPlugin : Plugin<Project> {
}

dependencies {
"implementation"(currentLibs.findBundle("room").get())
"annotationProcessor"(currentLibs.findLibrary("androidx-room-compiler").get())
"implementation"(currentLibs.findLibrary("androidx-paging-runtime").get())
"androidTestApi"(currentLibs.findLibrary("androidx-room-testing").get())
"ksp"(currentLibs.findLibrary("androidx-room-compiler").get())
"implementation"(libs.findBundle("room").get())
"annotationProcessor"(libs.findLibrary("androidx-room-compiler").get())
"implementation"(libs.findLibrary("androidx-paging-runtime").get())
"androidTestApi"(libs.findLibrary("androidx-room-testing").get())
"ksp"(libs.findLibrary("androidx-room-compiler").get())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,65 +1,64 @@
package st.slex.csplashscreen

import AppExt.currentLibs
import AppExt.findVersionString
import AppExt.androidTestImplementation
import AppExt.androidTestImplementationPlatform
import AppExt.debugImplementation
import AppExt.implementation
import AppExt.implementationBundle
import AppExt.implementationPlatform
import com.android.build.api.dsl.CommonExtension
import com.vk.gradle.plugin.compose.utils.VkomposeExtension
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.gradle.kotlin.dsl.configure

/**
* Configure Compose-specific options
*/
internal fun Project.configureAndroidCompose(
commonExtension: CommonExtension<*, *, *, *, *, *>,
) {
val libs = currentLibs

commonExtension.apply {

buildFeatures.compose = true
composeOptions.kotlinCompilerExtensionVersion = libs.findVersionString("composeCompiler")

dependencies {
val composeBom = libs.findLibrary("androidx-compose-bom").get()
add("implementation", platform(composeBom))
add("androidTestImplementation", platform(composeBom))

val composeApi = libs.findBundle("compose").get()
add("implementation", composeApi)

// val composeManifest = libs.findBundle("androidx-compose-manifest").get()
// add("debugImplementation", composeManifest)

val tooling = libs.findLibrary("androidx-compose-tooling").get()
add("debugImplementation", tooling)

val composeTest = libs.findLibrary("androidx-compose-ui-test-junit4").get()
add("androidTestImplementation", composeTest)

val accompanist = libs.findBundle("accompanist").get()
add("implementation", accompanist)

val appcompat = libs.findLibrary("appcompat").get()
add("implementation", appcompat)
androidTestImplementationPlatform("androidx-compose-bom")
implementationPlatform("androidx-compose-bom")
debugImplementation("androidx-compose-tooling")
androidTestImplementation("androidx-compose-ui-test-junit4")
implementationBundle("accompanist", "compose", "lifecycle")
implementation("appcompat", "material", "koin-androidx-compose")
}

val material = libs.findLibrary("material").get()
add("implementation", material)
extensions.configure<VkomposeExtension>(action = ::configureVkompose)
}

val lifecycle = libs.findBundle("lifecycle").get()
add("implementation", lifecycle)
private fun Project.configureVkompose(
extension: VkomposeExtension
): Unit = with(extension) {
skippabilityCheck = true
skippabilityCheck {
// For more see
// https://android-review.googlesource.com/c/platform/frameworks/support/+/2668595
// https://issuetracker.google.com/issues/309765121
stabilityConfigurationPath = "/path/file.config"
}

val koinCompose = libs.findLibrary("koin-androidx-compose").get()
add("implementation", koinCompose)
}
recompose {
isHighlighterEnabled = true
isLoggerEnabled = true
// or
// logger {
// logModifierChanges = true // true by default since 0.5
// logFunctionChanges = true // true by default since 0.5. log when function arguments (like lambdas or function references) of composable function are changed
// }
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs //+ buildComposeMetricsParameters()
}
testTag {
isApplierEnabled = true
isDrawerEnabled = false
isCleanerEnabled = false
}

sourceInformationClean = true
}

// TODO Check
Expand Down
Loading

0 comments on commit a58ecfc

Please sign in to comment.