Detekt CLIをラップするMavenプラグイン。 Detekt CLIと同じパラメーターをサポートします。
構成後の実行方法を参照してください。
< build >
< plugins >
< plugin >
< groupId >com.github.ozsie</ groupId >
< artifactId >detekt-maven-plugin</ artifactId >
< version >1.23.7</ version >
< executions >
< execution >
< phase >verify</ phase >
< goals >< goal >check</ goal ></ goals >
</ execution >
</ executions >
</ plugin >
</ plugins >
</ build >上記の構成を使用すると、Detektは${basedir}/srcでソースファイルをスキャンし、結果を${basedir}/detektに出力します。
Detektバージョン1.23.7で利用可能なすべてのパラメーターは、プラグインで構成できます。
プラグインは、detektに渡される構成としてローカルファイルをサポートします。
< build >
< plugins >
< plugin >
< groupId >com.github.ozsie</ groupId >
< artifactId >detekt-maven-plugin</ artifactId >
< version >1.23.7</ version >
< executions >
< execution >
< phase >verify</ phase >
< goals >< goal >check</ goal ></ goals >
< configuration >
< config >config/detekt/detekt.yml</ config >
</ configuration >
</ execution >
</ executions >
</ plugin >
</ plugins >
</ build >複数のファイルをリストすることができます;セパレーターとして。
プラグインは、HTTPおよびHTTPS上のリモート構成をサポートします。
< build >
< plugins >
< plugin >
< groupId >com.github.ozsie</ groupId >
< artifactId >detekt-maven-plugin</ artifactId >
< version >1.23.7</ version >
< executions >
< execution >
< phase >verify</ phase >
< goals >< goal >check</ goal ></ goals >
< configuration >
< config >https://raw.githubusercontent.com/Ozsie/detekt-maven-plugin/fd0de6d59e6ae1e062a9d2b030a171da1d3225ab/src/test/resources/resolve-config/remote/remote-config.yml</ config >
</ configuration >
</ execution >
</ executions >
</ plugin >
</ plugins >
</ build >Detektは、Detektプラグインにパッケージ化されたルールセット、プロセッサ、レポートなどをサポートしています。
既知のプラグインのリストについては、Detekt Marketplaceを参照してください。
< build >
< plugins >
< plugin >
< groupId >com.github.ozsie</ groupId >
< artifactId >detekt-maven-plugin</ artifactId >
< version >1.23.7</ version >
< executions >
< execution >
< phase >verify</ phase >
< goals >< goal >check</ goal ></ goals >
</ execution >
</ executions >
< dependencies >
<!-- Detekt's first-party unbundled plugin for library authors:
https://detekt.dev/docs/next/rules/libraries -->
< dependency >
< groupId >io.gitlab.arturbosch.detekt</ groupId >
< artifactId >detekt-rules-libraries</ artifactId >
< version >1.23.7</ version >
</ dependency >
</ dependencies >
</ plugin >
</ plugins >
</ build >< build >
< plugins >
< plugin >
< groupId >com.github.ozsie</ groupId >
< artifactId >detekt-maven-plugin</ artifactId >
< version >1.23.7</ version >
< executions >
< execution >
< phase >verify</ phase >
< goals >< goal >check</ goal ></ goals >
< configuration >
< plugins >
< plugin >local/path/to/plugin.jar</ plugin >
</ plugins >
</ configuration >
</ execution >
</ executions >
</ plugin >
</ plugins >
</ build >サポートされているレポートタイプについては、Detektドキュメントを参照してください。
< build >
< plugins >
< plugin >
< groupId >com.github.ozsie</ groupId >
< artifactId >detekt-maven-plugin</ artifactId >
< version >1.23.7</ 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 >または、構成は<executions>の外側に配置できます。これにより、Standaloneを実行するときに構成を使用できます。
< build >
< plugins >
< plugin >
< groupId >com.github.ozsie</ groupId >
< artifactId >detekt-maven-plugin</ artifactId >
< version >1.23.7</ 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 >最初にベースラインファイルを生成する必要があります。
mvn detekt:cbこれによりbaseline-<module-name>.xmlと呼ばれる各モジュールのベースラインファイルが生成されます。ベースラインの生成の詳細については、Create-Baselineを参照してください。以下のように、構成内のベースラインファイルを参照できるようになりました。
< build >
< plugins >
< plugin >
< groupId >com.github.ozsie</ groupId >
< artifactId >detekt-maven-plugin</ artifactId >
< version >1.23.7</ version >
< configuration >
< baseline >baseline.xml</ baseline >
</ configuration >
< executions >
< execution >
< phase >verify</ phase >
< goals >< goal >check</ goal ></ goals >
</ execution >
</ executions >
</ plugin >
</ plugins >
</ build >説明については、問題#144を参照してください。
< 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.23.7</ version >
< configuration >
< baseline >baseline.xml</ baseline >
< classPath >${generated.classpath}</ classPath >
< jvmTarget >17</ jvmTarget >
</ configuration >
< executions >
< execution >
< phase >verify</ phase >
< goals >< goal >ctr</ goal ></ goals >
</ execution >
</ executions >
</ plugin >
</ plugins >
</ build >checkDetektを実行するために使用されます。 -GCおよび-CBを除くすべてのCLIパラメーターは、-ddeTekt。{parameter}を使用して使用できます
例
mvn detekt:check -Ddetekt.config=detekt.ymlmvn detekt:check -Ddetekt.debug=trueタイプ解像度が必要な場合は、代わりに次のものを使用してください
mvn detekt:ctr -Ddetekt.config=detekt.ymlmvn detekt:ctr -Ddetekt.debug=truecreate-baselineベースラインを作成するために使用されます。 -GCおよび-CBを除くすべてのCLIパラメーターは、-ddeTekt。{parameter}を使用して使用できます。デフォルトでは、ベースライン-.xmlというファイルが生成されます。 -ddetekt.baselineを呼び出しに含めると、ベースラインファイルの他の名前を指定できます。
例
mvn detekt:cb -Ddetekt.config=detekt.ymlmvn detekt:cb -Ddetekt.debug=truemvn detekt:cb -Ddetekt.baseline=some-other-baseline.xmlmvn detekt:create-baseline -Ddetekt.config=detekt.ymlmvn detekt:create-baseline -Ddetekt.debug=truegenerate-configデフォルトの構成ファイルを生成するために使用されます。
例
mvn detekt:gcmvn detekt:generate-config