- surefire-report:reportのからみで、testが二回実行されてしまう
- target/site/cobertura/coverage.xmlが出力されないため、Hudsonのcobertura pluginからxmlを拾えない
testが2回走ってしまう件
//reporting/plugins/pluginでsurefire-reportを設定するときに以下のよぅに設定します。
<!-- surefire-report: http://maven.apache.org/plugins/maven-surefire-report-plugin/ -->
<plugin>
<artifactId>maven-surefire-report-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<report>report-only</report>
</reports>
</reportSet>
</reportSets>
</plugin>reportSetとか、そんなの知らなかったヨ!ちなみに、testフェーズだけ実行したときもsurefire-reportを走らせたければ、//build/plugins/pluginでsurefire-report pluginを以下のように設定すると、testを二回走らせずにreport出力ができますた。<plugin>
<artifactId>maven-surefire-report-plugin</artifactId>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>report-only</goal>
</goals>
</execution>
</executions>
</plugin>target/site/cobertura/coverage.xmlが出力されない件
こちらは簡単。といぅか、前回のエントリに含まれていない方がどぅかしてた。//reporting/plugins/pluginでcoberturaの設定をする際に、configurationの子要素としてformats/formatを使って「xml」の出力を設定する必要があります。デフォルトではhtmlだけが出力されます。
<!-- cobertura: http://mojo.codehaus.org/cobertura-maven-plugin/ -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<formats>
<format>xml</format>
<format>html</format>
</formats>
</configuration>
</plugin>まとめ
2点の問題の修正を反映し、各pluginの不要な設定を極力はずしたものがコチラ。plugin間のversionの問題は相変わらずシビアっぽいので、例えばfindbugsの結果レポートがdashboardに乗ってこない、等の症状は出ますが、それはとりあえず無視してます。
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.shin1o</groupId>
<artifactId>com.shin1o.reportsample</artifactId>
<packaging>jar</packaging>
<version>1.0.0-SNAPSHOT</version>
<name>com.shin1o.reportsample</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- http://maven.apache.org/plugins/maven-compiler-plugin/ -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<!-- surefire: http://maven.apache.org/plugins/maven-surefire-plugin/ -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>net.sourceforge.cobertura.datafile</name>
<value>${basedir}/target/cobertura/cobertura.ser</value>
</property>
</systemProperties>
<!-- スラッシュ区切り、javaを指定。
<excludes>
<exclude>com/shin1o/exclude/**/*.java</exclude>
</excludes>
-->
</configuration>
</plugin>
<!-- surefire-report: http://maven.apache.org/plugins/maven-surefire-report-plugin/ -->
<!-- testフェーズでもsurefire-reportが必要なら有効にする。
<plugin>
<artifactId>maven-surefire-report-plugin</artifactId>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>report-only</goal>
</goals>
</execution>
</executions>
</plugin>
-->
</plugins>
</build>
<reporting>
<plugins>
<!-- cobertura: http://mojo.codehaus.org/cobertura-maven-plugin/ -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<formats>
<format>xml</format>
<format>html</format>
</formats>
<instrumentation>
<!-- ignoreはパッケージ名で指定。
<ignores>
<ignore>com.shin1o.exclude.*</ignore>
</ignores>
-->
<!-- includes/excludesはスラッシュ区切り,classを指定
<includes>
<include>com/shin1o/include/**/*.class</include>
</includes>
<excludes>
<exclude>**/*Test*.class</exclude>
</excludes>
-->
</instrumentation>
</configuration>
</plugin>
<!-- surefire-report: http://maven.apache.org/plugins/maven-surefire-report-plugin/ -->
<plugin>
<artifactId>maven-surefire-report-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<report>report-only</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<!-- jxr: http://maven.apache.org/plugins/maven-jxr-plugin/ -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<configuration>
<inputEncoding>UTF-8</inputEncoding>
<outputEncoding>UTF-8</outputEncoding>
</configuration>
</plugin>
<!-- jdepend: http://mojo.codehaus.org/jdepend-maven-plugin/ -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jdepend-maven-plugin</artifactId>
</plugin>
<!-- pmd/cpd: http://maven.apache.org/plugins/maven-pmd-plugin/ -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<linkXref>true</linkXref>
<sourceEncoding>UTF-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
<targetJdk>1.5</targetJdk>
</configuration>
</plugin>
<!-- findbugs http://mojo.codehaus.org/findbugs-maven-plugin/ -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<xmlOutput>true</xmlOutput>
<effort>Max</effort>
</configuration>
</plugin>
<!-- dashboard: http://maven.apache.org/plugins/dashboard-maven-plugin/ -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>dashboard-maven-plugin</artifactId>
</plugin>
<!-- site: http://maven.apache.org/plugins/maven-site-plugin/ -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<configuration>
<inputEncoding>UTF-8</inputEncoding>
<outputEncoding>UTF-8</outputEncoding>
</configuration>
</plugin>
<!-- project-info: http://maven.apache.org/plugins/maven-project-info-reports-plugin/ -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</plugin>
</plugins>
</reporting>
<repositories>
<repository>
<id>Maven Snapshots</id>
<url>http://snapshots.maven.codehaus.org/maven2/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>Codehaus Snapshots</id>
<url>http://snapshots.repository.codehaus.org/</url>
</pluginRepository>
</pluginRepositories>
</project>
0 件のコメント:
コメントを投稿