tanamonの稀に良く書く日記

KEEP CALM AND DRINK BEER

Maven2で成果物をFTPを使ってアップする方法(Antを使わない版)

前回、Ant使わないとできないというようなことを書いたのですが、嘘でした。
wagon-maven-pluginを使ってできます。

やっぱりAntなんか要らない子でした。

pom.xml

<build>
	...
	<plugins>
		...
		<plugin>
			<groupId>org.codehaus.mojo</groupId>
			<artifactId>wagon-maven-plugin</artifactId>
			<executions>
				<execution>
					<id>upload-artifact</id>
					<phase>deploy</phase>
					<goals>
						<goal>upload</goal>
					</goals>
					<configuration>
						<serverId>ftp.example.com</serverId>
						<url>ftp://ftp.example.com/</url>
						<fromDir>${project.build.directory}</fromDir>
						<includes>${project.build.finalName}.${project.packaging}</includes>
						<toDir>/tmp/deploy</toDir>
					</configuration>
				</execution>
			</executions>
		</plugin>
	</plugins>
	<extensions>
		...
		<extension>
			<groupId>org.apache.maven.wagon</groupId>
			<artifactId>wagon-ftp</artifactId>
		</extension>
	</extensions>
</build>