# Publish module with dependencies

**URL:** <https://discuss.gradle.org/t/publish-module-with-dependencies/49015>\
**Category:** Help/Discuss\
**Created:** [July 29, 2024, 2:45pm UTC](https://discuss.gradle.org/t/publish-module-with-dependencies/49015 "2024-07-29T14:45:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThomasConstantinBity](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@ThomasConstantinBity](https://discuss.gradle.org/u/ThomasConstantinBity)\
**Post date:** [July 29, 2024, 2:45pm UTC](https://discuss.gradle.org/t/publish-module-with-dependencies/49015/1 "2024-07-29T14:45:42Z")

</div>

Hi,

I’d like to publish a package I’m working on; the project structure is the following:

```gradle
Project/
├── app/ # Android app for demo purposes
│ ├── src/
│ ├── build.gradle
│ └── ...
├── module_3/               
│ ├── src/
│ ├── build.gradle
│ └── ...
├── module_2/          
│ ├── src/
│ ├── build.gradle
│ └── ...
├── module_1/          
│ ├── src/
│ ├── build.gradle
│ └── ...
├── build.gradle
└── settings.gradle

```

module\_1 depends on module\_2 and module\_3. I just want to publish the first module, but when I try to import it on a new project I get an error at build time: ‘Could not resolve \<package\_name\>:\<module\_2\>:unspecified’

module\_1 gradle:

```kotlin
publishing {
    repositories {
        maven {
            url = 
            credentials {
                username = 
                password = 
            }
        }
    }
    publications {
        register<MavenPublication>("gpr") {
            from(components["java"])
        }
    }
}

dependencies {
    implementation(project(":module_2"))
    implementation(project(":module_3"))
}

```

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [July 29, 2024, 6:15pm UTC](https://discuss.gradle.org/t/publish-module-with-dependencies/49015/2 "2024-07-29T18:15:04Z")

</div>

Yes, if you see a need in splitting the code into multiple modules, you should also publish all of these modules and have the dependencies between them. There are surely other ways, but imho they are all dirty and cleanest is to just go the way to the end.
