Skip to content

Latest commit

 

History

History
119 lines (86 loc) · 4.33 KB

GRADLE.md

File metadata and controls

119 lines (86 loc) · 4.33 KB

Qodana for Gradle

official JetBrains project Gradle Plugin Portal GitHub Discussions Twitter Follow

Gradle interface to run Qodana

Important: This project requires Gradle 6.6 or newer; however, it is recommended to use the latest Gradle available. Update it with:

./gradlew wrapper --gradle-version=VERSION

Gradle Configuration

Note: Make sure you have docker installed and available in your environment if you want to run Qodana in a container.

Apply Gradle plugin org.jetbrains.qodana in the Gradle configuration file:

  • Groovy – build.gradle

    plugins {
        id "org.jetbrains.qodana" version "2024.2.5"
    }
  • Kotlin DSL – build.gradle.kts

    plugins {
        id("org.jetbrains.qodana") version "2024.2.5"
    }

Note: The latest version is:

qodana { } extension configuration

Properties available for configuration in the qodana { } top-level configuration closure:

Name Description Type Default Value
projectPath Path to the project folder to inspect. String project.projectDir
resultsPath Path to the directory to store task results. String "${projectPath}/build/qodana/results"
cachePath Path to the directory to store the generated report. String "${projectPath}/build/qodana/cache/"

Gradle Qodana Tasks

qodanaScan

Start Qodana in the project directory.

The task relies on the qodana { } extension configuration. However, it is also controlled by provided arguments.

Example

Add this to your Gradle configuration file:

  • Groovy – build.gradle

    plugins {
        // applies Gradle Qodana plugin to use it in project
        id "org.jetbrains.qodana" version "2024.2.5"
    }
    
    qodana {
        // by default result path is $projectPath/build/results
        resultsPath = "some/output/path"
    }
    
    tasks.qodanaScan {
        arguments = ["--fail-threshold", "0"]
    }
  • Kotlin – build.gradle.kts

    plugins {
        // applies Gradle Qodana plugin to use it in project
        id("org.jetbrains.qodana") version "2024.2.5"
    }
    
    qodana {
        // by default result path is $projectPath/build/results
        resultsPath.set("some/output/path")
    }
    
    tasks.qodanaScan {
        resultsPath.set("some/output/path")
        arguments.set(listOf("--fail-threshold", "0"))
    }

Note: Docker requires at least 4GB of memory. Set it in the Docker Preferences > Resources > Memory section.

Now you can run inspections with qodanaScan Gradle task:

gradle qodanaScan 
// or
./gradlew qodanaScan

A complete guide for options and configuration of arguments parameters can be found on Qodana CLI docs page.