Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <project xmlns:ivy="antlib:org.apache.ivy.ant" name="myproduct" default="help" basedir="../..">
- <!-- Project Structure -->
- <property name="jdk.version" value="1.7" />
- <property name="src.dir" location="${basedir}/src/de/mycompany/myproduct" />
- <property name="testsrc.dir" location="${basedir}/testsrc/de/mycompany/myproduct" />
- <property name="web.dir" value="${basedir}/application/webapp" />
- <property name="web.classes.dir" location="${web.dir}/WEB-INF/classes" />
- <property name="web.testclasses.dir" location="${web.dir}/testclasses" />
- <property name="target.dir" location="${basedir}/release" />
- <property name="deploy.file" location="${target.dir}/myproduct.war" />
- <property name="lib.dir" value="${web.dir}/WEB-INF/lib" />
- <ivy:settings file="${web.dir}/ivysettings.xml" />
- <!-- Ivy -->
- <target name="resolve" description="retrieve dependencies with ivy">
- <echo message="Getting dependencies..." />
- <echo message="Ivy Settings: ${web.dir}/ivysettings.xml" />
- <ivy:resolve file="${web.dir}/ivy.xml" />
- <ivy:cachepath pathid="compile.path" conf="compile" />
- <ivy:cachepath pathid="runtime.path" conf="runtime" />
- <ivy:cachepath pathid="test.path" conf="test" />
- <pathconvert property="classpathProp" refid="compile.path"/>
- <echo>Classpath is ${classpathProp}</echo>
- </target>
- <fileset id="lib.jars" dir="${lib.dir}">
- <include name="**/*.jar" />
- </fileset>
- <path id="compile.path">
- <fileset refid="lib.jars" />
- </path>
- <!-- Compile Java source from ${src.dir} and output it to ${web.classes.dir} -->
- <target name="compile" depends="init, resolve" description="compile source code">
- <mkdir dir="${web.classes.dir}" />
- <javac destdir="${web.classes.dir}" includeantruntime="false" debug="true" encoding="ISO-8859-1" >
- <src path="${src.dir}" />
- <classpath>
- <path refid="compile.path"/>
- <fileset dir="C:\Program Files\apache-tomcat-7.0.63\lib">
- <include name="el-api.jar"/>
- <include name="servlet-api.jar"/>
- <include name="jsp-api.jar"/>
- </fileset>
- </classpath>
- </javac>
- <mkdir dir="${web.testclasses.dir}" />
- <javac destdir="${web.testclasses.dir}" includeantruntime="false" debug="true" encoding="ISO-8859-1" >
- <src path="${testsrc.dir}" />
- <classpath>
- <path refid="test.path"/>
- <pathelement location="${web.classes.dir}"/>
- <fileset dir="C:\Program Files\apache-tomcat-7.0.63\lib">
- <include name="el-api.jar"/>
- <include name="servlet-api.jar"/>
- <include name="jsp-api.jar"/>
- </fileset>
- </classpath>
- </javac>
- <path id="junit.class.path">
- <pathelement location="${web.testclasses.dir}"/>
- </path>
- </target>
- <!-- Create the final WAR file for deployment -->
- <target name="package" depends="compile, junit" description="create a war file">
- <!-- ivy get dependencies from ivy cache and copy it into ${lib.dir} -->
- <ivy:retrieve pattern="${lib.dir}/[artifact]-[revision].[ext]" conf="runtime" />
- <ivy:report conf="compile" />
- <war destfile="${deploy.file}" webxml="${web.dir}/WEB-INF/web.xml">
- <webinf dir="${web.dir}/WEB-INF" />
- <zipfileset dir="${web.dir}/jsp" prefix="jsp" />
- <zipfileset dir="${web.dir}/tld" prefix="tld" />
- <zipfileset dir="${web.dir}/img" prefix="img" />
- <zipfileset dir="${web.dir}/js" prefix="js" />
- <zipfileset dir="${web.dir}/css" prefix="css" />
- <zipfileset dir="${web.dir}/contents" prefix="contents" />
- <zipfileset dir="${web.dir}/fonts" prefix="fonts" />
- </war>
- </target>
- <!-- Create folders -->
- <target name="init">
- <mkdir dir="${target.dir}" />
- <echo message="${target.dir}"> created.</echo>
- <mkdir dir="${web.classes.dir}" />
- <echo message="${web.classes.dir}"> created.</echo>
- </target>
- <!-- Delete folders -->
- <target name="clean" description="clean up">
- <ivy:cleancache />
- <delete dir="${web.classes.dir}" />
- <delete dir="${target.dir}" />
- <delete includeEmptyDirs="true">
- <fileset dir="${lib.dir}" includes="**/*" defaultexcludes="no" />
- </delete>
- </target>
- <target name="main" depends="clean, package" />
- <target name="report">
- <ivy:cleancache />
- <ivy:retrieve file="${web.dir}/ivy.xml" />
- <ivy:report conf="compile" />
- </target>
- <target name="junit" depends="compile">
- <echo message="|-- JUnit Classpath"/>
- <echo message="| |"/>
- <echo message="| |-- ${web.testclasses.dir}"/>
- <path id="junit.classpath">
- <path refid="test.path"/>
- <pathelement location="${web.testclasses.dir}"/>
- <pathelement location="${web.classes.dir}"/>
- <dirset dir="${web.testclasses.dir}">
- <include name="**"/>
- </dirset>
- </path>
- <pathconvert property="junit.classpath.property" refid="junit.classpath" />
- <echo message="JUnit classpath: ${junit.classpath.property}"/>
- <junit printsummary="yes" haltonfailure="yes" fork="true" >
- <classpath>
- <path refid="junit.classpath"/>
- </classpath>
- <formatter type="xml"/>
- <batchtest fork="yes" todir="${web.testclasses.dir}">
- <fileset dir="${testsrc.dir}">
- <include name="**/*.java"/>
- <exclude name="**/TestUtils.java"/>
- </fileset>
- </batchtest>
- </junit>
- </target>
- </project>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement