Advertisement
Guest User

build.xml

a guest
Nov 20th, 2015
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 5.48 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns:ivy="antlib:org.apache.ivy.ant" name="myproduct" default="help" basedir="../..">
  3.  
  4.     <!-- Project Structure -->
  5.     <property name="jdk.version" value="1.7" />
  6.     <property name="src.dir" location="${basedir}/src/de/mycompany/myproduct" />
  7.     <property name="testsrc.dir" location="${basedir}/testsrc/de/mycompany/myproduct" />
  8.     <property name="web.dir" value="${basedir}/application/webapp" />
  9.     <property name="web.classes.dir" location="${web.dir}/WEB-INF/classes" />
  10.     <property name="web.testclasses.dir" location="${web.dir}/testclasses" />
  11.     <property name="target.dir" location="${basedir}/release" />
  12.     <property name="deploy.file" location="${target.dir}/myproduct.war" />
  13.     <property name="lib.dir" value="${web.dir}/WEB-INF/lib" />
  14.     <ivy:settings file="${web.dir}/ivysettings.xml" />
  15.  
  16.     <!-- Ivy    -->
  17.     <target name="resolve" description="retrieve dependencies with ivy">
  18.  
  19.         <echo message="Getting dependencies..." />
  20.         <echo message="Ivy Settings: ${web.dir}/ivysettings.xml" />
  21.  
  22.  
  23.         <ivy:resolve file="${web.dir}/ivy.xml" />
  24.  
  25.         <ivy:cachepath pathid="compile.path" conf="compile" />
  26.         <ivy:cachepath pathid="runtime.path" conf="runtime" />
  27.         <ivy:cachepath pathid="test.path" conf="test" />
  28.        
  29.         <pathconvert property="classpathProp" refid="compile.path"/>
  30.         <echo>Classpath is ${classpathProp}</echo>
  31.  
  32.     </target>
  33.  
  34.     <fileset id="lib.jars" dir="${lib.dir}">
  35.         <include name="**/*.jar" />
  36.     </fileset>
  37.  
  38.     <path id="compile.path">
  39.         <fileset refid="lib.jars" />
  40.     </path>
  41.  
  42.     <!-- Compile Java source from ${src.dir} and output it to ${web.classes.dir} -->
  43.     <target name="compile" depends="init, resolve" description="compile source code">
  44.         <mkdir dir="${web.classes.dir}" />
  45.         <javac destdir="${web.classes.dir}" includeantruntime="false" debug="true" encoding="ISO-8859-1" >
  46.             <src path="${src.dir}" />
  47.             <classpath>
  48.                 <path refid="compile.path"/>
  49.                 <fileset dir="C:\Program Files\apache-tomcat-7.0.63\lib">
  50.                     <include name="el-api.jar"/>
  51.                     <include name="servlet-api.jar"/>
  52.                     <include name="jsp-api.jar"/>
  53.                 </fileset>
  54.             </classpath>
  55.         </javac>
  56.         <mkdir dir="${web.testclasses.dir}" />
  57.         <javac destdir="${web.testclasses.dir}" includeantruntime="false" debug="true" encoding="ISO-8859-1" >
  58.             <src path="${testsrc.dir}" />
  59.             <classpath>
  60.                 <path refid="test.path"/>
  61.                 <pathelement location="${web.classes.dir}"/>
  62.                 <fileset dir="C:\Program Files\apache-tomcat-7.0.63\lib">
  63.                     <include name="el-api.jar"/>
  64.                     <include name="servlet-api.jar"/>
  65.                     <include name="jsp-api.jar"/>
  66.                 </fileset>
  67.             </classpath>
  68.         </javac>
  69.        
  70.         <path id="junit.class.path">
  71.             <pathelement location="${web.testclasses.dir}"/>
  72.         </path>
  73.     </target>
  74.  
  75.     <!-- Create the final WAR file for deployment -->
  76.     <target name="package" depends="compile, junit" description="create a war file">
  77.  
  78.         <!-- ivy get dependencies from ivy cache and copy it into ${lib.dir} -->
  79.         <ivy:retrieve pattern="${lib.dir}/[artifact]-[revision].[ext]" conf="runtime" />
  80.         <ivy:report conf="compile" />
  81.         <war destfile="${deploy.file}" webxml="${web.dir}/WEB-INF/web.xml">
  82.  
  83.             <webinf dir="${web.dir}/WEB-INF" />
  84.             <zipfileset dir="${web.dir}/jsp" prefix="jsp" />
  85.             <zipfileset dir="${web.dir}/tld" prefix="tld" />
  86.             <zipfileset dir="${web.dir}/img" prefix="img" />
  87.             <zipfileset dir="${web.dir}/js" prefix="js" />
  88.             <zipfileset dir="${web.dir}/css" prefix="css" />
  89.             <zipfileset dir="${web.dir}/contents" prefix="contents" />
  90.             <zipfileset dir="${web.dir}/fonts" prefix="fonts" />
  91.  
  92.         </war>
  93.     </target>
  94.  
  95.     <!-- Create folders -->
  96.     <target name="init">
  97.         <mkdir dir="${target.dir}" />
  98.         <echo message="${target.dir}"> created.</echo>
  99.         <mkdir dir="${web.classes.dir}" />
  100.         <echo message="${web.classes.dir}"> created.</echo>
  101.     </target>
  102.  
  103.     <!-- Delete folders -->
  104.     <target name="clean" description="clean up">
  105.         <ivy:cleancache />
  106.         <delete dir="${web.classes.dir}" />
  107.         <delete dir="${target.dir}" />
  108.         <delete includeEmptyDirs="true">
  109.             <fileset dir="${lib.dir}" includes="**/*" defaultexcludes="no" />
  110.         </delete>
  111.     </target>
  112.  
  113.     <target name="main" depends="clean, package" />
  114.  
  115.     <target name="report">
  116.         <ivy:cleancache />
  117.         <ivy:retrieve file="${web.dir}/ivy.xml" />
  118.         <ivy:report conf="compile" />
  119.     </target>
  120.    
  121.    
  122.     <target name="junit" depends="compile">
  123.         <echo message="|-- JUnit Classpath"/>
  124.         <echo message="| |"/>
  125.         <echo message="| |-- ${web.testclasses.dir}"/>
  126.        
  127.         <path id="junit.classpath">
  128.             <path refid="test.path"/>
  129.             <pathelement location="${web.testclasses.dir}"/>
  130.             <pathelement location="${web.classes.dir}"/>
  131.             <dirset dir="${web.testclasses.dir}">
  132.               <include name="**"/>
  133.             </dirset>
  134.         </path>
  135.        
  136.         <pathconvert property="junit.classpath.property" refid="junit.classpath" />
  137.         <echo message="JUnit classpath: ${junit.classpath.property}"/>
  138.        
  139.         <junit printsummary="yes" haltonfailure="yes" fork="true" >
  140.            
  141.            
  142.             <classpath>
  143.                 <path refid="junit.classpath"/>
  144.             </classpath>
  145.            
  146.            
  147.             <formatter type="xml"/>
  148.            
  149.             <batchtest fork="yes" todir="${web.testclasses.dir}">
  150.                 <fileset dir="${testsrc.dir}">
  151.                   <include name="**/*.java"/>
  152.                   <exclude name="**/TestUtils.java"/>
  153.                 </fileset>
  154.             </batchtest>
  155.         </junit>
  156.     </target>
  157.  
  158. </project>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement