Files
detekt/docs/pages/gettingstarted/mavenanttask.md
Brais Gabín b5338ed4b3 Update documentation (#2617)
* Update --help output

* Document the different ways to install detekt

* Update how to install the cli in the readme

* Use the current version of detekt in our documentation

* Don't use the java -jar way to run detekt as an example

* fix language metadata
2020-04-20 15:30:43 +02:00

2.1 KiB

title, keywords, sidebar, permalink, folder, summary
title keywords sidebar permalink folder summary
Run detekt using Maven Ant Task maven anttask mavenanttask.html gettingstarted
  1. Add following lines to your pom.xml.
  2. Run mvn verify (when using the verify phase as we are doing here)
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.8</version>
            <executions>
                <execution>
                    <!-- This can be run separately with mvn antrun:run@detekt -->
                    <id>detekt</id>
                    <phase>verify</phase>
                    <configuration>
                        <target name="detekt">
                            <java taskname="detekt" dir="${basedir}"
                                  fork="true" 
                                  failonerror="true"
                                  classname="io.gitlab.arturbosch.detekt.cli.Main"
                                  classpathref="maven.plugin.classpath">
                                <arg value="--input"/>
                                <arg value="${basedir}/src/main/kotlin"/>
                                <arg value="--excludes"/>
                                <arg value="**/special/package/internal/**"/>
                                <arg value="--report"/>
                                <arg value="xml:${basedir}/reports/detekt.xml"/>
                                <arg value="--baseline"/>
                                <arg value="${basedir}/reports/baseline.xml"/>
                            </java>
                        </target>
                    </configuration>
                    <goals><goal>run</goal></goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>io.gitlab.arturbosch.detekt</groupId>
                    <artifactId>detekt-cli</artifactId>
                    <version>{{ site.detekt_version }}</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>