if i have the following structure and i want to in...
# gradle
j
if i have the following structure and i want to include project-d+e as a dependency inside project b and then again inside project-a how would i set this up?
Copy code
build.gradle.kts
settings.gradle.kts
subprojects
  +-- project-www
  +-- project-a (kotlin jvm)
  +-- project-b (kotlin mp jvm+js)
  +-- project-c (kotlin mp jvm+js)
  +-- project-d (java jvm)
  +-- project-e (kotlin jvm)
inside my settings.gradle.kts (root), i've added
Copy code
include("project-www")
include("project-a")
include("project-b")
...
include("project-e")
what should be going into my
project-b/settings.gradle.kts
and
project-b/build.gradle.kts
in order to pull in that project-d or project-e dependencies? and then i want to include that multiplatform's JVM part in project, would i be following the same steps or should i do something different for including a multiplatform project as dependency?
t
I don’t have settings in project-b and simply have
Copy code
implementation(project(":project-e"))
as dependency in project-b
does it now work in your case?
j
i've tried that yesterday and it doesn't compile i found some multiplatform docs, going to rewrite the build scripts to all be in teh multi platform format to see if that fixes the problem might be worth just writing a bunch of empty projects and getting them linking, then bringing back the dependencies one by one https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#adding-dependencies
t
I don’t have experience with multiplatform, the project I work on is pure jvm
j
then it's likely that what i've done in gradle so far is correct and that multiplatform projects needs a little more config going to work through those docs tonight and report back on what the solution was if i do find it
a
In order to depend on the JVM output of a multiplatform sibling subproject, I had to add this to the consuming project’s build.gradle.kts:
Copy code
configurations {
    val platformAttr = Attribute.of("org.jetbrains.kotlin.platform.type", org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType::class.java)
    all {
        attributes.attribute(platformAttr, org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.jvm)
    }
}
That was necessary to make Gradle pick out the JVM output from the exported multiplatform module. Presumably if the consumer is a multiplatform project, that’s automatically added.
j
where should that be going, in the consuming project's kotlin block or in the root of the build.gradle.kts? i've made a sample github repo, not getting the jvm and js options to compile https://github.com/JVAAS/kotlin-multiplatform-multi-module-setup
got it working in intellij now,
gradle build
is still failing if i run gradle build from the root
a
in the top level of the consuming project’s build file (although
configurations{}
will probably resolve to the right thing even if it’s not top-level, but best to be explicit)
j
seems to work in IntelliJ in both top-level and inside Kotlin block. have moved it to the top-level now is IntelliJ doing something different compared to regular
gradle build
considering IntelliJ is working but gradle build from command line is failing?
got it working, yay intellij seems to be less strict than gradle build
a
IntelliJ’s interpretation does differ sometimes- sometimes things work only one way round, sometimes only the other