Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: 'maven'
on:
workflow_dispatch:
pull_request:
paths:
- 'maven/**'
- 'plugin/src/main/kotlin/org/jetbrains/qodana/Qodana.kt'
- 'plugin/src/main/kotlin/org/jetbrains/qodana/Checksums.kt'
- 'plugin/src/main/kotlin/org/jetbrains/qodana/Version.kt'
push:
branches:
- main
- 'releases/*'
paths:
- 'maven/**'
- 'plugin/src/main/kotlin/org/jetbrains/qodana/Qodana.kt'
- 'plugin/src/main/kotlin/org/jetbrains/qodana/Checksums.kt'
- 'plugin/src/main/kotlin/org/jetbrains/qodana/Version.kt'

permissions:
contents: read
packages: read

jobs:
maven-test:
name: maven-test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- windows-latest
- ubuntu-latest
- macos-latest
steps:
- name: Fetch sources
uses: actions/checkout@v6

- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: zulu
java-version: 17
cache: maven

- name: Build and install plugin
run: |
cd maven
mvn clean install -DskipTests

- name: Run unit tests
run: |
cd maven
mvn test

- name: Run integration tests
run: |
cd maven
mvn failsafe:integration-test failsafe:verify

- name: Collect test results
if: ${{ failure() }}
uses: actions/upload-artifact@v5
with:
name: maven-test-results-${{ runner.os }}
path: |
maven/target/surefire-reports
maven/target/failsafe-reports
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,51 @@ jobs:
tfx extension publish --publisher JetBrains --vsix qodana.vsix -t $AZURE_TOKEN
env:
AZURE_TOKEN: ${{ secrets.AZURE_TOKEN }}

maven:
runs-on: ubuntu-latest
steps:
- name: Extract version from tag
run: |
TAG_NAME=${GITHUB_REF##*/}
VERSION=$(echo $TAG_NAME | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
echo "VERSION=${VERSION}" >> $GITHUB_ENV

- uses: actions/checkout@v6

- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: zulu
java-version: 17
cache: maven

- name: Import GPG key
run: |
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
gpgconf --reload gpg-agent

- name: Configure Maven settings
run: |
mkdir -p ~/.m2
cat > ~/.m2/settings.xml << 'EOF'
<settings>
<servers>
<server>
<id>central</id>
<username>${env.MAVEN_CENTRAL_USERNAME}</username>
<password>${env.MAVEN_CENTRAL_PASSWORD}</password>
</server>
</servers>
</settings>
EOF

- name: Update version and publish
run: |
cd maven
mvn versions:set -DnewVersion=${{ env.VERSION }} -DgenerateBackupPoms=false
mvn clean deploy -Prelease -DskipTests -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }}
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
102 changes: 102 additions & 0 deletions MAVEN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Qodana for Maven

[![official JetBrains project](https://jb.gg/badges/official.svg)][jb:confluence-on-gh]
[![GitHub Discussions](https://img.shields.io/github/discussions/jetbrains/qodana)][jb:discussions]
[![Twitter Follow](https://img.shields.io/badge/follow-%40Qodana-1DA1F2?logo=twitter)][jb:twitter]

Maven interface to run [Qodana](https://jetbrains.com/qodana)

> **Important:**
> This project requires Maven 3.6 or newer. Update it with your package manager or download from [Maven website](https://maven.apache.org/download.cgi).

## Maven Configuration

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

Add the Qodana Maven plugin to your `pom.xml`:

```xml
<build>
<plugins>
<plugin>
<groupId>io.github.qodana</groupId>
<artifactId>qodana-maven-plugin</artifactId>
<version>2025.3.1</version>
</plugin>
</plugins>
</build>
```

### Plugin Configuration

Properties available for configuration in the plugin:

| Name | Description | Type | Default Value |
|--------------|----------------------------------------------|----------------|----------------------------------------------|
| `projectDir` | Path to the project folder to inspect. | `File` | `${project.basedir}` |
| `resultsDir` | Path to the directory to store results. | `File` | `${project.build.directory}/qodana/results` |
| `cacheDir` | Path to the directory to store cache. | `File` | `${project.build.directory}/qodana/cache` |
| `qodanaDir` | Path to store the Qodana CLI binary. | `File` | `${project.build.directory}/qodana` |
| `arguments` | List of custom Qodana CLI `scan` arguments. | `List<String>` | `[]` |
| `useNightly` | Use a nightly version of Qodana CLI. | `Boolean` | `false` |

## Maven Qodana Goals

### `qodana:scan`

Start Qodana analysis in the project directory.

The goal downloads the Qodana CLI binary automatically (with checksum verification) and executes it with the configured arguments.

### Example

Add this to your `pom.xml`:

```xml
<build>
<plugins>
<plugin>
<groupId>io.github.qodana</groupId>
<artifactId>qodana-maven-plugin</artifactId>
<version>2025.3.1</version>
<configuration>
<resultsDir>${project.build.directory}/qodana/results</resultsDir>
<arguments>
<argument>--fail-threshold</argument>
<argument>0</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
```

Now you can run inspections with the `qodana:scan` goal:

```bash
mvn qodana:scan
```

### Command Line Configuration

All parameters can be overridden from the command line:

```bash
# Basic scan
mvn qodana:scan

# With custom arguments
mvn qodana:scan -Dqodana.arguments="--fail-threshold,0"

# Custom results directory
mvn qodana:scan -Dqodana.resultsDir=/path/to/results
```

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

A complete guide for options and configuration of `arguments` parameters can be found on [Qodana CLI docs page](https://github.com/JetBrains/qodana-cli#scan).


[jb:confluence-on-gh]: https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub
[jb:discussions]: https://jb.gg/qodana-discussions
[jb:twitter]: https://twitter.com/Qodana
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[versions]
kotlin = "1.8.10"
kotlin = "2.3.0"

# libraries
markdown = "0.5.0"

# plugins
dokka = "1.8.20"
dokka = "1.9.20"
gradlePluginPublish = "1.2.1"
gradleChangelogPlugin = "2.2.0"

Expand Down
1 change: 1 addition & 0 deletions maven/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
Loading
Loading