Simple working example of java rules check

339 Views Asked by At

I fail to find out how to set up jqassistant-maven-plugin to verify the rules in the java plugin on a multi-module maven project.

There is not a lot in the jqassistant documentation about how to configure a plugin. Also I do not see what goal I have to run in order to see some report with the result of the java rules analysis.

I added this to my root pom.xml

        <plugin>
            <groupId>com.buschmais.jqassistant</groupId>
            <artifactId>jqassistant-maven-plugin</artifactId>
            <version>1.9.0</version>
            <configuration>
                <useExecutionRootAsProjectRoot>true</useExecutionRootAsProjectRoot>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>com.buschmais.jqassistant.plugin</groupId>
                    <artifactId>java</artifactId>
                    <version>1.9.0</version>
                </dependency>
            </dependencies>
        </plugin>

When I execute

  1. mvn clean install
  2. mvn jqassistant:scan
  3. mvn jqassistant:analyze

Never do I see anything that looks like some output from jqassistant, except for a xml file that does not contain anything usefull:

<?xml version="1.0" encoding="UTF-8"?>
<jqassistant-report xmlns="http://schema.jqassistant.org/report/v1.8"></jqassistant-report>

When I run mvn jqassistant:effective-rules it always gives the following result:

[INFO] Groups [0]
[INFO] Constraints [0]
[INFO] Concepts [0]

Anyone who has a working example?

1

There are 1 best solutions below

2
Dirk Mahler On

jQAssistant comes with a very limited set of rules that can be applied out-of-the-box for verifying common mistakes (i.e. constraints). As of that the Java plugin mainly provides concepts that may be used if creating your own constraints.

There's one exception to it and that's the Spring plugin. It comes with a set of constraints to enforce best practices if working with the Spring Framework. Nevertheless the constraints need to be activated, the best way to do it is to activate one of the groups spring-boot:Default or spring-boot:Strict:

<plugin>
    <groupId>com.buschmais.jqassistant</groupId>
    <artifactId>jqassistant-maven-plugin</artifactId>
    <version>1.9.0</version>
    <executions>
        <execution>
            <id>default-cli</id>
            <goals>
                <goal>scan</goal>
                <goal>analyze</goal>
            </goals>
            <configuration>
                <groups>
                    <group>spring-boot:Strict</group>
                    <!--
                    <group>spring-boot:Default</group>
                    -->
                    <group>Default</group>
                </groups>
            </configuration>
        </execution>
    </executions>
</plugin>

(see https://101.jqassistant.org/getting-started-spring-boot-maven/)