diff --git a/core/src/main/kotlin/cash/grammar/kotlindsl/utils/DependencyExtractor.kt b/core/src/main/kotlin/cash/grammar/kotlindsl/utils/DependencyExtractor.kt index bb38133..dc5bbe0 100644 --- a/core/src/main/kotlin/cash/grammar/kotlindsl/utils/DependencyExtractor.kt +++ b/core/src/main/kotlin/cash/grammar/kotlindsl/utils/DependencyExtractor.kt @@ -223,6 +223,7 @@ public class DependencyExtractor( configuration = configuration, identifier = identifier ?: error("Could not determine dependency identifier. Failed to parse expression:\n `$fullText`"), + producerConfiguration = identifier.configuration, capability = capability, type = type.or(identifier), fullText = fullText, @@ -422,10 +423,6 @@ public class DependencyExtractor( val explicitPath = firstKey == "path" || secondKey == "path" if (firstKey == "path" || firstKey == null) { - require(secondKey == "configuration") { - "Expected 'configuration', was '$secondKey'." - } - path = firstValue configuration = secondValue } else { diff --git a/core/src/test/kotlin/cash/grammar/kotlindsl/utils/DependencyExtractorTest.kt b/core/src/test/kotlin/cash/grammar/kotlindsl/utils/DependencyExtractorTest.kt index aeed259..e75addd 100644 --- a/core/src/test/kotlin/cash/grammar/kotlindsl/utils/DependencyExtractorTest.kt +++ b/core/src/test/kotlin/cash/grammar/kotlindsl/utils/DependencyExtractorTest.kt @@ -2,6 +2,7 @@ package cash.grammar.kotlindsl.utils import cash.grammar.kotlindsl.model.DependencyDeclaration import cash.grammar.kotlindsl.model.DependencyDeclaration.Capability +import cash.grammar.kotlindsl.model.DependencyDeclaration.Identifier import cash.grammar.kotlindsl.model.DependencyDeclaration.Identifier.Companion.asSimpleIdentifier import cash.grammar.kotlindsl.model.DependencyDeclaration.Type import cash.grammar.kotlindsl.parse.Parser @@ -209,6 +210,15 @@ internal class DependencyExtractorTest { capability = Capability.DEFAULT, type = Type.PROJECT, ), + TestCase( + displayName = "project dependency on configuration", + fullText = """api(project(":foo", "shadow"))""", + configuration = "api", + identifier = Identifier(path = "\":foo\"", configuration = "\"shadow\""), + capability = Capability.DEFAULT, + type = Type.PROJECT, + producerConfiguration = "\"shadow\"", + ), TestCase( displayName = "testFixtures capability for project dependency", fullText = "testImplementation(testFixtures(project(\":has-test-fixtures\")))", @@ -248,20 +258,45 @@ internal class DependencyExtractorTest { val displayName: String, val fullText: String, val configuration: String, - val identifier: String, + val identifier: Identifier, val capability: Capability, val type: Type, + val producerConfiguration: String? = null, val precedingComment: String? = null ) { - override fun toString(): String = displayName - fun toDependencyDeclaration() = DependencyDeclaration( + constructor( + displayName: String, + fullText: String, + configuration: String, + identifier: String, + capability: Capability, + type: Type, + producerConfiguration: String? = null, + precedingComment: String? = null + ) : this( + displayName = displayName, + fullText = fullText, configuration = configuration, identifier = identifier.asSimpleIdentifier()!!, capability = capability, type = type, - fullText = fullText, + producerConfiguration = producerConfiguration, precedingComment = precedingComment, ) + + override fun toString(): String = displayName + + fun toDependencyDeclaration(): DependencyDeclaration { + return DependencyDeclaration( + configuration = configuration, + identifier = identifier, + capability = capability, + type = type, + fullText = fullText, + producerConfiguration = producerConfiguration, + precedingComment = precedingComment, + ) + } } } diff --git a/recipes/dependencies/src/test/kotlin/cash/recipes/dependencies/DependenciesSimplifierTest.kt b/recipes/dependencies/src/test/kotlin/cash/recipes/dependencies/DependenciesSimplifierTest.kt index e0b3bfc..61f7b03 100644 --- a/recipes/dependencies/src/test/kotlin/cash/recipes/dependencies/DependenciesSimplifierTest.kt +++ b/recipes/dependencies/src/test/kotlin/cash/recipes/dependencies/DependenciesSimplifierTest.kt @@ -66,4 +66,14 @@ internal class DependenciesSimplifierTest { """.trimIndent() ) } + + @Test fun `the project function doesn't require named arguments`() { + DependenciesSimplifier.of( + """ + dependencies { + api(project(":imported-protos", "shadow")) + } + """.trimIndent() + ) + } }