diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml
new file mode 100644
index 00000000..2649b7bb
--- /dev/null
+++ b/.idea/deploymentTargetSelector.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/facades/CodeOutputStreamMaker.kt b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/facades/CodeOutputStreamMaker.kt
index 4632d95c..71e7457b 100644
--- a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/facades/CodeOutputStreamMaker.kt
+++ b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/facades/CodeOutputStreamMaker.kt
@@ -10,4 +10,6 @@ interface CodeOutputStreamMaker {
extensionName: String = "kt",
vararg sourceIds: String,
): OutputStream
+
+ val packageNamesWrittenTo: List
}
\ No newline at end of file
diff --git a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/model/SubModuleInfo.kt b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/model/SubModuleInfo.kt
index 056a02cb..54aa470e 100644
--- a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/model/SubModuleInfo.kt
+++ b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/model/SubModuleInfo.kt
@@ -3,6 +3,7 @@ package com.ramcosta.composedestinations.codegen.model
data class SubModuleInfo(
val name: String?,
val genPackageName: String,
+ val hasNavArgsPackage: Boolean,
val topLevelGraphs: List,
val publicResultSenders: List
)
diff --git a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/ArgsToSavedStateHandleUtilsWriter.kt b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/ArgsToSavedStateHandleUtilsWriter.kt
index 656f09f5..7b265e76 100644
--- a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/ArgsToSavedStateHandleUtilsWriter.kt
+++ b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/ArgsToSavedStateHandleUtilsWriter.kt
@@ -73,7 +73,11 @@ $VISIBILITY_PLACEHOLDER fun $ARGS_DATA_CLASS_SIMPLE_NAME.toSavedStateHandle(
}
// add nav args packages as imports so we can delegate start route args to submodules generated code
- setOfImportable(*submodules.map { "${it.genPackageName}.navargs.*" }.toTypedArray()).forEach {
+ setOfImportable(
+ *submodules.mapNotNull { subModule ->
+ "${subModule.genPackageName}.navargs.*".takeIf { subModule.hasNavArgsPackage }
+ }.toTypedArray()
+ ).forEach {
importableHelper.addPriorityQualifiedImport(it)
}
diff --git a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/ModuleRegistryWriter.kt b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/ModuleRegistryWriter.kt
index 8e470e00..21d0e824 100644
--- a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/ModuleRegistryWriter.kt
+++ b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/ModuleRegistryWriter.kt
@@ -53,6 +53,7 @@ internal class ModuleRegistryWriter(
annotation class _Info_$registryId(
val moduleName: String,
val packageName: String,
+ val hasNavArgsPackage: Boolean,
val typeResults: Array<_Destination_Result_Info_$registryId> = emptyArray(),
val topLevelGraphs: Array = emptyArray()
)
@@ -66,6 +67,7 @@ internal class ModuleRegistryWriter(
@_Info_$registryId(
moduleName = "${codeGenConfig.moduleName ?: ""}",
packageName = "$codeGenBasePackageName",
+ hasNavArgsPackage = ${"$codeGenBasePackageName.navargs" in codeGenerator.packageNamesWrittenTo},
typeResults = [
%s1
],
diff --git a/compose-destinations-ksp/src/main/kotlin/com/ramcosta/composedestinations/ksp/codegen/KspCodeOutputStreamMaker.kt b/compose-destinations-ksp/src/main/kotlin/com/ramcosta/composedestinations/ksp/codegen/KspCodeOutputStreamMaker.kt
index b7b54f4c..99ee2ff8 100644
--- a/compose-destinations-ksp/src/main/kotlin/com/ramcosta/composedestinations/ksp/codegen/KspCodeOutputStreamMaker.kt
+++ b/compose-destinations-ksp/src/main/kotlin/com/ramcosta/composedestinations/ksp/codegen/KspCodeOutputStreamMaker.kt
@@ -11,6 +11,8 @@ class KspCodeOutputStreamMaker(
private val sourceMapper: KSFileSourceMapper
) : CodeOutputStreamMaker {
+ override val packageNamesWrittenTo = mutableListOf()
+
override fun makeFile(
name: String,
packageName: String,
@@ -28,6 +30,8 @@ class KspCodeOutputStreamMaker(
)
}
+ packageNamesWrittenTo.add(packageName)
+
return codeGenerator.createNewFile(
dependencies = dependencies,
fileName = name,
@@ -35,4 +39,5 @@ class KspCodeOutputStreamMaker(
extensionName = extensionName
)
}
+
}
\ No newline at end of file
diff --git a/compose-destinations-ksp/src/main/kotlin/com/ramcosta/composedestinations/ksp/processors/Processor.kt b/compose-destinations-ksp/src/main/kotlin/com/ramcosta/composedestinations/ksp/processors/Processor.kt
index c537cc69..a4c71889 100644
--- a/compose-destinations-ksp/src/main/kotlin/com/ramcosta/composedestinations/ksp/processors/Processor.kt
+++ b/compose-destinations-ksp/src/main/kotlin/com/ramcosta/composedestinations/ksp/processors/Processor.kt
@@ -107,6 +107,7 @@ class Processor(
SubModuleInfo(
name = it.findArgumentValue("moduleName"),
genPackageName = it.findArgumentValue("packageName")!!,
+ hasNavArgsPackage = it.findArgumentValue("hasNavArgsPackage")!!,
topLevelGraphs = it.findArgumentValue>("topLevelGraphs")!!,
publicResultSenders = it.findArgumentValue>(
"typeResults"