Conversation
|
zatim jsme vzdy pouzivali https://www.archunit.org/ je to sice pro Javu, ale tim, ze se Kotlin stejne prelozi do Javovskeho bytekodu, tak jsme s tim nemeli problem. Nicmene ten Konsist take nevypada spatne vzhledem k tomu ze je to primo psany pro Kotlin. U ArchUnit obcas narazime na nejaky problem ze necemu z Kotlinu nerozumi a pak se to ruzne hackuje |
|
Prosvistel jsem clanky https://proandroiddev.com/archunit-vs-konsist-why-did-we-need-another-linter-972c4ff2622d a https://medium.com/the-house-of-code/archunit-vs-konsist-in-android-kotlin-oriented-codebase-b72c6c698b0b. Ja bych ten Konsist urcite zkusil :) Ale rozhodnuti tohoto typu maji delat nejzkusenejsi clenove tymu ;) Pokud do toho pujdem, prozkoumal bych vzorovou integraci https://github.com/LemonAppDev/konsist/tree/develop/samples/starter-projects/konsist-starter-kmp-gradle-kotlin-junit5 a https://github.com/LemonAppDev/konsist/tree/develop/samples/starter-projects/konsist-starter-kmp-gradle-kotlin-kotest a jeste bych zvazil, zda neprejit na JUnit5 (to ted netusim, jestli to ma nejake potencialni problemy) |
1815086 to
165b503
Compare
8919ef5 to
608b229
Compare
165b503 to
3f26286
Compare
608b229 to
8c0e947
Compare
a71b0fc to
cf5abb4
Compare
…les to match contents.
…endencies() extension.
…, rfc ModulesStructureTest
53cbc18 to
23cb0d4
Compare
| @@ -0,0 +1,5 @@ | |||
| package config | |||
|
|
|||
| const val NAMESPACE_ID = "cz.quanti.rocketapp" | |||
There was a problem hiding this comment.
sloucil jsem const do build-logic, at se definuji jen jednou. Btw, build-logic uz je asi naming convention v gradle 8.5 a 8.8 https://docs.gradle.org/current/userguide/intro_multi_project_builds.html
| apply(pluginId("kotlin-serialization")) | ||
| } | ||
| extensions.configure<ApplicationExtension> { | ||
| namespace = "$NAMESPACE_ID.$ANDROID_MODULE_ID" |
There was a problem hiding this comment.
rfc dle novych projektu
| class ArchitectureLayersTest { | ||
| @Test | ||
| fun `clean architecture layers have correct dependencies`() { | ||
| // TODO handle MainApplication.kt |
There was a problem hiding this comment.
jak resis main application, ktera zavisi na DI?
| implementation(libs.library("test-coroutines")) | ||
|
|
||
| // Add SLF4J NOP to get rid of error message in ktor test. | ||
| implementation(libs.library("slf4j-nop")) |
There was a problem hiding this comment.
pridal jsem NOP logger, koukni, jestli neznas
| } | ||
|
|
||
| android { | ||
| buildFeatures.buildConfig = true |
There was a problem hiding this comment.
pres buildConfig predam hodnoty z build-logic
| .apply { | ||
| assertArchitecture { | ||
| ArchitectureLayer.entries.forEach { layer -> | ||
| if (isLayerEmpty(layer)) { |
There was a problem hiding this comment.
trochu jsem to tu refaktoroval, koukni, jestli to dava smysl
| import com.lemonappdev.konsist.api.architecture.Layer | ||
|
|
||
| enum class ArchitectureLayer(val layerName: String) { | ||
| /** |
There was a problem hiding this comment.
pridal jsem commenty viz wiki
| return Layer(name, "${PackagePatterns.ROOT_PACKAGE}..$layerName..") | ||
| } | ||
|
|
||
| fun ArchitectureLayer.dependencies(): List<ArchitectureLayer> = when (this) { |
There was a problem hiding this comment.
udelal jsem extension na dependencies, prijde mi to citelnejsi nez primo v testu. Nelze dat dependecy primo do enum, protoze je to cyklicka zavislost..
| fun Konsist.appScope(): KoScope = scopeFromModules(modulesInScope) | ||
|
|
||
| fun Konsist.allScope(): KoScope = scopeFromProject() | ||
| .minus(Konsist.scopeFromModule("build-logic.*")) |
There was a problem hiding this comment.
mozna tohle jeste extrahovat
| } | ||
| } | ||
|
|
||
| // TODO add tests for Repositories and domain models (Azure task number: 89759) |
There was a problem hiding this comment.
co vsechno za testy chceme pridat?
|
|
||
| import com.lemonappdev.konsist.api.architecture.Layer | ||
|
|
||
| enum class Module(val moduleType: ModuleType, val platform: Platform) { |
There was a problem hiding this comment.
dal jsem dohromady modul a platform, at je to citelnejsi. Plus doc z wiki a dependency jako u layers
| import cz.quanti.rocketapp.android.architecturetest.BuildConfig | ||
|
|
||
| object PackagePatterns { | ||
| const val ROOT_PACKAGE = BuildConfig.ROOT_PACKAGE |
There was a problem hiding this comment.
tady to z build configu taham
| import cz.quanti.rocketapp.android.architecturetest.BuildConfig | ||
|
|
||
| enum class Platform(val platformName: String) { | ||
| Android(BuildConfig.ANDROID_ID), |
| * so the caller is responsible for checking there is a message to show. | ||
| */ | ||
| @Composable | ||
| fun UiScreenState.Data<*>.ShowMessageInSnackBar() { |
There was a problem hiding this comment.
nevim, jestli je to idealni deleni, donutila me k tomu architektura - pouzivam zde localSnackbar ze system, a presentetion UiScreenState nemuze zaviset na system..
| "${PackagePatterns.ANDROID_ID}.*", | ||
| ) | ||
|
|
||
| fun Konsist.appScope(): KoScope = scopeFromModules(modulesInScope) |
There was a problem hiding this comment.
appScope predpoklada, ze neni zadny jinak pojmenovany modul
| val arg = dependencies.first() | ||
| val args = dependencies.drop(1) | ||
| .toTypedArray() | ||
| thisLayer.dependsOn(arg, *args) |
There was a problem hiding this comment.
tohle je trochu divne, ze knihovna ma fci s parametry (X, vararg X ) nebo neco takoveho
|
|
||
| private fun String.toModuleNameInPackage(): String { | ||
| return this | ||
| .replace('\\', '/') |
There was a problem hiding this comment.
win stroje potrebuji zmenit lomitka
I have checked arch unit test libraries and implement sample with
Konsist. If we go to use it, I can cover with more tests. If we have another library/solution, let's park now.