• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Ozsie/detekt-maven-plugin: Maven wrapper for detekt cli

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

Ozsie/detekt-maven-plugin

开源软件地址(OpenSource Url):

https://github.com/Ozsie/detekt-maven-plugin

开源编程语言(OpenSource Language):

Kotlin 100.0%

开源软件介绍(OpenSource Introduction):

Build Status Deploy codecov FOSSA Status Maven Central

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.21.0.1</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.21.0.1 can be configured in the plugin.

Remote configuration

The plugin supports remote config over http and https.

<build>
    <plugins>
        <plugin>
            <groupId>com.github.ozsie</groupId>
            <artifactId>detekt-maven-plugin</artifactId>
            <version>1.21.0.1</version>
            <executions>
                <execution>
                    <phase>verify</phase>
                    <goals><goal>check</goal></goals>
                    <configuration>
                        <plugins>
                            <config>https://raw.githubusercontent.com/Ozsie/detekt-maven-plugin/fd0de6d59e6ae1e062a9d2b030a171da1d3225ab/src/test/resources/resolve-config/remote/remote-config.yml</config>
                        </plugins>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Using plugin

<build>
    <plugins>
        <plugin>
            <groupId>com.github.ozsie</groupId>
            <artifactId>detekt-maven-plugin</artifactId>
            <version>1.21.0.1</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.21.0.1</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.21.0.1</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.21.0.1</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>

Set baseline

First a baseline file needs to be generated

mvn detekt:cb

This will generate a baseline file for each module named as baseline-<module-name>.xml. For more information on generating baselines, see create-baseline. You can now reference the baseline file in your configuration, as below.

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

Using Type Resolution

See Issue #144 for an explanation.

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.2.0</version>
            <executions>
                <execution>
                    <id>generate-classpath-var</id>
                    <phase>package</phase>
                    <goals><goal>build-classpath</goal></goals>
                    <configuration>
                        <outputProperty>generated.classpath</outputProperty>
                        <silent>true</silent>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>com.github.ozsie</groupId>
            <artifactId>detekt-maven-plugin</artifactId>
            <version>1.21.0.1</version>
            <configuration>
                <baseline>baseline.xml</baseline>
                <classPath>${generated.classpath}</classPath>
                <jvmTarget>17</jvmTarget>
            </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




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
ZipCodeCore/Maven.Quiz5发布时间:2022-08-17
下一篇:
qcadoo/qcadoo-maven-plugin: Qcadoo Framework - Maven Plugin发布时间:2022-08-17
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap