[30063] | 1 | <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
---|
| 2 | <project basedir="." default="war" name="TheMacronizer">
|
---|
| 3 |
|
---|
| 4 | <property environment="env"/>
|
---|
[32622] | 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 |
|
---|
[30063] | 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" />
|
---|
[31962] | 20 | <property name="webinf.dir" location="web/WEB-INF" />
|
---|
[32753] | 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"/>
|
---|
[30063] | 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">
|
---|
[32621] | 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 |
|
---|
[30063] | 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 |
|
---|
[31962] | 64 | <target name="build" depends="init">
|
---|
[30063] | 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"/>
|
---|
[31962] | 73 | <pathelement path="src/java"/>
|
---|
| 74 | <pathelement path="webinf.dir"/>
|
---|
[30063] | 75 | </classpath>
|
---|
| 76 | </javac>
|
---|
[31962] | 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.-->
|
---|
[32622] | 82 |
|
---|
| 83 | <filter token="macronizer.home" value="${basedir}"/>
|
---|
[32623] | 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"/>
|
---|
[32750] | 87 |
|
---|
[32623] | 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 -->
|
---|
[32622] | 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 |
|
---|
[31962] | 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"/>
|
---|
[32751] | 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 -->
|
---|
[32755] | 97 | <copy file="${build.dir.exp}/mysql.properties.in" tofile="${basedir}/mysql.properties" filtering="true" overwrite="true"/>
|
---|
[32753] | 98 |
|
---|
| 99 | <mkdir dir="${logfileproc.dir}"/>
|
---|
| 100 |
|
---|
[32751] | 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"/>
|
---|
[32753] | 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"/>
|
---|
[32755] | 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}"/>
|
---|
[32751] | 115 |
|
---|
[32753] | 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 |
|
---|
[32754] | 119 | <echo>*** Run the ant target 'ant logs-to-db-instructions' for instructions on setting up the MacroniserLogFileProcessor***</echo>
|
---|
[30063] | 120 | </target>
|
---|
| 121 |
|
---|
[32751] | 122 | <target name="logs-to-db-instructions">
|
---|
[32752] | 123 | <echo> ************************************************************
|
---|
[32751] | 124 | Instructions on setting up the MacroniserLogFileProcessor
|
---|
| 125 | ************************************************************
|
---|
| 126 |
|
---|
[32752] | 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)
|
---|
[32751] | 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;'
|
---|
[32752] | 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:
|
---|
[32751] | 140 | source ${scripts.dir}/MySQL_Code.sql
|
---|
| 141 |
|
---|
[32757] | 142 | 3. Edit ${basedir}/mysql.properties to set the db password.
|
---|
[32751] | 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
|
---|
[32753] | 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.
|
---|
[30063] | 158 |
|
---|
[32751] | 159 | ************************************************************
|
---|
| 160 | </echo>
|
---|
| 161 | </target>
|
---|
| 162 |
|
---|
[31962] | 163 | <target name="war" depends="build">
|
---|
[32622] | 164 | <echo>Basedir: ${basedir}</echo>
|
---|
[30063] | 165 | <jar destfile="${dist.filename.exp}">
|
---|
| 166 | <fileset dir="${build.dir.exp}" />
|
---|
| 167 | </jar>
|
---|
| 168 | </target>
|
---|
| 169 |
|
---|
| 170 | </project>
|
---|