@@ -38,6 +38,7 @@ import org.gradle.api.tasks.SourceSetContainer
3838import org.gradle.api.tasks.compile.JavaCompile
3939import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
4040import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
41+ import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
4142import org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSet
4243import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile
4344import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
@@ -64,9 +65,15 @@ class WirePlugin : Plugin<Project> {
6465 it.isCanBeConsumed = false
6566 it.isTransitive = false
6667 }
67- project.configurations.create(" protoProjectDependencies " ).also {
68+ project.configurations.create(" protoProjectDependenciesJvm " ).also {
6869 it.isCanBeResolved = true
6970 it.isCanBeConsumed = false
71+ it.attributes { attributesContainer ->
72+ // TODO(Benoit) If another project, on which this one depends, exposes multiple variants,
73+ // Wire won't be able to pick one. We force the resolution to JVM. On the other hand, this
74+ // breaks inter-module dependencies for non-jvm modules. We need to fix it.
75+ attributesContainer.attribute(KotlinPlatformType .attribute, KotlinPlatformType .jvm)
76+ }
7077 }
7178
7279 val androidPluginHandler = { _: Plugin <* > ->
@@ -115,7 +122,7 @@ class WirePlugin : Plugin<Project> {
115122 }
116123 }
117124
118- val projectDependenciesConfiguration = project.configurations.getByName(" protoProjectDependencies " )
125+ val projectDependenciesJvmConfiguration = project.configurations.getByName(" protoProjectDependenciesJvm " )
119126
120127 val outputs = extension.outputs
121128 check(outputs.isNotEmpty()) {
@@ -154,7 +161,7 @@ class WirePlugin : Plugin<Project> {
154161 val projectDependencies =
155162 (protoSourceInput.dependencies + protoPathInput.dependencies).filterIsInstance<ProjectDependency >()
156163 for (projectDependency in projectDependencies) {
157- projectDependenciesConfiguration .dependencies.add(projectDependency)
164+ projectDependenciesJvmConfiguration .dependencies.add(projectDependency)
158165 }
159166
160167 val targets = outputs.map { output ->
@@ -228,7 +235,7 @@ class WirePlugin : Plugin<Project> {
228235 )
229236 }
230237 task.outputDirectories.setFrom(outputDirectories)
231- task.projectDependencies.setFrom(projectDependenciesConfiguration )
238+ task.projectDependencies.setFrom(projectDependenciesJvmConfiguration )
232239 if (extension.protoLibrary) {
233240 task.protoLibraryOutput.set(File (project.libraryProtoOutputPath()))
234241 }
0 commit comments