Qodana 2021.2 Help

Gradle Plugin

official project

The Gradle Qodana plugin provides the Gradle interface to run code inspections from Intellij IDEA. To get started, apply the Gradle plugin org.jetbrains.qodana in the Gradle configuration file.

Add the following to the build.gradle configuration file.

plugins { id "org.jetbrains.qodana" version "<plugin-version>" }

Add the following to the build.gradle.kts configuration file:

plugins { id("org.jetbrains.qodana") version "<plugin-version>" }

'qodana { }' extension configuration

To configure the plugin, use the following options in the top level qodana { } configuration node.

NameDescriptionTypeDefault Value
autoUpdateAutomatically pull the latest Qodana Docker image before running the inspection.Booleantrue
cachePathPath to the cache directory.Stringnull
dockerContainerNameName of the Qodana Docker container.Stringidea-inspections
dockerImageNameName of the Qodana Docker image.Stringjetbrains/qodana:latest
executableDocker executable name.Stringdocker
projectPathPath to the project folder to inspect.Stringproject.projectDir
resultsPathPath to directory to store the execution results.String"${projectPath}/build/results"
saveReportGenerate HTML report.Booleanfalse
showReportServe an HTML report on showReportPort port.Booleanfalse
showReportPortDefault port used to serve the HTML report.Int8080

Gradle Qodana tasks

After the Gradle Qodana plugin is applied and configured, you can run the provided tasks:

runInspections

Starts Qodana code analysis in a Docker container. The task runs according to the qodana { } extension configuration but also provides additional properties and helper methods to configure the Docker image.

Properties

NameDescriptionTypeDefault Value
profilePathPath to the profile file to be mounted as /data/profile.xml.Stringnull
disabledPluginsPathPath to the list of plugins to be disabled in the Qodana IDE instance to be mounted as /root/.config/idea/disabled_plugins.txtStringnull
changesInspect uncommitted changes and report new problems.Booleanfalse
jvmParametersJVM parameters to start the IntelliJ IDEA JVM with.List<String>empty

Helper methods

NameDescription
bind(localPort: Int, dockerPort: Int)Adds a new port binding.
mount(localPath: String, dockerPath: String)Mounts a local directory to the given Docker path.
env(name: String, value: String)Adds an environment variable.
dockerArg(argument: String)Adds a Docker argument to the executed command.
arg(argument: String)Adds a Docker image argument to the executed command.

updateInspections

Pulls the latest Qodana Inspections Docker container. The task automatically runs before runInspections if the qodana.autoUpdate property is set to true.

stopInspections

Stops the Qodana Inspections Docker container.

cleanInspections

Cleans up the Qodana Inspections output directory.

Example

Add the following to the build.gradle configuration file:

plugins { // applies the Gradle Qodana plugin to use it in the project id "org.jetbrains.qodana" version "0.1.12" } qodana { // by default, qodana.recommended will be used profilePath = "./someExternallyStoredProfile.xml" // by default, the results path is $projectPath/build/results resultsPath = "some/output/path" }

Add the following to the build.gradle.kts configuration file:

plugins { // applies the Gradle Qodana plugin to use it in the project id("org.jetbrains.qodana") version "0.1.12" } qodana { // by default, qodana.recommended will be used profilePath.set("./someExternallyStoredProfile.xml") // by default, the results path is $projectPath/build/results resultsPath.set("some/output/path") }

To run the inspections, start the runInspections Gradle task:

gradle runInspections // or ./gradlew runInspections
Last modified: 08 September 2021