Building projects with Gradle

If your project uses the Gradle build system, cd into the directory containing the build.gradle file for the module you wish to build.

For a single-module project, this is typically located at the root of your repository. For a multi-module project, this may be within a sub-directory.

To compile the project, if a gradlew (or gradlew.bat on Windows) file is present, run the ./gradlew build command, otherwise run gradle build.

It is generally preferable to execute Gradle commands using ./gradlew (or gradlew.bat on Windows) rather than gradle if these Gradle Wrapper scripts are present in your project.

In either case, if successful, you should see a BUILD SUCCESSFUL message towards the end of the output from Gradle:

BUILD SUCCESSFUL in 15s
7 actionable tasks: 2 executed, 5 up-to-date

In order to run Diffblue Cover CLI it is essential that your Gradle project builds successfully. If it finds a Gradle project, Cover CLI will call Gradle to determine your project settings. If your Gradle project fails then Cover CLI will exit with an error message (and reason):

ERROR An error was encountered while building the Gradle project at ...

If there is a Gradle wrapper for your project (gradlew, gradlew.bat), Cover CLI will use the wrapper's declared version in preference to your system's installed Gradle version.

Gradle Troubleshooting

If dcover cannot validate the tests it creates due to an incompatibility with the stylecheck used in your environment, you will receive an error message.

If your project uses the Gradle checkstyle plugin (https://docs.gradle.org/current/userguide/checkstyle_plugin.html), amend the build.gradle file to exclude Diffblue tests, as shown in the example below:

tasks.withType(Checkstyle) {
    exclude '**/*DiffblueTest**'
}

results matching ""

    No results matching ""