Maven Antrun pluginを使う
S2JDBC-GenのAntタスクを実行するためにMaven Antrun Pluginを使いました。Maven Antrun plugin自体は、これまでも使っていたのですが、普段はMavenの特定のビルドフェーズでAntタスクを実行するために使っていたので、ビルドフェーズに関係なくAntタスクのみを実行しようとして迷ったのでメモしておきます。
Antrun pluginの実行はコマンドラインから以下のように実行します。
mvn antrun:run -Dant.target=foo
ここで実行されるAntタスクの以下のいずれかの場所に記述されたものになります。
idがdefault-cliのexecutionに記述されたタスク
<plugin> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <id>default-cli</id> <!-- <phase>prepare-package</phase>--> <configuration> <tasks> <property name="classpath" refid="maven.compile.classpath" /> <ant antfile="build.xml" target="${ant.target}" inheritRefs="true"></ant> </tasks> </configuration> </execution> </executions> </plugin>
ちなみに実行するtargetは以下のようにコマンドラインから渡しています。
mvn antrun:run -Dant.target=foo
plugin直下のconfigurationに記述されたタスク
<plugin> <artifactId>maven-antrun-plugin</artifactId> <configuration> <tasks> <property name="classpath" refid="maven.compile.classpath" /> <ant antfile="build.xml" target="${ant.target}" inheritRefs="true"></ant> </tasks> </configuration> </plugin>