Home > Java > javaTutorial > body text

How to Include Test Dependencies Across Modules in a Multi-Project Gradle Configuration?

Mary-Kate Olsen
Release: 2024-10-26 19:16:30
Original
711 people have browsed it

How to Include Test Dependencies Across Modules in a Multi-Project Gradle Configuration?

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
}
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!