maven3で使うプラグインなのだが、
どうも情報が古かったりするので、
最新版でまとめてみた。
【環境】
OS:windows8.1 – 64bit
JDK:1.8 – 64bit
maven:3.2.1 – eclipse lua embedded
【プラグイン】
- maven-compiler-plugin 3.3
- maven-project-info-reports-plugin 2.8
- org.apache.maven.plugins 3.4
- maven-checkstyle-plugin 2.15
- maven-javadoc-plugin 2.10.2
- org.apache.maven.plugins 3.4
- findbugs-maven-plugin 3.0.1
- maven-jxr-plugin 2.5
- taglist-maven-plugin 2.4
- cobertura-maven-plugin 2.7
ローカルPCのmavenで各種レポートを作成する場合、
mvn clean site
で作れるのだが、
chekstyleプラグインが独自のcheckstyleファイルを用いていると、
ビルドが失敗する(理由がわからない)
とりあえず、簡単にpomをさらす。
ローカルmaven用pom
< 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/xsd/maven-4.0.0.xsd" > < modelVersion >4.0.0</ modelVersion > : : < properties > < project.build.sourceEncoding >UTF-8</ project.build.sourceEncoding > < java.version >1.8</ java.version > </ properties > < dependencyManagement > : : </ dependencyManagement > < dependencies > : : </ dependencies > < build > < pluginManagement > < plugins > <!-- compiler plugin --> < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-compiler-plugin</ artifactId > < version >3.3</ version > < configuration > < source >${java.version}</ source > < target >${java.version}</ target > < compilerVersion >${java.version}</ compilerVersion > < encoding >${project.build.sourceEncoding}</ encoding > </ configuration > </ plugin > <!-- project info reports plugin --> < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-project-info-reports-plugin</ artifactId > < version >2.8</ version > </ plugin > <!-- site plugin --> < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-site-plugin</ artifactId > < version >3.4</ version > < configuration > < inputEncoding >${project.build.sourceEncoding}</ inputEncoding > < outputEncoding >${project.build.sourceEncoding}</ outputEncoding > </ configuration > </ plugin > <!-- checkstyle plugin --> < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-checkstyle-plugin</ artifactId > < version >2.15</ version > < dependencies > < dependency > < groupId >com.puppycrawl.tools</ groupId > < artifactId >checkstyle</ artifactId > < version >6.5</ version > </ dependency > </ dependencies > < configuration > < configLocation >${basedir}/config/google_checks.xml</ configLocation > < encoding >${project.build.sourceEncoding}</ encoding > </ configuration > </ plugin > <!-- javadoc plugin --> < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-javadoc-plugin</ artifactId > < version >2.10.2</ version > < configuration > < locale >ja</ locale > < charset >${project.build.sourceEncoding}</ charset > < encoding >${project.build.sourceEncoding}</ encoding > </ configuration > </ plugin > <!-- pmd plugin --> < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-pmd-plugin</ artifactId > < version >3.4</ version > < configuration > < outputEncoding >${project.build.sourceEncoding}</ outputEncoding > </ configuration > </ plugin > <!-- findbugs plugin --> < plugin > < groupId >org.codehaus.mojo</ groupId > < artifactId >findbugs-maven-plugin</ artifactId > < version >3.0.1</ version > < configuration > < effort >low</ effort > < xmlOutput >true</ xmlOutput > < encoding >${project.build.sourceEncoding}</ encoding > < outputEncoding >${project.build.sourceEncoding}</ outputEncoding > </ configuration > </ plugin > <!-- jxr plugin --> < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-jxr-plugin</ artifactId > < version >2.5</ version > < configuration > < inputEncoding >${project.build.sourceEncoding}</ inputEncoding > < outputEncoding >${project.build.sourceEncoding}</ outputEncoding > </ configuration > </ plugin > <!-- taglist plugin --> < plugin > < groupId >org.codehaus.mojo</ groupId > < artifactId >taglist-maven-plugin</ artifactId > < version >2.4</ version > < configuration > < encoding >${project.build.sourceEncoding}</ encoding > </ configuration > </ plugin > <!-- cobertura plugin --> < plugin > < groupId >org.codehaus.mojo</ groupId > < artifactId >cobertura-maven-plugin</ artifactId > < version >2.7</ version > < configuration > < formats > < format >html</ format > < format >xml</ format > </ formats > < encoding >${project.build.sourceEncoding}</ encoding > </ configuration > </ plugin > </ plugins > </ pluginManagement > < plugins > <!-- mvn site --> < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-site-plugin</ artifactId > < configuration > < reportPlugins > < plugin > < groupId >org.codehaus.mojo</ groupId > < artifactId >findbugs-maven-plugin</ artifactId > </ plugin > < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-project-info-reports-plugin</ artifactId > </ plugin > --> <!-- checkstyle はsiteでエラーになるためコメントアウト --> <!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> </plugin> --> < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-javadoc-plugin</ artifactId > < reportSets > < reportSet > < reports > < report >javadoc</ report > <!-- テスト用をださないための指定 --> </ reports > </ reportSet > </ reportSets > </ plugin > < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-pmd-plugin</ artifactId > </ plugin > < plugin > < groupId >org.codehaus.mojo</ groupId > < artifactId >findbugs-maven-plugin</ artifactId > </ plugin > < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-jxr-plugin</ artifactId > < reportSets > < reportSet > < reports > < report >jxr</ report > <!-- テスト用を出さないための指定 --> </ reports > </ reportSet > </ reportSets > </ plugin > < plugin > < groupId >org.codehaus.mojo</ groupId > < artifactId >taglist-maven-plugin</ artifactId > </ plugin > < plugin > < groupId >org.codehaus.mojo</ groupId > < artifactId >cobertura-maven-plugin</ artifactId > </ plugin > </ reportPlugins > </ configuration > </ plugin > </ plugins > </ build > </ project > |
上記の状態で、
mvn clean site
でうまいこと、htmlが出力される。
で、jenkisでやる場合だが、
これだと実はうまく動かない。
結論としては、
mvn clean checkstyle:checkstyle javadoc:javadoc pmd:pmd pmd:cpd taglist:taglist cobertura:cobertura compile site
がよいかなと。
pomは以下。
< build > < pluginManagement > : <!-- localの場合と同じ --> : </ pluginManagement > < plugins > <!-- mvn site --> < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-site-plugin</ artifactId > < configuration > < reportPlugins > < plugin > < groupId >org.codehaus.mojo</ groupId > < artifactId >findbugs-maven-plugin</ artifactId > </ plugin > </ reportPlugins > </ configuration > </ plugin > </ plugins > </ build > |
上記の感じで、findbugsだけ出力の指定をすればよい。
(findbugsは単体でレポートが出せないため)
これで、jenkins上でも各種レポートが上手いこと出力されるはず。
※jenkinsのビルド後の処理において、
集計するファイルはちゃんと指定したほうがよい。
Coberturaのxmlが上手く見つけられなかったりする。
なげ~~。
コメントがあればどうぞ