I need to add a dependency from an other local pro...
# gradle
p
I need to add a dependency from an other local project. I've followed this SO answer
Copy code
include(":module-name")
project(":module-name").projectDir = File("../../project-dir/")
But I'm getting an error about unrecognized class from
buildSrc
folder of
OtherProject
, from other project
gradle.build
file. Itself
OtherProject
builds fine. Do I need to add
buildSrc
explicitly somehow? Edit. I've tried
includeBuild
as @Vampire suggested, but it doesn't seems working with my KMM module. I'm using this code:
Copy code
includeBuild("../../project-dir/") {
    dependencySubstitution {
        substitute(module("com.project:module-name"))
            .with(project(":module-name"))
    }
}
Which produces the following error
ArtifactNotFoundException: Could not find kotlinx-coroutines-core-1.5.1-native-mt-samplessources.jar
v
What you do is a very bad idea. You add that other build as subproject under your multi-project build. That is in 98.7 % a very bad idea. What you are after is a composite build, where you use
includeBuild
, not
include
and it will automatically substitute the binary dependency on the artifact from that build by a "sub-build". https://docs.gradle.org/current/userguide/userguide_single.html#composite_builds
p
@Vampire Thanks, that seems like the right way to do it, unfortunately it doesn't work with the KMM module 🙄
j
Very similar question I just had myself below!
v
Well, I have no idea about KMM, so if it does not work with a composite build, you probably have to deploy to some local repo manually and then use that in the other project.
l
I am faced with the same problem and created a skeleton project to exemplify the issue: https://youtrack.jetbrains.com/issue/KT-50064