Last active
March 1, 2017 15:34
-
-
Save mhvelplund/2c9043831019152c240168fa5c9049f2 to your computer and use it in GitHub Desktop.
Introduce Maven in your Ant team, using ninja magics.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" ?> | |
<project default="main"> | |
<property name="maven_install_dir" value="maven_install" /> | |
<property name="maven_version" value="apache-maven-3.3.9" /> | |
<target name="get-maven" if="get.maven" description="Download Maven if needed"> | |
<mkdir dir="${maven_install_dir}" /> | |
<get src="http://ftp.download-by.net/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.zip" dest="${maven_install_dir}/apache-maven-3.3.9-bin.zip" /> | |
<unzip src="${maven_install_dir}/apache-maven-3.3.9-bin.zip" dest="${maven_install_dir}" /> | |
</target> | |
<target name="assert-maven" description="Check if Maven needs to be downloaded"> | |
<condition property="get.maven"> | |
<not> | |
<available file="${maven_install_dir}/apache-maven-3.3.9-bin.zip" /> | |
</not> | |
</condition> | |
<condition property="is.windows"> | |
<os family="windows" /> | |
</condition> | |
<condition property="not.windows"> | |
<not> | |
<os family="windows" /> | |
</not> | |
</condition> | |
<antcall target="get-maven" /> | |
</target> | |
<target name="maven-windows" if="is.windows" description="Set the path to Maven for Windows"> | |
<property name="maven_cmd" value=".\${maven_install_dir}\${maven_version}\bin\mvn.cmd" /> | |
</target> | |
<target name="maven-unix" if="not.windows" description="Set the path to Maven for *nix platforms"> | |
<property name="maven_cmd" value="./${maven_install_dir}/${maven_version}/bin/mvn" /> | |
<chmod file="${maven_cmd}" perm="a+x" /> | |
</target> | |
<target name="main" depends="assert-maven, maven-unix, maven-windows"> | |
<exec executable="${maven_cmd}"> | |
<env key="JAVA_HOME" value="${java.home}" /> | |
<arg value="clean" /> | |
<arg value="install" /> | |
</exec> | |
</target> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment