Skip to content

Stepwisepl/detekt-maven-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status codecov FOSSA Status Maven Central Dependabot Status

Detekt Maven Plugin

A maven plugin that wraps the Detekt CLI. It supports the same parameters as the Detekt CLI.

How to use

Basic configuration

<build>
    <plugins>
        <plugin>
            <groupId>com.github.ozsie</groupId>
            <artifactId>detekt-maven-plugin</artifactId>
            <version>1.15.0</version>
            <executions>
                <execution>
                    <phase>verify</phase>
                    <goals><goal>check</goal></goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Using the above configuration, Detekt will scan source files in ${basedir}/src and output the results in ${basedir}/detekt.

All parameters available to Detekt version 1.14.2 can be configured in the plugin.

Using plugin

<build>
    <plugins>
        <plugin>
            <groupId>com.github.ozsie</groupId>
            <artifactId>detekt-maven-plugin</artifactId>
            <version>1.15.0</version>
            <executions>
                <execution>
                    <phase>verify</phase>
                    <goals><goal>check</goal></goals>
                    <configuration>
                        <plugins>
                            <plugin>path/to/plugin.jar</plugin>
                        </plugins>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Or

<build>
    <plugins>
        <plugin>
            <groupId>com.github.ozsie</groupId>
            <artifactId>detekt-maven-plugin</artifactId>
            <version>1.15.0</version>
            <executions>
                <execution>
                    <phase>verify</phase>
                    <goals><goal>check</goal></goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>group</groupId>
                    <artifactId>artifact</artifactId>
                    <version>version</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

Specify report files

<build>
    <plugins>
        <plugin>
            <groupId>com.github.ozsie</groupId>
            <artifactId>detekt-maven-plugin</artifactId>
            <version>1.15.0</version>
            <executions>
                <execution>
                    <phase>verify</phase>
                    <goals><goal>check</goal></goals>
                    <configuration>
                        <report>
                            <report>txt:reports/detekt.txt</report>
                            <report>xml:reports/detekt.xml</report>
                        </report>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Alternatively, the configuration can be placed outside of the <executions>. This allows the configuration be used when running goals standalone

<build>
    <plugins>
        <plugin>
            <groupId>com.github.ozsie</groupId>
            <artifactId>detekt-maven-plugin</artifactId>
            <version>1.15.0</version>
            <configuration>
                <report>
                    <report>txt:reports/detekt.txt</report>
                    <report>xml:reports/detekt.xml</report>
                </report>
            </configuration>
            <executions>
                <execution>
                    <phase>verify</phase>
                    <goals><goal>check</goal></goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Goals

check

Used to run detekt. All cli parameters, excluding -gc and -cb, are available using -Ddetekt.{parameter}

Examples

  • mvn detekt:check -Ddetekt.config=detekt.yml
  • mvn detekt:check -Ddetekt.debug=true

create-baseline

Used to create a baseline. All cli parameters, excluding -gc and -cb, are available using -Ddetekt.{parameter}. By default, a file called baseline.xml will be generated. If you include -Ddetekt.baseline in the call you can specify some other name for the baseline file.

Examples

  • mvn detekt:cb -Ddetekt.config=detekt.yml
  • mvn detekt:cb -Ddetekt.debug=true
  • mvn detekt:cb -Ddetekt.baseline=some-other-baseline.xml
  • mvn detekt:create-baseline -Ddetekt.config=detekt.yml
  • mvn detekt:create-baseline -Ddetekt.debug=true

generate-config

Used to generate a default configuration file

Example

  • mvn detekt:gc
  • mvn detekt:generate-config

For more information on Detekt, have a look at https://github.com/detekt/detekt

Contributors

License

FOSSA Status

Packages

No packages published

Languages

  • Kotlin 100.0%