2017-12-28 10 views
0

Maven-checkstyle-plugin은 컴파일 단계에서 라이프 사이클에 포함됩니다 .FailOneError 구성이 활성화되었습니다 .xml 보고서를 생성하고 빌드를 중단합니다. 내 사용자 정의 .xsl 파일을 사용하여 html 버전을 가져오고 싶습니다. 그것을 위해, 나는 xml-maven-plugin을 사용하지만 자동 실행을 위해 구성 할 수 없으며 수명주기에 통합 할 수 없다.maven과 함께 html checkstyle 보고서 생성

나는 구현해야이 단계 :
1) 휴식을 구축) 받는다는-checkstyle-플러그인
3) 플러그인은 XML 보고서
4 오류를 발견하고 생성 코드를 분석
2) "MVN 설치"를 실행 아래
는 5) XML-받는다는 - 플러그인 automacilly 내 pom.xml 파일의

파트를보고 .HTML 생성

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <configuration> 
       <source>1.8</source> 
       <target>1.8</target> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-maven-plugin</artifactId> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-checkstyle-plugin</artifactId> 
      <version>${checkstyle.version}</version> 
      <executions> 
       <execution> 
        <id>compile</id> 
        <goals> 
         <goal>check</goal> 
        </goals> 
        <phase>compile</phase> 
        <configuration> 
         <configLocation>checkstyle/checkstyle.xml</configLocation> 
         <encoding>UTF-8</encoding> 
         <consoleOutput>true</consoleOutput> 
         <failsOnError>false</failsOnError> 
         <includeTestSourceDirectory>false</includeTestSourceDirectory> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>xml-maven-plugin</artifactId> 
      <version>${xml.maven.version}</version> 
      <executions> 
       <execution> 
        <goals> 
         <goal>transform</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <transformationSets> 
        <transformationSet> 
         <dir>target\</dir> 
         <stylesheet>checkstyle\checkstyle-author.xsl</stylesheet> 
         <includes>checkstyle-result.xml</includes> 
         <fileMappers> 
          <fileMapper 
            implementation="org.codehaus.plexus.components.io.filemappers.RegExpFileMapper"> 
           <pattern>\.xml$</pattern> 
           <replacement>.html</replacement> 
          </fileMapper> 
         </fileMappers> 
        </transformationSet> 
       </transformationSets> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

답변

1

단계와 플러그인을 면밀히 관찰해야합니다.

checkstyle 플러그인은 "컴파일"단계에서 실행됩니다. the docs of the xml-maven-plugin에 따르면 기본 단계는 "generate-resources"입니다.

그래서 당신은 checkstyle 플러그인 이후에 a phase에 목표를 둘 필요 (프로세스 클래스는 컴파일 후 제공) :

<executions> 
    <execution> 
    <phase>process-classes</phase> 
    <goals> 
     <goal>transform</goal> 
    </goals> 
    </execution> 
</executions> 

내가 누락 된 파일에 대해 불평한다 XML 플러그인의 로그를 믿지해야 깨끗하게하지 않고 빌드를 두 번 실행하면 작동합니까? 그게 좋은 결과는 아니 겠지. 따라서 일반적으로 가장 좋은 경우 실행되는 명령을 갖는 것 :

관련 문제