| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- <?xml version="1.0" encoding="UTF-8"?>
- <project name="ieat2" basedir="." default="war"
- xmlns:ivy="antlib:org.apache.ivy.ant">
- <property name="lib.dir" value="lib/"/>
- <property name="web.dir" value="web/"/>
- <property name="test.dir" value="tests/"/>
- <property name="conf.dir" value="conf/dev/"/>
- <property name="script.dir" value="scripts/"/>
- <property name="ant.lib" value="${user.home}/.ant/lib"/>
- <property name="ant.conf.dir" value="${conf.dir}/ant/"/>
-
- <property prefix="app" file="${ant.conf.dir}/app.properties"/>
- <property name="app.conf.dir" value="${conf.dir}/app/"/>
- <property prefix="tomcat" file="${ant.conf.dir}/tomcat.properties"/>
- <property prefix="build" file="${ant.conf.dir}/build.properties"/>
- <property name="build.lib" value="${lib.dir}/war/"/>
- <property name="build.warfile"
- value="${build.dir}/${app.name}-${build.version}.war"/>
- <tstamp>
- <format property="build.time" pattern="MM/dd/yyyy hh:mm aa z" />
- </tstamp>
- <property prefix="test" file="${ant.conf.dir}/test.properties"/>
- <property name="test.lib" value="${lib.dir}/test/"/>
- <property name="test.target.dir" value="${build.dir}/tests"/>
- <property name="source.dir" value="src/"/>
- <property name="source.dir.java" value="${source.dir}/java"/>
- <property name="target.dir.server"
- value="${build.dir}/${app.name}/WEB-INF/classes"/>
- <property name="target.dir.client" value="${build.dir}/${app.name}/js"/>
- <property prefix="compile" file="${ant.conf.dir}/compile.properties"/>
- <property name="compile.lib" value="${lib.dir}/compile"/>
- <path id="compile.classpath">
- <pathelement location="${target.dir.server}"/>
- <fileset dir="${compile.lib}" includes="*.jar"/>
- </path>
-
- <property name="ivy.jar" value="${ant.lib}/ivy.jar"/>
- <property name="ivy.dep.file" value="${ant.conf.dir}/ivy.xml" />
- <available property="ivy.installed" file="${ivy.jar}"/>
- <property name="kotlin.lib" value="/opt/kotlinc/lib" />
- <typedef resource="org/jetbrains/kotlin/ant/antlib.xml"
- classpath="${kotlin.lib}/kotlin-ant.jar"/>
-
- <target name="help" description="Display build help">
- <echo>iEat v${build.version}</echo>
- <echo>To see list of targets, use ant -p</echo>
- </target>
- <target name="skip.ivy"
- description="Do not check dependencies. (Saves laptop battery)">
- <property name="ivy.skip" value="true"/>
- </target>
- <target name="ivy.install" unless="ivy.installed">
- <mkdir dir="${ant.lib}"/>
- <get dest="${ivy.jar}"
- src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.3.0/ivy-2.3.0.jar"/>
- <taskdef resource="org/apache/ivy/ant/antlib.xml"
- uri="antlib:org.apache.ivy.ant"
- classpath="${ivy.jar}"/>
- <property name="ivy.installed" value="true"/>
- </target>
- <target name="ivy.tree" depends="ivy.install"
- description="Show the dependency tree.">
- <ivy:dependencytree />
- </target>
- <target name="ivy.resolve.compile" unless="ivy.skip" depends="ivy.install">
- <ivy:retrieve pattern="${lib.dir}/[conf]/[artifact].[ext]" conf="compile"/>
- </target>
- <target name="ivy.resolve.war" unless="ivy.skip" depends="ivy.install">
- <ivy:retrieve pattern="${lib.dir}/[conf]/[artifact].[ext]" conf="war"/>
- </target>
- <target name="ivy.resolve.test" unless="ivy.skip" depends="ivy.install">
- <ivy:retrieve pattern="${lib.dir}/[conf]/[artifact].[ext]" conf="test"/>
- </target>
- <target name="ivy.resolve.ant" unless="ivy.skip" depends="ivy.install">
- <ivy:retrieve pattern="${ant.lib}/[artifact].[ext]" conf="ant"/>
- </target>
-
- <target name="test.load" depends="ivy.resolve.ant">
- <taskdef name="junit"
- classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" />
- </target>
- <target name="init.db"
- description="Pre-populate database with seed from USDA. (Unix Only)">
- <!-- TODO: Port Unix scripts to batch -->
- <exec executable="${script.dir}/import_weights.sh" />
- </target>
- <target name="deploy.load" depends="ivy.resolve.ant">
- <path id="ant.lib.path">
- <fileset dir="${ant.lib}" includes="*.jar"/>
- </path>
- <taskdef resource="org/apache/catalina/ant/antlib.xml"
- uri="antlib:org.apache.catalina.ant">
- <classpath refid="ant.lib.path"/>
- </taskdef>
- <taskdef name="deploy"
- classname="org.apache.catalina.ant.DeployTask">
- <classpath refid="ant.lib.path"/>
- </taskdef>
- <taskdef name="undeploy"
- classname="org.apache.catalina.ant.UndeployTask">
- <classpath refid="ant.lib.path"/>
- </taskdef>
- </target>
-
- <target name="ivy.resolve"
- depends="ivy.resolve.compile,ivy.resolve.war,ivy.resolve.ant"
- description="Use ivy to resolve compilation dependencies"/>
- <target name="compile.server" depends="ivy.resolve.compile"
- description="Compile server source files">
- <mkdir dir="${target.dir.server}"/>
- <javac srcdir="${source.dir.java}"
- excludes="name/tflucke/ieat2/client/**"
- verbose="${compile.verbose}"
- destdir="${target.dir.server}"
- debug="${compile.debug}"
- deprecation="${compile.deprecation}"
- optimize="${compile.optimize}"
- nowarn="${compile.nowarn}"
- includeantruntime="${compile.include.ant}"
- bootclasspath="${build.bootstrap.path}"
- target="${build.java.version}"
- source="${build.java.version}">
- <classpath refid="compile.classpath" />
- <withKotlin/>
- </javac>
- <!--
- TF 2019-09-09: May not be nessisary because of withKotlin
- <kotlinc src="${source.dir.kotlin}"
- output="${target.dir.server}"
- nowarn="${compile.nowarn}"
- classpath="${compile.classpath}">
- <compilerarg value="-verbose"/>
- <compilerarg line="-jvm-target ${build.java.version}"/>
-
- verbose="${compile.verbose}" -verbose
- deprecation="${compile.deprecation}" -progressive
- optimize="${compile.optimize}" -Xno-optimize
- </kotlinc>
- -->
- </target>
- <target name="compile.client" depends="ivy.resolve.compile"
- description="Compile client source files">
- <mkdir dir="${target.dir.client}"/>
- <kotlin2js src="${source.dir.java}"
- output="${target.dir.client}/generated.js"
- nowarn="${compile.nowarn}">
- </kotlin2js>
- </target>
- <target name="compile.tests" depends="ivy.resolve.test,compile.server"
- description="Compile test files">
- <mkdir dir="${test.target.dir}"/>
- <javac srcdir="${test.dir}"
- verbose="${compile.verbose}"
- destdir="${test.target.dir}"
- debug="${compile.debug}"
- deprecation="${compile.deprecation}"
- optimize="false"
- nowarn="${compile.nowarn}"
- includeantruntime="${compile.include.ant}"
- bootclasspath="${build.bootstrap.path}"
- target="${build.java.version}"
- source="${build.java.version}">
- <classpath>
- <path refid="compile.classpath"/>
- <fileset dir="${test.lib}" includes="*.jar"/>
- </classpath>
- </javac>
- </target>
-
- <target name="war" depends="compile.server,compile.client,ivy.resolve.war"
- description="Create application WAR">
- <mkdir dir="${build.dir}"/>
- <war warfile="${build.warfile}" webxml="${app.conf.dir}/web.xml">
- <lib dir="${build.lib}"/>
- <fileset dir="web"/>
- <fileset dir="${build.dir}/${app.name}">
- <include name="js/**/*.js"/>
- </fileset>
- <classes dir="${target.dir.server}"/>
- <classes dir="${app.conf.dir}">
- <exclude name="web.xml"/>
- </classes>
- </war>
- </target>
- <target name="test.server"
- description="Run all unit tests on server"
- depends="compile.server,compile.tests,test.load">
- <junit printsummary="yes"
- haltonfailure="${test.halt.failure}"
- haltonerror="${test.halt.error}">
- <classpath>
- <path refid="compile.classpath"/>
- <fileset dir="${test.lib}" includes="*.jar"/>
- <fileset dir="${lib.dir" includes="*.jar"/>
- <pathelement location="${test.target.dir}"/>
- <pathelement location="conf/test/app/"/>
- </classpath>
- <batchtest fork="yes">
- <fileset dir="${test.dir}">
- <include name="**/*.java"/>
- </fileset>
- <formatter type="plain" usefile="false"/>
- </batchtest>
- </junit>
- </target>
-
- <target name="test" description="Run all tests" depends="test.server">
- </target>
-
- <target name="clean" description="Delete build files">
- <delete dir="${build.dir}" />
- </target>
- <target name="clean.full" depends="clean"
- description="Delete build files and dependencies">
- <delete dir="${ivy.jar}"/>
- <delete dir="${lib.dir}"/>
- <ivy:cleancache/>
- </target>
- <target name="deploy" depends="war,deploy.load" description="Deploy to tomcat">
- <deploy url="http://localhost:8080/manager/text"
- username="${tomcat.username}"
- password="${tomcat.password}"
- update="true"
- path="/${app.name}-${build.version}"
- war="file:./${build.warfile}" />
- </target>
- <target name="undeploy" depends="deploy.load" description="Undeploy from tomcat">
- <undeploy url="http://localhost:8080/manager/text"
- username="${tomcat.username}"
- password="${tomcat.password}"
- path="/${app.name}-${build.version}"/>
- </target>
- </project>
|