Multi-Project Test Dependencies in Gradle
When working with multi-project configurations in Gradle, managing dependencies for tests across projects can be challenging. This article explores a common issue where test dependencies from one module are not recognized in another module, focusing on the specific example encountered by the user.
The user has a multi-project configuration with two projects, A and B. Project A contains both main and test source code, while Project B depends on the main code from Project A. However, when compiling the test Java code in Project B, the test files from Project A are not included.
The problem lies in the dependency configuration of Project B. To resolve this, the user needs to add a testCompile dependency to Project B's build.gradle file. This will instruct Gradle to include the test sources from Project A as well:
dependencies { ... testCompile project(':A').sourceSets.test.output }
This approach has been tested with Gradle version 1.7 and has been deprecated for Gradle versions 5.6 and above. For updated information on managing multi-project test dependencies in Gradle, please refer to the relevant documentation or community resources.
The above is the detailed content of How to Include Test Dependencies Across Modules in a Multi-Project Gradle Configuration?. For more information, please follow other related articles on the PHP Chinese website!