maven実行時に出力されるデフォルトのconfigulation要素
ビルド作業の自動化で使うmavenですけども、デフォルトの設定でも十分なこともあります。ただし設定箇所はとても多く、作業環境やリリースの状況によっては特殊な設定が必要なケースもありました。
ここではmaven実行時に出力されるログをDEBUGレベルにして、configuration要素のログを出してみて、その確認方法を見てみます。
configurationのログ
以下にビルド実行をしたときのmaven実行時ログに出ている configurationの内容を貼ります。
build.log
[DEBUG] === PROJECT BUILD PLAN ================================================
[DEBUG] Project: lumi:noltodo:1.0.1-SNAPSHOT
[DEBUG] Dependencies (collect): []
[DEBUG] Dependencies (resolve): [compile, runtime, test]
[DEBUG] Repositories (dependencies): [spring-milestones (http://repo.spring.io/milestone, releases+snapshots), central (http://repo.maven.apache.org/maven2, releases)]
[DEBUG] Repositories (plugins) : [central (http://repo.maven.apache.org/maven2, releases)]
[DEBUG] -----------------------------------------------------------------------
[DEBUG] Goal: org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean)
[DEBUG] Style: Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<directory default-value="${project.build.directory}"/>
<excludeDefaultDirectories default-value="false">${clean.excludeDefaultDirectories}</excludeDefaultDirectories>
<failOnError default-value="true">${maven.clean.failOnError}</failOnError>
<followSymLinks default-value="false">${clean.followSymLinks}</followSymLinks>
<outputDirectory default-value="${project.build.outputDirectory}"/>
<reportDirectory default-value="${project.reporting.outputDirectory}"/>
<retryOnError default-value="true">${maven.clean.retryOnError}</retryOnError>
<skip default-value="false">${clean.skip}</skip>
<testOutputDirectory default-value="${project.build.testOutputDirectory}"/>
<verbose>${clean.verbose}</verbose>
</configuration>
[DEBUG] -----------------------------------------------------------------------
[DEBUG] Goal: org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources)
[DEBUG] Style: Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<buildFilters default-value="${project.build.filters}"/>
<encoding default-value="${project.build.sourceEncoding}">${encoding}</encoding>
<escapeString>${maven.resources.escapeString}</escapeString>
<escapeWindowsPaths default-value="true">${maven.resources.escapeWindowsPaths}</escapeWindowsPaths>
<includeEmptyDirs default-value="false">${maven.resources.includeEmptyDirs}</includeEmptyDirs>
<outputDirectory default-value="${project.build.outputDirectory}"/>
<overwrite default-value="false">${maven.resources.overwrite}</overwrite>
<project default-value="${project}"/>
<resources default-value="${project.resources}"/>
<session default-value="${session}"/>
<supportMultiLineFiltering default-value="false">${maven.resources.supportMultiLineFiltering}</supportMultiLineFiltering>
<useBuildFilters default-value="true"/>
<useDefaultDelimiters default-value="true"/>
</configuration>
[DEBUG] -----------------------------------------------------------------------
[DEBUG] Goal: org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile)
[DEBUG] Style: Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<basedir default-value="${basedir}"/>
<buildDirectory default-value="${project.build.directory}"/>
<classpathElements default-value="${project.compileClasspathElements}"/>
<compileSourceRoots default-value="${project.compileSourceRoots}"/>
<compilerId default-value="javac">${maven.compiler.compilerId}</compilerId>
<compilerReuseStrategy default-value="${reuseCreated}">${maven.compiler.compilerReuseStrategy}</compilerReuseStrategy>
<compilerVersion>${maven.compiler.compilerVersion}</compilerVersion>
<debug default-value="true">${maven.compiler.debug}</debug>
<debuglevel>${maven.compiler.debuglevel}</debuglevel>
<encoding default-value="${project.build.sourceEncoding}">UTF-8</encoding>
<executable>${maven.compiler.executable}</executable>
<failOnError default-value="true">${maven.compiler.failOnError}</failOnError>
<fork default-value="false">${maven.compiler.fork}</fork>
<generatedSourcesDirectory default-value="${project.build.directory}/generated-sources/annotations"/>
<maxmem>${maven.compiler.maxmem}</maxmem>
<meminitial>${maven.compiler.meminitial}</meminitial>
<optimize default-value="false">${maven.compiler.optimize}</optimize>
<outputDirectory default-value="${project.build.outputDirectory}"/>
<outputFileName>${project.build.finalName}</outputFileName>
<projectArtifact default-value="${project.artifact}"/>
<session default-value="${session}"/>
<showDeprecation default-value="false">${maven.compiler.showDeprecation}</showDeprecation>
<showWarnings default-value="false">${maven.compiler.showWarnings}</showWarnings>
<skipMultiThreadWarning default-value="${false}">${maven.compiler.skipMultiThreadWarning}</skipMultiThreadWarning>
<source default-value="1.5">1.7</source>
<staleMillis default-value="0">${lastModGranularityMs}</staleMillis>
<target default-value="1.5">1.7</target>
<verbose default-value="false">${maven.compiler.verbose}</verbose>
</configuration>
[DEBUG] -----------------------------------------------------------------------
(以下省略)
このように、ビルドで必要なゴール(goal)によって必要なconfigurationが変わっていることがわかります。ここで実行ログに出ているゴールは…
buildlog2.log
Goal: org.apache.maven.plugins:maven-clean-plugin:2.5:clean
Goal: org.apache.maven.plugins:maven-resources-plugin:2.6:resources
Goal: org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile
と、クリーン→リソース→コンパイル→…とそれぞれのゴールごとのプラグインとバージョンが出力されています。
それぞれのゴールで設定可能な定義はmaven公式サイトからたどれますが、実際に動いている定義やバージョンの確認はここから行うことができます。
もし何らかのビルドエラーが発生した場合、こちらと違う状況であるかを確認するためにも、mavenのログをDEBUGレベルで出力しておきましょう。