Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.87 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project name="museumdb" default="dist" basedir=".">
  3. <description>Builds, tests, and runs the project.</description>
  4. <!-- ******************************************************************* -->
  5. <!-- * Project Home Directories * -->
  6. <!-- ******************************************************************* -->
  7. <!-- * We should include most dependancy jars in the repository. * -->
  8. <!-- ******************************************************************* -->
  9.  
  10. <!-- Override this with "ant -Dconf.home=./conf.example deploy" -->
  11. <property name="conf.home" value="${basedir}/conf/local" />
  12.  
  13. <!-- Load the build environment properties -->
  14. <property file="${conf.home}/build.properties"/>
  15.  
  16. <!-- ******************************************************************* -->
  17. <!-- * Classpath Parameters * -->
  18. <!-- ******************************************************************* -->
  19. <!-- * The different classpaths that are used in the build process. * -->
  20. <!-- ******************************************************************* -->
  21.  
  22. <path id="log4j.classpath">
  23. <fileset dir="${log4j.home}" id="log4j.files" includes="log4j-1.2.8.jar"/>
  24. </path>
  25. <path id="dist.classpath">
  26. <pathelement location="${dist.home}"/>
  27. </path>
  28. <path id="bin.classpath">
  29. <pathelement location="${bin.home}"/>
  30. </path>
  31. <path id="json-simple.classpath">
  32. <fileset dir="${json-simple.home}" id="json-simple.files" includes="json_simple-1.1.jar"/>
  33. </path>
  34. <path id="cas.classpath">
  35. <fileset dir="${cas.home}">
  36. <include name="cas.jar"/>
  37. <include name="cas-client-core-3.1.10.jar"/>
  38. </fileset>
  39. </path>
  40. <path id="jdbc.classpath">
  41. <fileset dir="${jdbc.home}" id="jdbc.files">
  42. <include name="postgres-*.jar"/>
  43. <include name="mysql-connector*.jar"/>
  44. <include name="commons-logging-1.1*.jar"/>
  45. </fileset>
  46. </path>
  47. <path id="tomcat.classpath">
  48. <fileset dir="${tomcat.home}" id="tomcat.files">
  49. <include name="catalina-ant.jar"/>
  50. <include name="servlet-api-2.5.jar"/>
  51. </fileset>
  52. </path>
  53. <path id="ant-contrib.classpath">
  54. <fileset dir="${ant-contrib.home}" id="ant-contrib.files">
  55. <include name="ant-contrib-0.6.jar"/>
  56. </fileset>
  57. </path>
  58. <path id="sysUtil.classpath">
  59. <fileset dir="${sysUtil.home}" id="sysUtil.files">
  60. <include name="ca.usask.cs.sysUtil.jar"/>
  61. </fileset>
  62. </path>
  63. <!-- TODO FIXME added by Dylan. Clean as necessary! -->
  64. <path id="junit.classpath">
  65. <fileset dir="${junit.home}" id="junit.files">
  66. <include name="junit-4.8.2.jar"/>
  67. </fileset>
  68. </path>
  69. <path id="lib.classpath">
  70. <pathelement location="${lib.home}"/>
  71. </path>
  72. <path id="test.classpath">
  73. <pathelement location="${test.home}"/>
  74. </path>
  75. <path id="selenium.rc.classpath">
  76. <fileset dir="${selenium.rc.home}" id="selenium.rc.files">
  77. <include name="selenium-java-client-driver.jar"/>
  78. </fileset>
  79. </path>
  80. <path id="spring.classpath">
  81. <fileset dir="${spring.home}" id="spring.files">
  82. <include name="spring*.jar"/>
  83. </fileset>
  84. </path>
  85. <path id="transaction.classpath">
  86. <fileset dir="${lib.home}" id="transaction.files">
  87. <include name="aopalliance.jar"/>
  88. </fileset>
  89. </path>
  90. <path id="jstl.classpath">
  91. <fileset dir="${lib.home}" id="jstl.files">
  92. <include name="jstl-impl-1.2.jar"/>
  93. <include name="standard.jar" />
  94. </fileset>
  95. </path>
  96. <path id="mockito.classpath">
  97. <fileset dir="${lib.home}" id="mockito.files">
  98. <include name="mockito-all-1.8.5.jar"/>
  99. </fileset>
  100. </path>
  101. <path id="reflections.classpath">
  102. <fileset dir="${lib.home}" id="reflections.files">
  103. <include name="reflections-0.9.5-RC2.jar"/>
  104. <include name="google-collections-1.0.jar"/>
  105. <include name="slf4j-api-1.5.6.jar"/>
  106. <include name="logback-classic-0.9.9.jar"/>
  107. <include name="gson-1.4.jar"/>
  108. <include name="dom4j-1.6.jar"/>
  109. <include name="xml-apis-1.0.b2.jar"/>
  110. <include name="servlet-api-2.5.jar"/>
  111. <include name="javassist-3.8.0.GA.jar"/>
  112. <include name="logback-core-0.9.9.jar"/>
  113. </fileset>
  114. </path>
  115. <path id="cobertura.classpath">
  116. <fileset dir="${cobertura.home}">
  117. <include name="cobertura.jar" />
  118. <include name="asm-3.0.jar" />
  119. <include name="asm-tree-3.0.jar" />
  120. <include name="jakarta-oro-2.0.8.jar" />
  121. <include name="log4j-1.2.9.jar" />
  122. </fileset>
  123. </path>
  124.  
  125.  
  126. <!-- ******************************************************************* -->
  127. <!-- * Task Definitions * -->
  128. <!-- ******************************************************************* -->
  129. <!-- * This area identifies the external ant tasks that we want to be * -->
  130. <!-- * able to use. Of particular interest are the tomcat tasks, * -->
  131. <!-- * which can be used for automatic deployment, as well as the * -->
  132. <!-- * ant-contrib tasks which contain additional useful ant routines. * -->
  133. <!-- ******************************************************************* -->
  134.  
  135. <taskdef name="tomcat-stop" classname="org.apache.catalina.ant.StopTask">
  136. <classpath refid="tomcat.classpath"/>
  137. </taskdef>
  138. <taskdef name="tomcat-start" classname="org.apache.catalina.ant.StartTask">
  139. <classpath refid="tomcat.classpath"/>
  140. </taskdef>
  141. <taskdef name="tomcat-deploy" classname="org.apache.catalina.ant.DeployTask">
  142. <classpath refid="tomcat.classpath"/>
  143. </taskdef>
  144. <taskdef name="tomcat-undeploy" classname="org.apache.catalina.ant.UndeployTask">
  145. <classpath refid="tomcat.classpath"/>
  146. </taskdef>
  147. <taskdef resource="net/sf/antcontrib/antcontrib.properties">
  148. <classpath refid="ant-contrib.classpath"/>
  149. </taskdef>
  150.  
  151.  
  152. <taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
  153.  
  154. <!-- ******************************************************************* -->
  155. <!-- * Targets * -->
  156. <!-- ******************************************************************* -->
  157. <!-- * The meat of the ant build file, each target is an action that * -->
  158. <!-- * you want to be able to perform. * -->
  159. <!-- ******************************************************************* -->
  160.  
  161.  
  162.  
  163. <target name="clean"
  164. description="Removes the built classes." >
  165. <delete dir="${dist.home}" />
  166. <delete dir="${admin.home}" />
  167. </target>
  168.  
  169. <target name="doc" description="Builds javadoc documentation." >
  170. <echo> Generating javadoc at ${src.home}</echo>
  171. <javadoc destdir="${docs.home}/api"
  172. sourcepath="${src.home}/java/ca/usask/cs/museum/"
  173. source="1.6"
  174. windowtitle="API Documentation">
  175.  
  176. <classpath>
  177. <!--<pathelement location="${bin.home}" />-->
  178. <fileset dir="${basedir}/lib">
  179. <include name="*.jar"/>
  180. </fileset>
  181. </classpath>
  182.  
  183. <fileset dir="${basedir}/src/java/ca/usask/cs/museum">
  184. <!--<include name="acquisition/controllers/*.java"/>-->
  185. <include name="**/**/*.java"/>
  186. </fileset>
  187.  
  188. </javadoc>
  189. </target>
  190.  
  191. <target name="build"
  192. depends="clean"
  193. description="Builds class tree from sources." >
  194. <echo message="Building."/>
  195. <mkdir dir="${bin.home}"/>
  196. <javac source="1.6" debug="true" deprecation="true"
  197. destdir="${bin.home}" fork="true" srcdir="${src.home}"
  198. includeantruntime="false">
  199. <classpath refid="tomcat.classpath"/>
  200. <classpath refid="cas.classpath"/>
  201. <classpath refid="log4j.classpath"/>
  202. <classpath refid="json-simple.classpath" />
  203. <classpath refid="sysUtil.classpath"/>
  204. <classpath refid="jdbc.classpath"/>
  205. <classpath refid="spring.classpath"/>
  206. <classpath refid="transaction.classpath" />
  207. <classpath refid="jstl.classpath" />
  208. </javac>
  209. </target>
  210.  
  211.  
  212. <!-- Cleans some directories prior to tests.-->
  213. <target name="pre-test">
  214. <echo message="Cleaning old coverage reports."/>
  215. <delete dir="${cobertura.report.home}"/>
  216. <mkdir dir="${cobertura.report.home}"/>
  217. </target>
  218.  
  219. <target name="build-test"
  220. description="Compile the test source tree"
  221. depends="pre-test">
  222. <echo message="Building test files."/>
  223. <mkdir dir="${bin.home}" />
  224. <javac destdir="${bin.home}" source="1.6" target="1.6"
  225. debug="true" fork="true" deprecation="false"
  226. optimize="false" failonerror="true"
  227. includeantruntime="false" >
  228. <src path="${test.home}" />
  229. <classpath refid="tomcat.classpath"/>
  230. <classpath refid="cas.classpath"/>
  231. <classpath refid="log4j.classpath"/>
  232. <classpath refid="json-simple.classpath" />
  233. <classpath refid="sysUtil.classpath"/>
  234. <classpath refid="selenium.rc.classpath"/>
  235. <classpath refid="junit.classpath"/>
  236. <classpath refid="spring.classpath"/>
  237. <classpath refid="mockito.classpath"/>
  238. <classpath refid="reflections.classpath"/>
  239. <classpath refid="transaction.classpath" />
  240. <classpath refid="jstl.classpath" />
  241. </javac>
  242. <!-- Cobertura stuff. -->
  243. <cobertura-instrument todir="${cobertura.bin.home}">
  244. <fileset dir="${bin.home}">
  245. <include name="**/*.class"/>
  246. </fileset>
  247. </cobertura-instrument>
  248. </target>
  249.  
  250. <target name="dist"
  251. depends="build"
  252. description="Creates war archive to deploy application" >
  253. <!-- Copy configuration files into classes dir (so they're in the classpath) -->
  254. <copy overwrite="yes" todir="${dist.home}/WEB-INF/classes">
  255. <fileset dir="${conf.home}" includes="*.properties" />
  256. </copy>
  257. <!-- Copy context.xml to META-INF -->
  258. <copy overwrite="yes" file="${conf.home}/context.xml" tofile="${dist.home}/META-INF/context.xml" />
  259. <!-- Copy web.xml to WEB-INF -->
  260. <copy overwrite="yes" file="${conf.home}/web.xml" tofile="${dist.home}/WEB-INF/web.xml" />
  261.  
  262. <!-- Copy *some of the* libraries into lib dir -->
  263. <copy overwrite="yes" todir="${dist.home}/WEB-INF/lib">
  264. <!--<fileset dir="${cas.home}" includes="**/*" />
  265. <fileset dir="${log4j.home}" includes="**/*" />
  266. <fileset dir="${json-simple.home}" includes="**/*" />
  267. <fileset dir="${sysUtil.home}" includes="**/*" />
  268. <fileset dir="${jdbc.home}" includes="**/*" />
  269. <fileset dir="${spring.home}" includes="**/*.jar" />-->
  270. <fileset dir="${lib.home}" includes="**/*.jar" />
  271. </copy>
  272. <!-- Copy web stuff into deploy root -->
  273. <copy overwrite="yes" todir="${dist.home}">
  274. <fileset dir="${basedir}/web" includes="**/*" />
  275. </copy>
  276. <jar destfile="${basedir}/${dist.name}.war" compress="true">
  277. <fileset dir="${dist.home}" />
  278. </jar>
  279. </target>
  280.  
  281. <target name="deploy"
  282. description="Deploys to remote tomcat instances."
  283. depends="dist,astyle">
  284. <foreach list="${machines}"
  285.  
  286. target="_deploy-single"
  287. param="identifier" />
  288. </target>
  289.  
  290. <!--Added by: Jordan Johns
  291. Purpose: To run Artistic Style on your source to ensure all our coding style/format is the same. -->
  292. <target name="astyle" description="Runs astyle on your source.">
  293.  
  294. <!-- LINUX CONDITIONAL EXECUTION-->
  295. <exec executable="${basedir}/lib/astyle/linux/astyle" osfamily="unix">
  296. <arg value="--style=allman"/>
  297. <arg value="--recursive"/>
  298. <arg value="${basedir}/*.java"/>
  299. </exec>
  300.  
  301. <!-- MAC CONDITIONAL EXECUTION-->
  302. <exec executable="${basedir}/lib/astyle/mac/astyle" osfamily="mac">
  303. <arg value="--style=allman"/>
  304. <arg value="--recursive"/>
  305. <arg value="${basedir}/*.java"/>
  306. </exec>
  307.  
  308. <!-- WINDOWS CONDITIONAL EXECUTION-->
  309. <exec executable="${basedir}/lib/astyle/windows/Astyle.exe" osfamily="windows">
  310. <arg value="--style=allman"/>
  311. <arg value="--recursive"/>
  312. <arg value="${basedir}/*.java"/>
  313. </exec>
  314. </target>
  315.  
  316.  
  317. <condition property="foo.path" value="C:\Foo\Dir">
  318. <os family="windows"/>
  319. </condition>
  320. <condition property="foo.path" value="/home/foo/dir">
  321. <os family="unix"/>
  322. </condition>
  323.  
  324.  
  325. <!--<target name="tomcat-start">
  326. <java jar="${catalina.home}/bin/bootstrap.jar" fork="true">
  327. <jvmarg value="-Dcatalina.home=${catalina.home}"/>
  328. </java>
  329. </target>
  330.  
  331. <target name="tomcat-stop">
  332. <java jar="${catalina.home}/bin/bootstrap.jar" fork="true">
  333. <jvmarg value="-Dcatalina.home=${catalina.home}"/>
  334. <arg line="stop"/>
  335. </java>
  336. </target>-->
  337.  
  338. <target name="_deploy-single"
  339. description="Deploys web app to a single tomcat instance from passed in identifier variable" >
  340. <!-- get specific properties from passed in machine name -->
  341. <propertycopy property="current.manager.url" from="${identifier}.manager.url" />
  342. <propertycopy property="current.manager.username" from="${identifier}.manager.username" />
  343. <propertycopy property="current.manager.password" from="${identifier}.manager.password" />
  344. <propertycopy property="current.manager.path" from="${identifier}.manager.path" />
  345.  
  346. <echo message="Preparing to deploy to ${identifier}" />
  347. <echo message="Using ${current.manager.username} on ${current.manager.url} with path ${current.manager.path}" />
  348. <!-- stop the current service -->
  349.  
  350. <echo>Stopping old museumdb instance.</echo>
  351. <trycatch>
  352. <try>
  353. <tomcat-stop url="${current.manager.url}"
  354. username="${current.manager.username}"
  355. password="${current.manager.password}"
  356. path="${current.manager.path}"/>
  357. </try>
  358. <catch>
  359. </catch>
  360. </trycatch>
  361.  
  362. <!-- undeploy the old war -->
  363. <echo>Undeploying old museumdb instance.</echo>
  364. <trycatch>
  365. <try>
  366. <tomcat-undeploy url="${current.manager.url}"
  367. username="${current.manager.username}"
  368. password="${current.manager.password}"
  369. path="${current.manager.path}"/>
  370. </try>
  371. <catch>
  372. </catch>
  373. </trycatch>
  374.  
  375. <!-- deploy the new war -->
  376. <echo>Deploying new museumdb instance.</echo>
  377. <trycatch>
  378. <try>
  379. <tomcat-deploy url="${current.manager.url}"
  380. username="${current.manager.username}"
  381. password="${current.manager.password}"
  382. war="${basedir}/${dist.name}.war"
  383. path="${current.manager.path}"/>
  384. <echo message="Deployed to ${current.manager.path}" />
  385. </try>
  386. <catch>
  387. </catch>
  388. </trycatch>
  389.  
  390. <echo>Starting new museumdb instance.</echo>
  391. <trycatch>
  392. <try>
  393. <tomcat-start url="${current.manager.url}"
  394. username="${current.manager.username}"
  395. password="${current.manager.password}"
  396. path="${current.manager.path}"/>
  397. </try>
  398. <catch>
  399. </catch>
  400. </trycatch>
  401.  
  402. </target>
  403.  
  404. <!-- TODO FIXME Added by Dylan. Buildmasta, please clean this up to your standards! TODO FIXME -->
  405. <!-- Runs JUnit tests on the project -->
  406. <target name="test" depends="build,build-test,deploy" >
  407. <echo message="Running all tests to make sure the project is sound" />
  408. <junit printsummary="yes" haltonfailure="no" showoutput="yes" >
  409. <sysproperty key="museumdb.website.address" value="${museumdb.website.address}"/>
  410. <sysproperty key="selenium.port" value="${selenium.port}"/>
  411.  
  412. <!-- Specify the name of the coverage data file to use. -->
  413. <sysproperty key="net.sourceforge.cobertura.datafile" file="${cobertura.ser}" />
  414.  
  415. <classpath location="${cobertura.bin.home}" />
  416. <classpath location="${bin.home}" />
  417. <classpath>
  418. <path refid="junit.classpath" />
  419. <path refid="lib.classpath" />
  420. <path refid="test.classpath" />
  421. <path refid="selenium.rc.classpath" />
  422. <path refid="spring.classpath" />
  423. <path refid="log4j.classpath" />
  424. <path refid="mockito.classpath"/>
  425. <path refid="reflections.classpath"/>
  426. <path refid="transaction.classpath" />
  427. <path refid="cobertura.classpath" />
  428. <path refid="jdbc.classpath" />
  429. </classpath>
  430.  
  431. <formatter type="brief" usefile="false" />
  432. <formatter type="plain" />
  433.  
  434. <batchtest fork="yes" >
  435. <fileset dir="${test.home}" >
  436. <include name="**/*Test*.java" />
  437.  
  438. <exclude name="**/example/**" />
  439. <exclude name="**/test/utility/**" />
  440. <exclude name="**/test/annotations/**" />
  441. <exclude name="**/SmokeTestSuite.java" />
  442. </fileset>
  443. </batchtest>
  444. </junit>
  445. </target>
  446.  
  447. <!-- Runs tests on the project, excluding GUI tests. -->
  448. <target name="no-gui-test" depends="build,build-test,deploy" >
  449. <echo message="Running all tests to make sure the project is sound" />
  450. <junit printsummary="yes" haltonfailure="no" showoutput="yes" >
  451. <sysproperty key="museumdb.website.address" value="${museumdb.website.address}"/>
  452. <sysproperty key="selenium.port" value="${selenium.port}"/>
  453.  
  454. <!-- Specify the name of the coverage data file to use. -->
  455. <sysproperty key="net.sourceforge.cobertura.datafile" file="${cobertura.ser}" />
  456.  
  457. <classpath location="${cobertura.bin.home}" />
  458. <classpath location="${bin.home}" />
  459. <classpath>
  460. <path refid="junit.classpath" />
  461. <path refid="lib.classpath" />
  462. <path refid="test.classpath" />
  463. <path refid="selenium.rc.classpath" />
  464. <path refid="spring.classpath" />
  465. <path refid="log4j.classpath" />
  466. <path refid="mockito.classpath"/>
  467. <path refid="reflections.classpath"/>
  468. <path refid="transaction.classpath" />
  469. <path refid="cobertura.classpath" />
  470. <path refid="jdbc.classpath" />
  471. </classpath>
  472.  
  473.  
  474. <formatter type="brief" usefile="false" />
  475. <formatter type="plain" />
  476.  
  477. <batchtest fork="yes" >
  478. <fileset dir="${test.home}">
  479. <include name="**/*Test*.java" />
  480.  
  481. <exclude name="**/test/gui/**" />
  482. <exclude name="**/example/**" />
  483. <exclude name="**/test/utility/**" />
  484. <exclude name="**/test/annotations/**" />
  485. <exclude name="**/SmokeTestSuite.java" />
  486. </fileset>
  487. </batchtest>
  488. </junit>
  489. </target>
  490.  
  491. <!-- Runs the Smoke Test -->
  492. <target name="smoke-test" depends="build,build-test,deploy" >
  493. <echo message="Running smoke tests to make sure basic functionality is not compromised." />
  494. <junit printsummary="yes" haltonfailure="no" showoutput="yes" >
  495. <sysproperty key="museumdb.website.address" value="${museumdb.website.address}"/>
  496. <sysproperty key="selenium.port" value="${selenium.port}"/>
  497.  
  498. <!-- Specify the name of the coverage data file to use. -->
  499. <sysproperty key="net.sourceforge.cobertura.datafile" file="${cobertura.ser}" />
  500.  
  501. <classpath location="${cobertura.bin.home}" />
  502. <classpath location="${bin.home}" />
  503. <classpath>
  504. <path refid="junit.classpath" />
  505. <path refid="lib.classpath" />
  506. <path refid="test.classpath" />
  507. <path refid="selenium.rc.classpath" />
  508. <path refid="spring.classpath" />
  509. <path refid="log4j.classpath" />
  510. <path refid="mockito.classpath"/>
  511. <path refid="reflections.classpath"/>
  512. <path refid="transaction.classpath" />
  513. <path refid="cobertura.classpath" />
  514. <path refid="jdbc.classpath" />
  515. </classpath>
  516.  
  517. <formatter type="brief" usefile="false" />
  518. <formatter type="plain" />
  519.  
  520. <batchtest fork="yes" >
  521. <fileset dir="${test.home}" >
  522.  
  523. <!-- IF THIS IS CHANGED, the "test" target must be updated as well, as it explicitly excludes the SmokeTestSuite class
  524. on the assumption that it runs all smoke tests.-->
  525. <include name="**/SmokeTestSuite.java" />
  526. </fileset>
  527. </batchtest>
  528. </junit>
  529. </target>
  530.  
  531. <target name="generate-coverage-report">
  532. <cobertura-report srcdir="${src.home}" destdir="${cobertura.report.home}" datafile="${cobertura.ser}">
  533. <fileset dir="${src.home}">
  534. <include name="**/*.java" />
  535. </fileset>
  536. </cobertura-report>
  537. </target>
  538.  
  539. </project>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement