# Access source code from a shared Kotlin project - gradle

**URL:** <https://discuss.kotlinlang.org/t/access-source-code-from-a-shared-kotlin-project-gradle/27579>\
**Category:** Support\
**Created:** [November 3, 2023, 5:05pm UTC](https://discuss.kotlinlang.org/t/access-source-code-from-a-shared-kotlin-project-gradle/27579 "2023-11-03T17:05:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saghar\_Pervez-Akhtar](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@Saghar\_Pervez-Akhtar](https://discuss.kotlinlang.org/u/Saghar_Pervez-Akhtar)\
**Post date:** [November 3, 2023, 5:05pm UTC](https://discuss.kotlinlang.org/t/access-source-code-from-a-shared-kotlin-project-gradle/27579/1 "2023-11-03T17:05:20Z")

</div>

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`

```auto
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

```auto
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`

```auto
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**
