2017-12-28 45 views
0

Maven-checkstyle-pluginはコンパイル時にライフサイクルに組み込まれています.FilesOneError設定が有効です.xmlレポートが生成され、クラッシュします。カスタム.xslファイルを使用してhtmlバージョンを取得します。私はxml-maven-pluginを使用していますが、自動実行用に設定することはできず、ライフサイクルに統合することはできません。mavenでhtml checkstyleレポートを生成

私は、この手順を実装する必要があります。
1)
2 "をMVNインストール" を実行)のmaven-Checkstyleは、プラグインは、コード
3を分析する)プラグインがエラーを検出し、XMLレポート
4を生成)休憩を構築ダウン
は 5)XML-のmaven-pluginのは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プラグインのログが欠落しているファイルについて文句を言うか、すべき必要があると考えていますきれいにしなくてもビルドを2回実行すると動作しますか?それは良い結果ではないでしょう。したがって、通常は最高のときに実行されるもので順序を持つこと:)

関連する問題