追記:
Ant使わなくてもできました。
Maven2で成果物をFTPを使ってアップする方法(Antを使わない版) - tanamonの日記
こんなん公式サイトのプラグイン一覧にあるだろ、と思っていたら無かった。
wagon-ftpのようなリポジトリに登録する方法としてFTPを使う、というものはあるんだけどね。
探すとAlakai FTP Pluginというものがあって、これを使えばファイルの転送はできるみたい。
ただし、パスワードは毎回手入力しないといけない。あと、使っている人がほとんどいない。
でも同じような事をしたがる人なんて結構いる気がするのにみんなどうしてるのかなぁと思ってたら、どうやらmaven-antrun-pluginを使ってAntのFTPタスクとして実行させているみたい。
Antを止めてMaven2を使おうとしているのに、まさか内部でAntを使う羽目になるとは。。。
ということで、以下、maven-antrun-pluginを使ってFTPを使ってアップする方法です。
pom.xml
<build> ... <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <id>ftp-upload</id> <phase>deploy</phase> <goals> <goal>run</goal> </goals> <configuration> <tasks> <ftp server="${ftp.server}" remotedir="${ftp.remotedir}" userid="${ftp.username}" password="${ftp.password}"> <fileset dir="${project.build.directory}"> <include name="${project.build.finalName}.${project.packaging}" /> </fileset> </ftp> </tasks> </configuration> </execution> </executions> <dependencies> <dependency> <groupId>ant</groupId> <artifactId>ant-commons-net</artifactId> <version>1.6.5</version> </dependency> <dependency> <groupId>commons-net</groupId> <artifactId>commons-net</artifactId> <version>1.4.1</version> </dependency> </dependencies> </plugin> </plugins> </build> <properties> <ftp.server>server.example.com</ftp.server> <ftp.username>user</ftp.username> <ftp.password>pass</ftp.password> <ftp.remotedir>/tmp/deploy</ftp.remotedir> </properties>
ちなみに、例ではFTPの接続情報をpropertiesに書いていますが、これだと成果物のMETA-INF内のpom.xmlを見るとパスワードがバレバレになるので、実際にはsetting.xmlあたりに書いた方が安全です。