Skip to content
Snippets Groups Projects
build.xml 3.22 KiB
Newer Older
Piotr Gawron's avatar
Piotr Gawron committed
<?xml version="1.0" encoding="UTF-8"?>
<project name="minerva" default="main" basedir=".">
	<property environment="env"/>

	<property name="build.dir" value="web/target" />
	<property name="war.file" value="web-1.0.war" />
	<property name="tomcat.home" value="${env.CATALINA_HOME}" />
	<property name="tomcat.deploy.dir" value="${tomcat.home}/webapps" />

	<condition property="isWindows">
    <os family="windows" />
	</condition>

	<condition property="isUnix">
    <os family="unix" />
	</condition>

	<target name="war-exists">
    <available file="${tomcat.deploy.dir}/${ant.project.name}.war" property="war.exists"/>
	</target>
	
	<target name="remove-war" depends="war-exists" if="war.exists">
		<delete file="${tomcat.deploy.dir}/${ant.project.name}.war" />
	</target>

	<target name="war-dir-exists">
    <available file="${tomcat.deploy.dir}/${ant.project.name}" property="war-dir.exists" type="dir"/>
	</target>
	
	<target name="remove-war-dir" depends="war-dir-exists" if="war-dir.exists">
		<delete dir="${tomcat.deploy.dir}/${ant.project.name}" />
	</target>
	
	<target name="deploy" depends="remove-war,remove-war-dir">
		<copy file="${build.dir}/${war.file}" todir="${tomcat.deploy.dir}" />
		<move file="${tomcat.deploy.dir}/${war.file}" tofile="${tomcat.deploy.dir}/${ant.project.name}.war"/>
	</target>


	<target name="main" depends="tomcat-stop,maven-build,deploy,tomcat-start">
	</target>

	<target name="all" depends="main">
	</target>

	<target name="tomcat-start">
		<exec executable="${tomcat.home}/bin/startup.bat">
		</exec>
	</target>

	<target name="tomcat-stop">
		<exec executable="${tomcat.home}/bin/shutdown.bat">
		</exec>
	</target>

	<target name="maven-build" depends="svnversion, maven-build-windows, maven-build-unix"/>
	
	<target name="maven-build-windows" if="isWindows">
		<exec dir="." executable="cmd" >
			 <arg line="/c mvn -Dmaven.test.skip=true clean install -pl web -am" />
		</exec>
	</target>

	<target name="maven-build-unix" if="isUnix">
		<exec dir="." executable="sh" >
			 <arg line="-c 'mvn -Dmaven.test.skip=true clean install -pl web -am'" />
		</exec>
	</target>

	<target name="maven-test" depends="maven-test-windows, maven-test-unix"/>
	
	<target name="maven-test-windows" depends="maven-build" if="isWindows">
		<exec dir="." executable="cmd" >
			 <arg line="/c mvn test -fn" />
<!--			 <arg line="/c mvn surefire-report:report" /> -->
		</exec>
	</target>

	<target name="maven-test-unix" depends="maven-build" if="isUnix">
		<exec dir="." executable="sh" >
			 <arg line="-c 'mvn test -fn'" />
<!--			 <arg line="-c 'mvn surefire-report:report'" /> -->
		</exec>
	</target>

	<target name="deployMapFiles">
		<copy todir="${tomcat.deploy.dir}/map_images">
			<fileset dir="map_images" />
		</copy>
	</target>
	

	<target name="svnversion">
    <exec executable="svnversion" outputproperty="svnversion" />
		<tstamp>
      <format property="build.time" pattern="dd/MM/yyyy HH:mm"
              unit="hour"/>
  	</tstamp>
    <echo >SVN Version: ${svnversion}
Build timestamp: ${build.time}</echo>
    
    <echo file="web/src/main/webapp/svnversion.txt">${svnversion}
${build.time}</echo>    
  </target>	

	<target name="debian-pkg" depends="maven-build">
		<exec executable="debian/create-debian-pkg.sh"/>
	</target>
</project>