<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Copyright 2008-2014 by Emeric Vernat
 *
 *     This file is part of Java Melody.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
-->

<!-- Auteur: Emeric Vernat -->
<project basedir="." default="war" name="JavaMelody Demo Webapp">
	<!-- Initialisation des tâches -->
	<target name="init">
		<echo message="-- Script Ant JavaMelody Demo Webapp --" level="info" />

		<mkdir dir="build" />
		<tstamp>
			<format property="TODAY_yyyyMMdd" pattern="yyyy-MM-dd" />
		</tstamp>
		<echo file="build/JAVAMELODY-VERSION.properties" message="version=SNAPSHOT-${TODAY_yyyyMMdd}" />

		<ant dir="../javamelody-core" antfile="build.xml" target="clean" />
		<ant dir="../javamelody-core" antfile="build.xml" target="jar" />
	</target>

	<!-- Nettoyage du répertoire de compilation et du war -->
	<target name="clean">
		<echo message="Nettoyage" level="info" />
		<delete dir="build" />
		<delete file="javamelody-demo-webapp.war" />
	</target>

	<target name="build" depends="init">
		<echo message="Compilation" level="info" />
		<javac encoding="UTF-8" debug="on" deprecation="on" nowarn="off" source="1.6" target="1.6" 
			srcdir="src" destdir="build" includeantruntime="false"
			classpath="../javamelody-core/src/main/lib/javax.servlet-api-3.1.0.jar">
			<compilerarg value="-Xlint" />
		</javac>
	</target>

	<!-- Construction du war -->
	<target name="war" depends="build">
		<echo message="Construction du war" level="info" />
		<delete file="demo.war" />
		<jar destfile="demo.war">
			<zipfileset file="web.xml" prefix="WEB-INF" />
			<zipfileset dir="pages" prefix="WEB-INF/pages" />
			<zipfileset file="build/JAVAMELODY-VERSION.properties" prefix="WEB-INF/classes" />
			<zipfileset file="build/*.class" prefix="WEB-INF/classes" />
			<zipfileset file="../javamelody-core/javamelody.jar" prefix="WEB-INF/lib" />
			<zipfileset file="../javamelody-core/src/test/test-webapp/WEB-INF/lib/xpp3_min-1.1.4c.jar" prefix="WEB-INF/lib" />
			<zipfileset file="../javamelody-core/src/test/test-webapp/WEB-INF/lib/xstream-1.4.9.jar" prefix="WEB-INF/lib" />
			<zipfileset src="appwhite1-gwt.war" excludes="WEB-INF/web.xml,WEB-INF/lib/ojdbc*.jar,WEB-INF/lib/javamelody*.jar" />
			<manifest>
				<attribute name="Built-By" value="${user.name}" />
				<attribute name="Built-Date" value="${TODAY_FR}" />
				<attribute name="Build-Jdk" value="${java.version}" />
				<section name="javamelody-demo-webapp">
					<attribute name="Implementation-Title" value="Java Melody Demo Webapp" />
					<attribute name="Implementation-Vendor" value="Emeric Vernat" />
				</section>
			</manifest>
		</jar>
		<delete dir="build" />
	</target>
</project>
