/jqassistant-gradle-plugin

Gradle Plugin for jQAssistant

Primary LanguageJava

jQAssistant Gradle plugin

This is the first snapshot of a Gradle plugin for jQAssistant. Currently supported are:

  • all jQAssistant tasks: scan, analyze, server, report, available-scopes, available-rules, effective-rules, effective-configuration, reset, list-plugins

  • giving any options defined for the CLI

  • configuring the jQAssistant version (default is 2.1.0)

  • configuring the neo4J Version (4 or 5, default depends on Java version)

  • configuring additional plugins (Java plugin is added by default)

  • configuring additional artifacts to be scanned (Java compile output is added by default)

  • configuring .jqassistant config file location

  • single module and multi module projects

Requirements

  • Java 11 or 17 (see gradle compatibility below)

  • Gradle 6.9 - 8.8 (see gradle compatibility below)

To increase compatibility with older java version, this plugin uses jQAssistants neo4Jv4 variant of jQA 2

Usage

For a sample project check out the example project in this repository. The build.gradle file gives an overview of how to apply and configure the plugin. The .jqassistant.yml gives an example of how to configure jQAssistant. For more information, check out the jQAssistant User Manual

Add in your Gradle project in question the plugin via

plugins {
    id "de.kontext_e.jqassistant.gradle" version "2.1.0"
}

or

buildscript {
    repositories {
        mavenLocal()
    }
    dependencies {
        classpath 'de.kontext_e.jqassistant.gradle:jqassistant-gradle-plugin:2.1.0'
    }
}

and apply the plugin

apply plugin: 'de.kontext_e.jqassistant.gradle'

Now you can simply call

./gradlew scan

or

./gradlew analyze

Configuration

You can go with the defaults or configure the plugin, e.g. this way:

project.ext["jqaversion"] = "1.9.1"
project.ext["kejqapluginversion"] = "1.7.0"
jqassistant {
    toolVersion = "${project.jqaversion}"
    neo4jVersion 5
    configFile "jqassistant/.jqassistant.yml"
    //Deprecated but still work
    plugins "com.buschmais.jqassistant.plugin:junit:${project.jqaversion}"
    plugins "de.kontext-e.jqassistant.plugin:jqassistant.plugin.git:${project.kejqapluginversion}"
    options "-reset"
    //Deprecated, only works when no config file is used
    scanDirs ".git"
}

Note that if you have multiple options, config files or scanDirs, just add multiple lines as seen with plugins, e.g.

scanDirs ".git"
scanDirs "doc/arc42"

If there is no specific neo4J version declared, the plugin choses the latest version compatible with the current java version (see compatibility matrix below).

If a version is specified it is chosen, unless it is incompatible. In that case the plugin also falls back to the latest compatible version.

Note that when changing the neo4J version, the store folder in the jqassistant folder in the project root must be deleted.

Tested Gradle Versions

Compatibility Matrix: The content of the cell are the jQAssistant neo4J-versions, that work given the gradle and java versions

Java 11 Java 17 Java 21

gradle 8.5 - 8.8

v4

v4 & v5

v5

gradle 7.3 - 8.4

v4

v4 & v5

gradle (6.8)/7.0 - 7.2

v4

6.8 and below: does not work (version 1.0.1-SNAPSHOT works down to 4.10)

Tested jQAssistant Versions

  • 2.1.0

  • for jqa 1.X use version 1.0.1-SNAPSHOT version of this Plugin