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> 외부에 배치 될 수 있습니다. 이를 통해 목표 독립형을 실행할 때 구성을 사용할 수 있습니다.
< 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 이라는 각 모듈에 대한 기준 파일이 생성됩니다. 기준선 생성에 대한 자세한 내용은 생성 기반을 참조하십시오. 이제 아래와 같이 구성에서 기준 파일을 참조 할 수 있습니다.
< 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}를 사용하여 사용할 수 있습니다. 기본적으로 Baseline -.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