I have the following structure and i want to include integration-jvm-1
as a dependency inside module-mp-1
and inside application-jvm-1
, i want to include module-mp-1
's JVM output as dependency.
See the sample project on Github: https://github.com/JVAAS/kotlin-multiplatform-multi-module-setup
Here's the overview of what i've done so far:
generic-project
+-- applications
+-- application-jvm-1
+-- integrations
+-- integration-jvm-1
+-- modules
+-- module-mp-1
build.gradle.kts
settings.gradle.kts
my build.gradle.kts
is empty, settings.gradle.kts
is as follow:
rootProject.name = "generic-project"
include("applications:application-jvm-1")
include("modules:module-mp-1")
include("integrations:integration-jvm-1")
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
maven {
url = uri("https://dl.bintray.com/kotlin/kotlin-eap")
}
}
}
applications/application-jvm-1/build.gradle.kts
is as follow
(note the api(project(":modules:module-mp-1"))
dependency)
plugins {
val kotlinVersion = "1.4-M2"
application
kotlin("multiplatform") version kotlinVersion
kotlin("plugin.serialization") version kotlinVersion
}
group = "com.generic.applications"
version = "1.0.0"
repositories {
jcenter()
mavenCentral()
maven {
url = uri("https://dl.bintray.com/kotlin/kotlin-eap")
}
maven {
url = uri("https://kotlin.bintray.com/kotlinx")
}
gradlePluginPortal()
}
kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "11"
}
}
sourceSets {
val serializationVersion = "0.20.0-1.4-M2"
val coroutinesVersion = "1.3.7-1.4-M2"
val jvmMain by getting {
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("reflect"))
api(project(":modules:module-mp-1"))
}
}
val jvmTest by getting {
dependencies {
implementation(kotlin("test-junit"))
}
}
all {
languageSettings.enableLanguageFeature("InlineClasses")
}
}
}
application {
mainClassName = "Application"
}
integrations/integration-jvm-1/build.gradle.kts
is as follow:
plugins {
val kotlinVersion = "1.4-M2"
kotlin("multiplatform") version kotlinVersion
kotlin("plugin.serialization") version kotlinVersion
}
group = "com.generic.integrations"
version = "1.0.0"
repositories {
jcenter()
mavenCentral()
maven {
url = uri("https://dl.bintray.com/kotlin/kotlin-eap")
}
maven {
url = uri("https://kotlin.bintray.com/kotlinx")
}
gradlePluginPortal()
}
kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "11"
}
}
sourceSets {
val serializationVersion = "0.20.0-1.4-M2"
val coroutinesVersion = "1.3.7-1.4-M2"
val jvmMain by getting {
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("reflect"))
// logging
val slf4jVersion = "1.7.25"
val logbackVersion = "1.2.3"
implementation("org.slf4j:slf4j-api:$slf4jVersion")
implementation("org.slf4j:jcl-over-slf4j:$slf4jVersion")
implementation("org.slf4j:jul-to-slf4j:$slf4jVersion")
implementation("org.slf4j:log4j-over-slf4j:$slf4jVersion")
implementation("ch.qos.logback:logback-classic:$logbackVersion")
}
}
val jvmTest by getting {
dependencies {
implementation(kotlin("test-junit"))
}
}
all {
languageSettings.enableLanguageFeature("InlineClasses")
}
}
}
/modules/module-mp-1/build.gradle.kts
is as follow:
(note the dependency api(project(":integrations:integration-jvm-1"))
)
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.4-M2"
}
group = "com.generic.modules"
version = "1.0.0"
repositories {
mavenCentral()
jcenter()
maven {
url = uri("https://dl.bintray.com/kotlin/kotlin-eap")
}
}
dependencies {
testImplementation(kotlin("test-junit5"))
implementation(kotlin("stdlib-jdk8"))
// ktor
val ktorVersion = "1.3.1"
//implementation("io.ktor:ktor-server-netty:$ktorVersion")
implementation("io.ktor:ktor-server-cio:$ktorVersion")
implementation("io.ktor:ktor-html-builder:$ktorVersion")
implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.7.1")
// logging
val slf4jVersion = "1.7.25"
val logbackVersion = "1.2.3"
implementation("org.slf4j:slf4j-api:$slf4jVersion")
implementation("org.slf4j:jcl-over-slf4j:$slf4jVersion")
implementation("org.slf4j:jul-to-slf4j:$slf4jVersion")
implementation("org.slf4j:log4j-over-slf4j:$slf4jVersion")
implementation("ch.qos.logback:logback-classic:$logbackVersion")
api(project(":integrations:integration-jvm-1"))
}
tasks.withType<KotlinCompile>() {
kotlinOptions.jvmTarget = "11"
}
When i pull Generic Project into IntelliJ and do a gradle refresh, i'm not getting error, but i'm also unable to get it to compile when i use module dependencies inside application
import com.generic.modules.Module1 <<-- unresolved reference modules
object Application {
@JvmStatic
fun main(args: Array<String>) {
println("TEST")
println(Module1().toString())
}
}
Any ideas? I've made a sample project on Github with all of the above https://github.com/JVAAS/kotlin-multiplatform-multi-module-setup
If this directory structure is making it more difficult than it should be, then i'm happy to change that too. Just want dependencies working one way or another.