Tag Archives: ant

Maven Configuration to deploy on install phase using maven-antrun-plugin

“pom.xml” content

Add the following properties to define deployment context:

<properties>
	<filename>${project.build.finalName}.${project.packaging}</filename>
	<deployable>${basedir}/target/${filename}</deployable>
	<deploydir>/sharing/vm/</deploydir>
</properties>

Then add the following plugin configuration:

<plugin>
	<artifactId>maven-antrun-plugin</artifactId>
	<version>1.8</version>
	<executions>
		<execution>
			<id>clean</id>
			<phase>pre-clean</phase>
			<goals>
				<goal>run</goal>
			</goals>
			<configuration>
				<target name="undeploy">
					<delete file="${deploydir}/${filename}" />
				</target>
			</configuration>
		</execution>

		<execution>
			<id>deploy</id>
			<phase>install</phase>
			<goals>
				<goal>run</goal>
			</goals>
			<configuration>
				<target name="deploy">
					<copy file="${deployable}" todir="${deploydir}" />
				</target>
			</configuration>
		</execution>
	</executions>
</plugin>