Skip to content

Instantly share code, notes, and snippets.

@rladstaetter
Created January 21, 2013 20:59
Show Gist options
  • Save rladstaetter/4589329 to your computer and use it in GitHub Desktop.
Save rladstaetter/4589329 to your computer and use it in GitHub Desktop.
An example for calling ant from maven using a property file for storing values
<project default="main">
<target name="main">
<echo message="This line is executed in an external build.xml for javafx version: ${javafx.version}"/>
</target>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.ladstatt.maven</groupId>
<artifactId>example-pom-with-filtering</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>example-pom-with-filtering</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<filters>
<filter>props.properties</filter>
</filters>
<plugins>
<!-- http://mojo.codehaus.org/properties-maven-plugin/ -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>props.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<target>
<!-- Place any Ant task here. You can add anything you can add between
<target> and </target> in a build.xml. -->
<property name="a.version" value="${a.version}" />
<ant antfile="build.xml" />
<echo
message="This is ant called from maven for and providing a version number from a property file ${a.version}" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
</dependencies>
</project>
@motomark
Copy link

Thanks for this - couldn't quite figure out how to do this with the ant-run plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment