Mavenソースコードリーディング
いつもお世話になってるMaven。こいつがなければライブラリ管理やらビルドやらが大変なことになってしまう。
常々どういう仕組みになっているのか気になってはいたが、ソースは読んだことなかった。
まずはダウンロード。現時点の最新は3.0.4らしい。http://maven.apache.org/download.html
しかし、何から読んだらいいか分からない。。
取りあえず、3.0.3が入っているコマンドラインで以下を打ってみる。
mvn -X
すると以下のようなエラーが。
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1] org.apache.maven.lifecycle.NoGoalSpecifiedException: No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:104) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
どうもMavenCli.javaというクラスから処理が始まるらしいことが分かった。
よく見ると、build.xmlにもこのクラスが書いてある箇所がある。
<target name="maven-compile" depends="compile-boot,process-classes" descriptio n="compiles Maven using the bootstrap Maven, skipping automated tests"> <java fork="true" classname="org.apache.maven.cli.MavenCli" failonerror="true"> <!--jvmarg line="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"/--> <classpath refid="maven.classpath" /> <arg value="${maven.debug}" /> <arg value="-B" /> <arg value="-V" /> <arg value="clean" /> <arg value="${maven.goal}" /> <arg value="-Dmaven.test.skip=${maven.test.skip}" /> <arg value="-DskipTests=${skipTests}" /> <arg value="-Dmaven.repo.local=${maven.repo.local}" /> <arg value="-Dsurefire.useFile=${surefire.useFile}" /> <arg value="-Dmaven.test.redirectTestOutputToFile=${maven.test.redirectTestOutputToFile}" /> <arg value="-DdistributionId=${distributionId}" /> <arg value="-DdistributionShortName=${distributionShortName}" /> <arg value="-DdistributionName=${distributionName}" /> </java> </target>
眠くなってきたので今日はここまで。
続く、のか。。?