Permalink
Fetching contributors…
Cannot retrieve contributors at this time
419 lines (358 sloc) 16 KB
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Build file for Joshua. -->
<project name="Apache Joshua Machine Translation Toolkit" default="all" basedir="." xmlns:doxygen="antlib:org.doxygen.tools" xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- ~~~~~ Properties, Paths, etc ~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<property environment="env" />
<property name="JOSHUA" value="${basedir}" />
<property name="KENLM" value="${basedir}/ext/kenlm" />
<property name="src" value="${JOSHUA}/src" />
<property name="external" value="${JOSHUA}/ext" />
<property name="test" value="${JOSHUA}/test" />
<property name="build" value="${JOSHUA}/class" />
<property name="lib" value="${JOSHUA}/lib" />
<property name="thraxlib" value="${JOSHUA}/thrax/bin" />
<property name="doc" value="${JOSHUA}/doc" />
<path id="compile.all.classpath">
<fileset dir="${lib}">
<include name="jung-api-2.0.jar" />
<include name="jung-graph-impl-2.0.jar" />
<include name="jung-algorithms-2.0.jar" />
<include name="jung-visualization-2.0.jar" />
<include name="berkeleylm.jar" />
<include name="junit-4.10.jar" />
<include name="commons-cli-1.2.jar" />
<include name="collections-generic-4.01.jar" />
<include name="args4j-2.0.29.jar" />
<include name="gson-2.5.jar" />
<include name="guava-19.0.jar" />
</fileset>
<fileset dir="${thraxlib}">
<include name="thrax.jar" />
</fileset>
<fileset dir="${external}/berkeleylm/jar">
<include name="berkeleylm.jar" />
</fileset>
</path>
<!-- ~~~~~ Init build task ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- Create the build directory for compiled class files -->
<target name="init" depends="check-joshua-home, resolve, download-submodules, download-hadoop"
description="--> Check for environment variables, retrieve dependencies with ivy, download git dependencies, and get Hadoop">
</target>
<!-- Check for environment variables -->
<target name="check-joshua-home" description="--> Check for environment variables">
<echo message="JOSHUA = ${JOSHUA} basedir = ${basedir}" />
<!-- <if> -->
<!-- <not> -->
<!-- <equals arg1="${JOSHUA}" arg2="${basedir}" /> -->
<!-- </not> -->
<!-- <then> -->
<!-- <fail message="WARNING: $JOSHUA environment variable overrident to ${basedir}" /> -->
<!-- </then> -->
<!-- </if> -->
</target>
<target name="set-java-home" unless="env.JAVA_HOME" description="--> Prompt user to set JAVA_HOME environment variable">
<fail message="Please set the $JAVA_HOME environment variable." />
<!-- TODO: add suggestion to use /System/Library/Frameworks/JavaVM.framework/Home/ iff on OSX -->
</target>
<target name="kenlm" depends="check-joshua-home,download-submodules" description="--> Build KenLM">
<exec dir="${JOSHUA}/jni" executable="/bin/bash">
<env key="JOSHUA" path="${JOSHUA}" />
<arg line="build_kenlm.sh" />
</exec>
</target>
<target name="giza" depends="check-joshua-home" description="--> 'Make' the giza software in scripts/training/giza-pp/">
<exec executable="make">
<arg value="-j" />
<arg value="4" />
<arg value="-C" />
<arg value="${external}/giza-pp/" />
<arg value="all" />
<arg value="install" />
</exec>
<exec executable="make">
<arg value="-C" />
<arg value="${external}/symal" />
<arg value="all" />
</exec>
</target>
<target name="parallelize" depends="check-joshua-home" description="--> 'Make' the parallelize software in scripts/training/parallelize/">
<exec executable="make">
<arg value="-j" />
<arg value="4" />
<arg value="-C" />
<arg value="scripts/training/parallelize/" />
</exec>
</target>
<target name="download-submodules" depends="check-joshua-home" description="--> Download submodules">
<exec executable="git">
<arg value="submodule" />
<arg value="init" />
</exec>
<exec executable="git">
<arg value="submodule" />
<arg value="update" />
</exec>
</target>
<target name="thrax" depends="check-joshua-home" description="--> Build Thrax">
<subant buildpath="thrax">
</subant>
</target>
<target name="berkeleylm" depends="check-joshua-home" description="--> Build BerkeleyLM">
<subant target="jar" buildpath="${external}/berkeleylm">
</subant>
</target>
<!-- Download the hadoop tool tarball (not jar library), which gets used by
pipeline.pl and test/hadoop/ -->
<target name="download-hadoop" depends="check-joshua-home" description="--> Download the Hadoop software">
<get
src="http://archive.apache.org/dist/hadoop/core/hadoop-2.5.2/hadoop-2.5.2.tar.gz"
dest="${JOSHUA}/lib"
usetimestamp="true"
skipexisting="true" />
</target>
<!-- Determines whether the "devel" target needs to be built, which
is conditioned on the presence of the .git subdirectory -->
<condition property="devel-env">
<and>
<available file=".git"/>
</and>
</condition>
<!-- ~~~~~ Java build tasks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<target name="all" depends="setup, jar, giza, kenlm, parallelize" description="--> Default target Java build tasks">
</target>
<!-- The setup target does some downloading of files. These files
are packaged into releases, so this step only needs to be run if
we're in a development environment -->
<target name="setup" if="devel-env">
<antcall inheritAll="true" inheritRefs="true" target="init"/>
<antcall inheritAll="true" inheritRefs="true" target="thrax"/>
<antcall inheritAll="true" inheritRefs="true" target="berkeleylm"/>
</target>
<!-- Compile the Java code. -->
<target name="java" depends="check-joshua-home,version" description="--> Compile the Java code">
<mkdir dir="${build}" />
<javac srcdir="${src}" destdir="${build}" classpathref="compile.all.classpath" debug="on" encoding="utf8" sourcepath="" includeantruntime="false">
<!-- We nullify the sourcepath in order to disable Ant's usual resolution mechanism. This makes it an error for our basic code to call into code that has external dependencies, rather than auto-including those files and then having a classpath error. -->
<include name="**/*.java" />
<!-- This should be on, so people see it. But it can be quite verbose...
<compilerarg value="-deprecation"/>
-->
</javac>
</target>
<!-- Create a JAR file -->
<target name="jar" depends="java,check-joshua-home" description="--> Create a JAR file of compiles classes">
<jar destfile="${lib}/joshua.jar" index="true">
<fileset dir="${build}">
<include name="**/*.class" />
</fileset>
<manifest>
<attribute name="Main-Class" value="joshua.decoder.JoshuaDecoder" />
</manifest>
</jar>
</target>
<target name="tree_visualizer" depends="java,check-joshua-home" description="--> Runs the Tree Visualizer software in examples/tree_visualizer/tree_visualizer.jar">
<jar destfile="examples/tree_visualizer/tree_visualizer.jar" index="true">
<zipgroupfileset dir="lib" includes="*.jar" />
<fileset dir="${build}">
<include name="**/*.class" />
</fileset>
<indexjars>
<fileset dir="${lib}" />
</indexjars>
<manifest>
<attribute name="Class-Path" value="tree_visualizer.jar" />
<attribute name="Main-Class" value="joshua.ui.tree_visualizer.browser.Browser" />
</manifest>
</jar>
</target>
<!-- Create a versioned release -->
<target name="release" depends="devel-clean, init, thrax, version" description="--> Create a versioned release">
<exec executable="./scripts/support/make-release.sh" />
</target>
<!-- Set git version -->
<target name="version" description="Build VERSION file">
<exec executable="./scripts/support/write-version.sh">
</exec>
</target>
<!-- Create a JAR file of the source code -->
<target name="source-jar" description="--> Create a JAR file of the source code">
<jar destfile="${lib}/joshua-src.jar">
<fileset dir="${build}">
<include name="**/*.java" />
</fileset>
</jar>
</target>
<!-- ~~~~~ Cleaning tasks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- Delete the compiled files -->
<target name="clean" depends="clean-thrax,clean-java,clean-kenlm,clean-giza" description="--> Clean (remove) all build directories">
<delete file="${lib}/libken.so" />
<delete file="tree_visualizer/tree_visualizer.jar" />
<delete dir="doc/html" />
<delete dir="doc/latex" />
</target>
<!-- Clean up GIZA and symal code -->
<target name="clean-giza" description="--> Clean GIZA and symal">
<exec executable="make">
<arg value="-C" />
<arg value="${external}/giza-pp" />
<arg value="clean" />
</exec>
<exec executable="make">
<arg value="-C" />
<arg value="${external}/symal" />
<arg value="clean" />
</exec>
</target>
<!-- Delete just the java files -->
<target name="clean-java" description="--> Delete just the java files">
<delete verbose="true" quiet="true">
<fileset dir="${build}">
<include name="**/*.class" />
</fileset>
</delete>
</target>
<target name="clean-thrax" description="--> Delete just the thrax files">
<delete verbose="true" quiet="true">
<fileset dir="${thraxlib}">
<include name="**/*.class"/>
</fileset>
</delete>
</target>
<target name="clean-kenlm" description="--> Cleaning up KenLM">
<delete dir="${KENLM}/build" />
</target>
<!-- Delete *all* generated files,
including files and directories not tracked by git -->
<target name="devel-clean" description="--> Delete *all* generated files, including files and directories not tracked by git">
<input
message="WARNING: all untracked, ignored files will be removed. Continue? (y/n) "
validargs="y,n"
addproperty="do.delete"
/>
<condition property="do.abort">
<equals arg1="n" arg2="${do.delete}"/>
</condition>
<fail if="do.abort">Build aborted by user.</fail>
<!-- Delete untracked, ignored files and directories. -->
<exec executable="git">
<arg value="clean" />
<arg value="-fdX" />
</exec>
</target>
<!-- ~~~~~ Doxygen ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<taskdef uri="antlib:org.doxygen.tools" resource="org/doxygen/tools/antlib.xml" classpath="${lib}/ant-doxygen-1.6.1.jar" />
<!-- Compile the Javadocs and Markdown documentation into web pages -->
<target name="documentation" depends="check-joshua-home" description="--> Compile the Javadocs and Markdown documentation into web pages">
<doxygen:doxygen configFilename="${doc}/Doxyfile" />
</target>
<!-- ~~~~~ Tests ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<target name="test" depends="all" description="--> Run tests">
<exec dir="test" executable="/bin/bash" failonerror="false">
<env key="JOSHUA" path="${JOSHUA}" />
<arg line="run-all-tests.sh" />
</exec>
</target>
<!-- ~~~~~ Ivy ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<property name="ivy.install.version" value="2.2.0" />
<condition property="ivy.home" value="${env.IVY_HOME}">
<isset property="env.IVY_HOME" />
</condition>
<property name="ivy.home" value="${JOSHUA}" />
<property name="ivy.jar.dir" value="${ivy.home}/lib" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
<target name="download-ivy" unless="offline">
<!-- Test for Ant Version.-->
<fail message="Ivy requires Ant version 1.8.0 or greater. Please upgrade to the latest version.">
<condition>
<not>
<antversion atleast="1.8.0"/>
</not>
</condition>
</fail>
<property name="ivy.default.ivy.user.dir" value="${JOSHUA}/lib" />
<mkdir dir="${ivy.jar.dir}" />
<!-- download Ivy from web site so that it can be used even without any special installation -->
<get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" dest="${ivy.jar.file}" usetimestamp="true" skipexisting="true" />
</target>
<target name="init-ivy" depends="download-ivy" description="--> Try to load and initialize Ivy here from Ivy Home">
<!-- try to load ivy here from ivy home, in case the user has not already dropped
it into ant's lib dir (note that the latter copy will always take precedence).
We will not fail as long as local lib dir exists (it may be empty) and
ivy is in at least one of ant's lib dir or the local lib dir. -->
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar" />
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path" />
</target>
<!-- =================================
target: resolve
================================= -->
<target name="resolve" description="--> retrieve dependencies with ivy" depends="init-ivy">
<property name="ivy.default.ivy.user.dir" value="${JOSHUA}/lib" />
<ivy:configure file="${JOSHUA}/lib/ivysettings.xml" />
<ivy:resolve file="${JOSHUA}/lib/ivy.xml" />
<ivy:retrieve type="jar,bundle" />
</target>
<!-- target: clean-eclipse ============================================ -->
<target name="clean-eclipse" depends="clean"
description="--> cleans the eclipse project"/>
<!-- ================================================================== -->
<!-- Eclipse targets -->
<!-- ================================================================== -->
<!-- classpath for generating eclipse project -->
<path id="eclipse.classpath">
<fileset dir="${lib}">
<include name="**.jar" />
<exclude name="ant-eclipse-1.0-jvm1.2.jar" />
</fileset>
<fileset dir="${lib}">
<include name="**/*.jar" />
</fileset>
</path>
<!-- target: ant-eclipse-download =================================== -->
<target name="ant-eclipse-download" description="--> Downloads the ant-eclipse binary.">
<get src="http://downloads.sourceforge.net/project/ant-eclipse/ant-eclipse/1.0/ant-eclipse-1.0.bin.tar.bz2"
dest="${src}/ant-eclipse-1.0.bin.tar.bz2" usetimestamp="false" />
<untar src="${src}/ant-eclipse-1.0.bin.tar.bz2"
dest="${src}" compression="bzip2">
<patternset>
<include name="lib/ant-eclipse-1.0-jvm1.2.jar"/>
</patternset>
</untar>
<delete file="${src}/ant-eclipse-1.0.bin.tar.bz2" />
</target>
<!-- target: eclipse ================================================ -->
<target name="eclipse"
depends="init,jar,ant-eclipse-download"
description="--> Create eclipse project files">
<pathconvert property="eclipse.project">
<path path="${basedir}"/>
<regexpmapper from="^.*/([^/]+)$$" to="\1" handledirsep="yes"/>
</pathconvert>
<taskdef name="eclipse"
classname="prantl.ant.eclipse.EclipseTask"
classpath="${src}/lib/ant-eclipse-1.0-jvm1.2.jar" />
<eclipse updatealways="true">
<project name="${eclipse.project}" />
<classpath>
<library pathref="eclipse.classpath" exported="false" />
<source path="${basedir}/src" />
<output path="${build}" />
</classpath>
</eclipse>
</target>
</project>