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

Revision 32754, 7.5 KB (checked in by ak19, 17 months ago)

Improving instructions

  • 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="${build.dir.exp}/WEB-INF/classes/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   
110    <copy file="${scripts.dir}/macronLogToDB.bash.in" tofile="${scripts.dir}/macronLogToDB.bash" filtering="true" overwrite="true"/>
111    <chmod file="${scripts.dir}/macronLogToDB.bash" perm="ugo+rx"/>
112   
113    <echo>*** Run the ant target 'ant logs-to-db-instructions' for instructions on setting up the MacroniserLogFileProcessor***</echo>
114  </target>
115
116  <target name="logs-to-db-instructions">
117    <echo>      ************************************************************
118      Instructions on setting up the MacroniserLogFileProcessor
119      ************************************************************
120     
121      1. Install mysql-5.7.23 as instructed at
122      http://wiki.greenstone.org/doku.php?id=en:user_advanced:greenstonesqlplugs#getting_and_running_mysql
123      (And when you run that mysql installation's db server, shut it down or run its mysql client,
124      do so as per the instructions there)
125
126      2. Use separate terminals to use the above instructions link to:
127        - Start the mysql server
128        - Connect to the mysql client
129     
130      3. After connecting to the client, in the mysql client terminal
131        - IMPORTANT: don't forget to immediately follow with 'set names utf8mb4;'
132        - CREATE AND INITIALISE the Macroniser database and its tables by running
133    the MySQL_Code.sql script by typing the following and hitting ENTER:
134            source ${scripts.dir}/MySQL_Code.sql
135     
136      3. Edit ${build.dir.exp}/WEB-INF/classes/mysql.properties to set the db password.
137        - If you set up a different username for the mysql db, set that in mysql.properties too.
138        - If nothing is set, MacronLogFileProcessor will assume the username is root.   
139
140      4. Set up the daily cronjob as follows:
141        - open a terminal and type 'export EDITOR=emacs' (or set to the text editor you prefer)
142    - type 'crontab -e' and the editor will open the cronfile
143    - append the contents from ${scripts.dir}/cron.txt to the cronfile
144    - save file and exit the editor
145
146      5. If you have email rights on the linux you're working from,
147         type your email into macronLogToDB.bash.in and macronLogToDB.bash
148         to get sent emails on errors.
149
150      6. All going well, you should get output files in the ${logfileproc.dir}
151     folder after the cron job runs each night.
152   
153      ************************************************************
154    </echo>
155  </target>
156 
157  <target name="war" depends="build">
158    <echo>Basedir: ${basedir}</echo>
159    <jar destfile="${dist.filename.exp}"> 
160      <fileset dir="${build.dir.exp}" />
161    </jar>
162  </target>
163 
164</project>
Note: See TracBrowser for help on using the browser.