Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ Build, then initialize the generated root graph:
StitchInjector.init(StitchSingletonGraph())
```

For multi-module projects, other modules should apply this Gradle plugin:

```kotlin
plugins {
id("io.github.harrytmthy.stitch") version "1.0.0-rc01"
}
```

Add other scopes, where each scope represents a generated graph:

```kotlin
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref
koin-compiler = { id = "io.insert-koin.compiler.plugin", version.ref = "koinCompiler" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublishPlugin" }
stitch = { id = "io.github.harrytmthy.stitch", version.ref = "stitch" }

# Convention Plugins
stitch-android-library = { id = "stitch.android.library" }
Expand Down
5 changes: 1 addition & 4 deletions samples/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
plugins {
alias(libs.plugins.stitch.android.library)
alias(libs.plugins.ksp)
alias(libs.plugins.stitch)
}

android {
Expand All @@ -28,10 +29,6 @@ android {
create("withDagger") { dimension = "di" }
create("withNone") { dimension = "di" }
}

ksp {
arg("stitch.moduleName", "Core")
}
}

dependencies {
Expand Down
5 changes: 1 addition & 4 deletions samples/feature/home/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
plugins {
alias(libs.plugins.stitch.android.library)
alias(libs.plugins.ksp)
alias(libs.plugins.stitch)
}

android {
Expand All @@ -28,10 +29,6 @@ android {
create("withDagger") { dimension = "di" }
create("withNone") { dimension = "di" }
}

ksp {
arg("stitch.moduleName", "FeatureHome")
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ class StitchSymbolProcessor(private val environment: SymbolProcessorEnvironment)
val logger = environment.logger
logger.info("Stitch: Starting dependency injection code generation")
try {
val moduleName = getOption("stitch.moduleName")
val moduleKey = moduleName.toModuleKey()
val localScanResult = LocalScanResult()
LocalAnnotationScanner(resolver, localScanResult).scan()
if (!localScanResult.isAggregator) {
val moduleName = getModuleName()
val moduleKey = moduleName.toModuleKey()
ContributionCodeGenerator(environment.codeGenerator)
.generate(moduleName, moduleKey, localScanResult)
} else {
Expand All @@ -76,9 +76,9 @@ class StitchSymbolProcessor(private val environment: SymbolProcessorEnvironment)
return emptyList()
}

private fun getOption(name: String): String =
environment.options[name] ?: throw StitchProcessingException(
"Missing KSP option '$name'. Configure via ksp { arg(...) } or apply 'io.github.harrytmthy.stitch' plugin.",
private fun getModuleName(): String =
environment.options["stitch.moduleName"] ?: throw StitchProcessingException(
"Missing KSP option 'stitch.moduleName'. Configure via ksp { arg(...) } or apply 'io.github.harrytmthy.stitch' plugin.",
)

/**
Expand Down
Loading