I have 2 Gradle projects both inside the same directory. The directory structure is as follows:
ParentDirectory\
GradleProjectA\
build.gradle
GradleProjectB\
settings.gradle
build.gradle
I want to add GradleProjectA
as a dependency to GradleProjectB
. In the settings.gradle
for GradleProjectB
, I've tried adding include 'GradleProjectA'
and then in build.gradle
: compile project(':GradleProjectA')
but that didn't work.
Any help would be greatly appreciated. Thanks.
The local build cache uses a system directory to store tasks outputs. The default location is the Gradle user home directory that points to $USER_HOME/. gradle/caches. Every time we run the build in our system, artifacts will be stored here.
A project dependency is a special form of an execution dependency. It causes the other project to be built first and adds the jar with the classes of the other project to the classpath. It also adds the dependencies of the other project to the classpath. You can trigger a gradle :api:compile .
To add a dependency to your project, specify a dependency configuration such as implementation in the dependencies block of your module's build.gradle file.
If the project requires a specific version of a dependency on a configuration-level then it can be achieved by calling the method ResolutionStrategy. force(java. lang. Object[]).
The way I did something like this is as follows:
GradleProjectB/settings.gradle
:
include ':GradleProjectA'
project(':GradleProjectA').projectDir = new File('../GradleProjectA')
GradleProjectB/build.gradle
:
compile project(":GradleProjectA")
In the latest version of Gradle, you can use Composite Builds, like that:
In GradleProjectB's settings.gradle, add the following line:
includeBuild "../GradleProjectA"
It will automatically handle dependency collisions and all that stuff.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With