I have created 2 separate Gradle projects
- Project_A (org.foo.bar:my_lib) - Library, without main.
- Project_B (org.foo.bar:my-app) - A SpringBoot application.
I want to add Project_A as a dependency of Project_B.
I have tried ‘maven-publish’ plugin on Project_A to publish to maven-local, and use mavenLocal() to pull dependencies in Project_B, but it didn’t work.
I have also tried adding my library as dependency like:
But I keep getting error: Could not find com.foo.bar:my_lib:0.0.1…
Need help in resolving dependencies across multiple projects.
You should be very careful when using
It is broken by design and I’d recommend to avoid it whenever you can.
If you really need to publish-then-consume with local projects, better use some other directory as local file repository.
implementation project(‘:my_lib:0.0.1’) only works for projects within the same multi-project build, not with published libraries.
implementation ‘com.foo.bar:my_lib:0.0.1’ should have worked if that actually was what you published. Check Maven Local directory what got published there and / or the result of
./gradlew outgoingVariants in Project_A.
Actually, if the Gradle version in A and B are compatible I’d usually rather prefer using composite build feature to combine the builds, then everything is built as needed automatically and you can also work on both together in one IDE, and not have to have two projects open and remember to publish in-between and so on.