Gradle plugin
Edit page Last modified: 14 October 2021The 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>"
}
note
The latest Gradle Qodana plugin version is currently
0.1.12
.
tip
For details on working with Gradle in IntelliJ IDEA, see the IntelliJ IDEA Gradle documentation.
'qodana { }' extension configuration
To configure the plugin, use the following options in the top level qodana { }
configuration node.
Name | Description | Type | Default Value |
---|---|---|---|
| Automatically pull the latest Qodana Docker image before running the inspection. |
|
|
| Path to the cache directory. |
|
|
| Name of the Qodana Docker container. |
|
|
| Name of the Qodana Docker image. |
|
|
| Docker executable name. |
|
|
| Path to the project folder to inspect. |
|
|
| Path to directory to store the execution results. |
|
|
| Generate HTML report. |
|
|
| Serve an HTML report on |
|
|
| Default port used to serve the HTML report. |
|
|
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.
note
Properties
Name | Description | Type | Default Value |
---|---|---|---|
| Path to the profile file to be mounted as |
|
|
| Path to the list of plugins to be disabled in the Qodana IDE instance to be mounted as |
|
|
| Inspect uncommitted changes and report new problems. |
|
|
| JVM parameters to start the IntelliJ IDEA JVM with. |
|
|
Helper methods
Name | Description |
---|---|
| Adds a new port binding. |
| Mounts a local directory to the given Docker path. |
| Adds an environment variable. |
| Adds a Docker argument to the executed command. |
| Adds a Docker image argument to the executed command. |
tip
For the detailed description of the Qodana IntelliJ Docker image configuration, see Docker Image Configuration.
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, the results path is $projectPath/build/results
resultsPath = "some/output/path"
}
runInspections {
// by default qodana.recommended will be used
profilePath = "./someExternallyStoredProfile.xml"
}
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")
}
tasks {
runInspections {
// by default qodana.recommended will be used
// profilePath.set("./someExternallyStoredProfile.xml")
}
}
To run the inspections, start the runInspections
Gradle task:
gradle runInspections
// or
./gradlew runInspections
Thanks for your feedback!