source: other-projects/the-macronizer/trunk/build.xml

Last change on this file was 33865, checked in by ak19, 13 months ago
  1. The gs3 context name changed from macronizer to macron-restoration. 2. Western Wilson's sql related changes weren't committed to svn
  • Property svn:mime-type set to text/xml
File size: 8.2 KB
Line 
1<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2<project basedir="." default="war" name="TheMacronizer">
3
4 <property environment="env"/>
5 <!--
6 the associated Greenstone 3 installation folder
7 You're expected to run/source the gs3-setup script in the GS3
8 before running the default ant target in this file.
9 You will be warned of this if you attempt to run this ant
10 build.xml file without doing gs3-setup.
11 -->
12 <property name="gsdl3.web.home" value="${env.GSDL3HOME}"/>
13 <property name="gsdl3.src.home" value="${env.GSDL3SRCHOME}"/>
14
15 <property name="dist.dir.exp" location="releases" />
16
17 <property name="dist.filename.exp" value="TheMacronizer.war" />
18 <property name="build.dir.exp" location="web" />
19 <property name="lib.dir.exp" location="web/WEB-INF/lib" />
20 <property name="webinf.dir" location="web/WEB-INF" />
21 <!-- Properties for MacroniserLogFileProcessor, use FULL PATHS -->
22 <property name="scripts.dir" location="${basedir}/src/scripts-and-sql" />
23 <property name="logfileproc.dir" value="${basedir}/logproc"/>
24
25 <!--
26 If changing these values, make sure you run 'ant clean'
27 -->
28 <property name="javac.source" value="1.8" />
29 <property name="javac.target" value="${javac.source}" />
30 <property name="javac.debug" value="true" />
31
32
33 <path id="classpath.exp">
34 <fileset dir="${lib.dir.exp}">
35 <include name="*.jar" />
36 </fileset>
37 </path>
38
39
40 <target name="clean">
41 <!-- delete only the class files built by themacronizer -->
42 <delete dir="${build.dir.exp}/WEB-INF/classes"/>
43 </target>
44
45
46 <target name="init">
47 <!-- has the gs3-setup script been run?? -->
48 <condition property="gs3-setup-not-done">
49 <not>
50 <isset property="env.GSDL3HOME"/>
51 </not>
52 </condition>
53 <fail if="gs3-setup-not-done" message="Please run 'gs3-setup' (Windows) or 'source gs3-setup.sh' (Linux/Mac) in the Greenstone3 installation that's associated with this Macronizer installation before this step."/>
54
55
56 <echo message="${ant.project.name}: ${ant.file}"/>
57 <mkdir dir="${build.dir.exp}/WEB-INF/classes"/>
58 <mkdir dir="${build.dir.exp}/WEB-INF/classes/monogram"/>
59 <copy includeemptydirs="false" todir="${build.dir.exp}/WEB-INF/classes/monogram/data">
60 <fileset dir="src/java/monogram/data" />
61 </copy>
62 </target>
63
64 <target name="build" depends="init">
65 <javac source="${javac.source}" target="${javac.target}" debug="${javac.debug}"
66 encoding="utf-8"
67 destdir="${build.dir.exp}/WEB-INF/classes" includeantruntime="false">
68 <src path="src"/>
69
70 <classpath>
71 <path refid="classpath.exp"/>
72 <pathelement location="src/jars/servlet-api.jar"/>
73 <pathelement path="src/java"/>
74 <pathelement path="webinf.dir"/>
75 </classpath>
76 </javac>
77
78 <!-- http://ant.apache.org/manual/Tasks/copy.html
79 By default, files are only copied if the source file is newer than the destination file,
80 or when the destination file does not exist. However, you can explicitly overwrite files
81 with the overwrite attribute.-->
82
83 <filter token="macronizer.home" value="${basedir}"/>
84
85 <!-- 1a. Create the log4j.properties file from its log4j.properties.in template file and put it into the *Macronizer* installation's web/WEB-INF/classes folder -->
86 <copy file="${build.dir.exp}/log4j.properties.in" tofile="${build.dir.exp}/WEB-INF/classes/log4j.properties" filtering="true" overwrite="true"/>
87
88 <!-- 1b. Create the mysql.props file -->
89 <copy file="${build.dir.exp}/mysql.properties.in" tofile="${build.dir.exp}/WEB-INF/classes/mysql.properties" filtering="true" overwrite="true"/>
90
91 <!-- TODO: Ask Ryan Ko if the following message is fit to be known in public:
92 <echo>Make sure to change the mysql db.password property in WEB-INF/classes/mysql.properties</echo>
93 -->
94
95 <!-- 2. Create the macronizer.xml tomcat context file from the macronizer.xml.in template file and put it into the correct location in the associated GS3 installation -->
96 <copy file="${build.dir.exp}/macronizer.xml.in" tofile="${gsdl3.src.home}/packages/tomcat/conf/Catalina/localhost/macron-restoration.xml" filtering="true" overwrite="true"/>
97
98 <!-- mkdir Creates a directory. Also non-existent parent directories are created,
99 when necessary. Does nothing if the directory already exist. -->
100 <mkdir dir="${build.dir.exp}/logs"/>
101
102 <!-- For the MacroniserFileLogProcessor, which sets up a nightly cron to send useful logging info
103 from the daily macron.log.<date> files to a mysqldb, need to do some setup too -->
104 <copy file="${build.dir.exp}/mysql.properties.in" tofile="${basedir}/mysql.properties" filtering="true" overwrite="true"/>
105
106 <mkdir dir="${logfileproc.dir}"/>
107
108 <filter token="macronizer.scripts" value="${scripts.dir}"/>
109 <filter token="macronizer.logs" value="${build.dir.exp}/logs"/>
110 <copy file="${basedir}/src/scripts-and-sql/cron.in" tofile="${basedir}/src/scripts-and-sql/cron.txt" filtering="true" overwrite="true"/>
111
112 <filter token="logfileproc.exec_folder" value="${build.dir.exp}/WEB-INF/classes"/> <!-- where the util.MacroniserLogProcessor compiled code is -->
113 <filter token="logfileproc.dir" value="${logfileproc.dir}"/>
114 <filter token="jarlibs.folder" value="${build.dir.exp}/WEB-INF/lib"/>
115 <filter token="classes.folder" value="${build.dir.exp}/WEB-INF/classes"/>
116 <!-- Why can't we set the classpath to the mysql.properties file
117 to be anywhere other than the toplevel Macronizer folder/basedir?
118 Anything else causes class MySQLAccess of MacroniserLogFileProcessor
119 to fail with mysql.properties FileNotFoundException -->
120 <!--<filter token="mysqlprops.dir" value="${logfileproc.dir}"/>-->
121 <filter token="mysqlprops.dir" value="${basedir}"/>
122
123 <copy file="${scripts.dir}/macronLogToDB.bash.in" tofile="${scripts.dir}/macronLogToDB.bash" filtering="true" overwrite="true"/>
124 <chmod file="${scripts.dir}/macronLogToDB.bash" perm="ugo+rx"/>
125
126 <echo>*** Run the ant target 'ant logs-to-db-instructions' for instructions on setting up the MacroniserLogFileProcessor***</echo>
127 </target>
128
129 <target name="logs-to-db-instructions">
130 <echo> ************************************************************
131 Instructions on setting up the MacroniserLogFileProcessor
132 ************************************************************
133
134 1. Install mysql-5.7.23 as instructed at
135 http://wiki.greenstone.org/doku.php?id=en:user_advanced:greenstonesqlplugs#getting_and_running_mysql
136 (And when you run that mysql installation's db server, shut it down or run its mysql client,
137 do so as per the instructions there)
138
139 2. Use separate terminals to use the above instructions link to:
140 - Start the mysql server
141 - Connect to the mysql client
142
143 3. After connecting to the client, in the mysql client terminal
144 - IMPORTANT: don't forget to immediately follow with 'set names utf8mb4;'
145 - CREATE AND INITIALISE the Macroniser database and its tables by running
146 the MySQL_Code.sql script by typing the following and hitting ENTER:
147 source ${scripts.dir}/MySQL_Code.sql
148
149 3. Edit ${basedir}/mysql.properties to set the db password.
150 - If you set up a different username for the mysql db, set that in mysql.properties too.
151 - If nothing is set, MacronLogFileProcessor will assume the username is root.
152
153 4. Set up the daily cronjob as follows:
154 - open a terminal and type 'export EDITOR=emacs' (or set to the text editor you prefer)
155 - type 'crontab -e' and the editor will open the cronfile
156 - append the contents from ${scripts.dir}/cron.txt to the cronfile
157 - save file and exit the editor
158
159 5. If you have email rights on the linux you're working from,
160 type your email into macronLogToDB.bash.in and macronLogToDB.bash
161 to get sent emails on errors.
162
163 6. All going well, you should get output files in the ${logfileproc.dir}
164 folder after the cron job runs each night.
165
166 ************************************************************
167 </echo>
168 </target>
169
170 <target name="war" depends="build">
171 <echo>Basedir: ${basedir}</echo>
172 <jar destfile="${dist.filename.exp}">
173 <fileset dir="${build.dir.exp}" />
174 </jar>
175 </target>
176
177</project>
Note: See TracBrowser for help on using the repository browser.