i am working on gradle project There are interdependent components
for example: there are 2 componenets A and B
A is dependent on B
In build.gradle of component A i have given project reference of B like below mentioned-
if i build component A the dependent component B java files will be compiled but the uts and jar are not built
Is there any way to build dependent components uts and jars ?
Gradle version that i am using is 7.1
What are “uts”?
The jar is not built because Gradle tries to avoid work where possible and just for compiling A, the jar of B is not necessary, but the compiled classes are sufficient.
There are multiple ways to get the
jar, for example
./gradlew :B:jar to build specifically the
B jar, or
./gradlew :B:build to build the
B project including running tests- and assembling all jars like sources jar or JavaDoc jar, or
./gradlew build to do so for all projects in the build.
It really depends on what exactly you want to do.
Uts are the unit test cases
Unit tests are executed if you run the
test task or any that depends on it like
So can we run unit tests of dependent component B ? if yes how can we declare that in dependencies block of component A
No, you cannot declare that in the dependencies block.
And also you shouldn’t.
Maybe you should take a step back and desribe what your actual use-case is / what your situation is / what problem you actually try to solve.
There might be more appropriate solutions than what you are asking for.