I am attempting to understand how I can create a dependency in gradle so that its code can be shared across multiple projects I have searched around but haven’t been able to fully understand how this works
I am using Kotlin and Gradle and my understanding is that the best approach (one that I like as well) is to create a separate project that creates a jar, which I can then import (I can later upload this to nexus)
ProjectA
SharedProjectLib
In SharedProjectLib I have the following settings
settings.gradle.kts
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0"
}
rootProject.name = "SharedProjectLib"
in build.gradle.kts
I have
plugins {
`java-library`
kotlin("multiplatform") version "1.9.0"
}
group = "me.user"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
kotlin {
jvm {
jvmToolchain(8)
withJava()
testRuns.named("test") {
executionTask.configure {
useJUnitPlatform()
}
}
}
sourceSets {
val commonMain by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
}
}
After building this project, I have a jar file, which I have moved into the lib folder of ProjectA Now, in the settings I have tried the following build.gradle
plugins {
id 'java'
...
dependencies {
implementation files('lib/SharedProjectLib-jvm-1.0-SNAPSHOT.jar')
...
Thank you
These settings don’t work and there are so many configurations I found online but not sure how to apply them. How can I set ProjectA so that I can access a simple data class object from SharedProjectLib