root/other-projects/the-macronizer/trunk/build.xml @ 32755

Revision 32755, 7.8 KB (checked in by ak19, 17 months ago)

Western Wilson stuff. Final changes to get the mysql.props file running directly off the-macronizer checkout after ant's been run on it (and the 'ant logs-to-db-instructions' have been followed)

  • Property svn:mime-type set to text/xml
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    <!-- 1. 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    <!-- 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 -->
89    <copy file="${build.dir.exp}/macronizer.xml.in" tofile="${gsdl3.src.home}/packages/tomcat/conf/Catalina/localhost/macronizer.xml" filtering="true" overwrite="true"/>
90   
91    <!-- mkdir Creates a directory. Also non-existent parent directories are created,
92     when necessary. Does nothing if the directory already exist. -->
93    <mkdir dir="${build.dir.exp}/logs"/>
94
95    <!-- For the MacroniserFileLogProcessor, which sets up a nightly cron to send useful logging info
96     from the daily macron.log.<date> files to a mysqldb, need to do some setup too -->
97    <copy file="${build.dir.exp}/mysql.properties.in" tofile="${basedir}/mysql.properties" filtering="true" overwrite="true"/>
98   
99    <mkdir dir="${logfileproc.dir}"/>
100   
101    <filter token="macronizer.scripts" value="${scripts.dir}"/>
102    <filter token="macronizer.logs" value="${build.dir.exp}/logs"/>
103    <copy file="${basedir}/src/scripts-and-sql/cron.in" tofile="${basedir}/src/scripts-and-sql/cron.txt" filtering="true" overwrite="true"/>
104
105    <filter token="logfileproc.exec_folder" value="${build.dir.exp}/WEB-INF/classes"/> <!-- where the util.MacroniserLogProcessor compiled code is -->
106    <filter token="logfileproc.dir" value="${logfileproc.dir}"/>
107    <filter token="jarlibs.folder" value="${build.dir.exp}/WEB-INF/lib"/>
108    <filter token="classes.folder" value="${build.dir.exp}/WEB-INF/classes"/>
109    <!-- Why can't we set the classpath to the mysql.properties file
110     to be anywhere other than the toplevel Macronizer folder/basedir?
111     Anything else causes class MySQLAccess of MacroniserLogFileProcessor
112     to fail with mysql.properties FileNotFoundException -->
113    <!--<filter token="mysqlprops.dir" value="${logfileproc.dir}"/>-->
114    <filter token="mysqlprops.dir" value="${basedir}"/>
115   
116    <copy file="${scripts.dir}/macronLogToDB.bash.in" tofile="${scripts.dir}/macronLogToDB.bash" filtering="true" overwrite="true"/>
117    <chmod file="${scripts.dir}/macronLogToDB.bash" perm="ugo+rx"/>
118   
119    <echo>*** Run the ant target 'ant logs-to-db-instructions' for instructions on setting up the MacroniserLogFileProcessor***</echo>
120  </target>
121
122  <target name="logs-to-db-instructions">
123    <echo>      ************************************************************
124      Instructions on setting up the MacroniserLogFileProcessor
125      ************************************************************
126     
127      1. Install mysql-5.7.23 as instructed at
128      http://wiki.greenstone.org/doku.php?id=en:user_advanced:greenstonesqlplugs#getting_and_running_mysql
129      (And when you run that mysql installation's db server, shut it down or run its mysql client,
130      do so as per the instructions there)
131
132      2. Use separate terminals to use the above instructions link to:
133        - Start the mysql server
134        - Connect to the mysql client
135     
136      3. After connecting to the client, in the mysql client terminal
137        - IMPORTANT: don't forget to immediately follow with 'set names utf8mb4;'
138        - CREATE AND INITIALISE the Macroniser database and its tables by running
139    the MySQL_Code.sql script by typing the following and hitting ENTER:
140            source ${scripts.dir}/MySQL_Code.sql
141     
142      3. Edit ${build.dir.exp}/WEB-INF/classes/mysql.properties to set the db password.
143        - If you set up a different username for the mysql db, set that in mysql.properties too.
144        - If nothing is set, MacronLogFileProcessor will assume the username is root.   
145
146      4. Set up the daily cronjob as follows:
147        - open a terminal and type 'export EDITOR=emacs' (or set to the text editor you prefer)
148    - type 'crontab -e' and the editor will open the cronfile
149    - append the contents from ${scripts.dir}/cron.txt to the cronfile
150    - save file and exit the editor
151
152      5. If you have email rights on the linux you're working from,
153         type your email into macronLogToDB.bash.in and macronLogToDB.bash
154         to get sent emails on errors.
155
156      6. All going well, you should get output files in the ${logfileproc.dir}
157     folder after the cron job runs each night.
158   
159      ************************************************************
160    </echo>
161  </target>
162 
163  <target name="war" depends="build">
164    <echo>Basedir: ${basedir}</echo>
165    <jar destfile="${dist.filename.exp}"> 
166      <fileset dir="${build.dir.exp}" />
167    </jar>
168  </target>
169 
170</project>
Note: See TracBrowser for help on using the browser.