Skip to content

Commit 69d260e

Browse files
authored
Simplified the version catalog logic. (#9)
1 parent ef3992c commit 69d260e

File tree

8 files changed

+161
-184
lines changed

8 files changed

+161
-184
lines changed

core/src/main/kotlin/com/mitteloupe/cag/core/Generator.kt

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,13 @@ class Generator(
7272
val featureNameLowerCase = request.featureName.lowercase()
7373
val dependencyConfiguration =
7474
DependencyConfiguration(
75-
versions =
76-
buildList {
77-
addAll(VersionCatalogConstants.KOTLIN_VERSIONS + VersionCatalogConstants.ANDROID_VERSIONS)
78-
if (request.enableCompose) {
79-
addAll(VersionCatalogConstants.COMPOSE_VERSIONS)
80-
}
81-
if (request.enableKtlint) {
82-
addAll(VersionCatalogConstants.KTLINT_VERSIONS)
83-
}
84-
if (request.enableDetekt) {
85-
addAll(VersionCatalogConstants.DETEKT_VERSIONS)
86-
}
75+
versions = VersionCatalogConstants.ANDROID_VERSIONS,
76+
libraries =
77+
if (request.enableCompose) {
78+
LibraryConstants.COMPOSE_LIBRARIES
79+
} else {
80+
emptyList()
8781
},
88-
libraries = if (request.enableCompose) LibraryConstants.COMPOSE_LIBRARIES else emptyList(),
8982
plugins =
9083
buildList {
9184
addAll(PluginConstants.KOTLIN_PLUGINS + PluginConstants.ANDROID_PLUGINS)
@@ -270,7 +263,7 @@ class Generator(
270263

271264
val dependencyConfiguration =
272265
DependencyConfiguration(
273-
versions = VersionCatalogConstants.KOTLIN_VERSIONS + VersionCatalogConstants.ANDROID_VERSIONS,
266+
versions = VersionCatalogConstants.ANDROID_VERSIONS,
274267
libraries = emptyList(),
275268
plugins = PluginConstants.KOTLIN_PLUGINS + PluginConstants.ANDROID_PLUGINS
276269
)
@@ -421,17 +414,6 @@ class Generator(
421414
throw GenerationException("Failed to create project directory.")
422415
}
423416

424-
val versions =
425-
buildList {
426-
addAll(
427-
VersionCatalogConstants.KOTLIN_VERSIONS +
428-
VersionCatalogConstants.ANDROID_VERSIONS +
429-
VersionCatalogConstants.TESTING_VERSIONS
430-
)
431-
if (request.enableCompose) {
432-
addAll(VersionCatalogConstants.COMPOSE_VERSIONS)
433-
}
434-
}
435417
val libraries =
436418
LibraryConstants.CORE_ANDROID_LIBRARIES + LibraryConstants.TESTING_LIBRARIES +
437419
if (request.enableCompose) {
@@ -454,7 +436,7 @@ class Generator(
454436
}
455437
val dependencyConfiguration =
456438
DependencyConfiguration(
457-
versions = versions,
439+
versions = VersionCatalogConstants.ANDROID_VERSIONS,
458440
libraries = libraries,
459441
plugins = plugins
460442
)

core/src/main/kotlin/com/mitteloupe/cag/core/generation/architecture/ArchitectureModulesContentGenerator.kt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,6 @@ class ArchitectureModulesContentGenerator(
5353
throw GenerationException("Failed to create directories for architecture package '$architecturePackageName'.")
5454
}
5555

56-
val versions =
57-
buildList {
58-
addAll(VersionCatalogConstants.KOTLIN_VERSIONS + VersionCatalogConstants.ANDROID_VERSIONS)
59-
if (enableCompose) {
60-
addAll(VersionCatalogConstants.COMPOSE_VERSIONS)
61-
}
62-
if (enableKtlint) {
63-
addAll(VersionCatalogConstants.KTLINT_VERSIONS)
64-
}
65-
if (enableDetekt) {
66-
addAll(VersionCatalogConstants.DETEKT_VERSIONS)
67-
}
68-
}
6956
val libraries =
7057
LibraryConstants.CORE_ANDROID_LIBRARIES +
7158
if (enableCompose) {
@@ -94,7 +81,7 @@ class ArchitectureModulesContentGenerator(
9481
}
9582
val dependencyConfiguration =
9683
DependencyConfiguration(
97-
versions = versions,
84+
versions = VersionCatalogConstants.ANDROID_VERSIONS,
9885
libraries = libraries,
9986
plugins = plugins
10087
)

core/src/main/kotlin/com/mitteloupe/cag/core/generation/architecture/CoroutineModuleContentGenerator.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class CoroutineModuleContentGenerator(
3636

3737
val dependencyConfiguration =
3838
DependencyConfiguration(
39-
versions = VersionCatalogConstants.KOTLIN_VERSIONS + VersionCatalogConstants.ANDROID_VERSIONS,
40-
libraries = LibraryConstants.CORE_ANDROID_LIBRARIES,
39+
versions = VersionCatalogConstants.ANDROID_VERSIONS,
40+
libraries = listOf(LibraryConstants.KOTLINX_COROUTINES_CORE),
4141
plugins = PluginConstants.KOTLIN_PLUGINS + PluginConstants.ANDROID_PLUGINS
4242
)
4343
catalogUpdater.updateVersionCatalogIfPresent(

0 commit comments

Comments
 (0)