1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
<?xml version="1.0"?>
<project name="JFlex" default="help">
<property environment="env" />
<property name="version" value="1.7.0" />
<property name="bootstrap.version" value="1.6.1" />
<property name="junit.version" value="4.11" />
<property name="cup.version" value="11b" />
<property name="jflex.jdk.version" value="1.7"/>
<property name="ant.build.javac.source" value="${jflex.jdk.version}"/>
<property name="ant.build.javac.target" value="${jflex.jdk.version}"/>
<!-- use any of these files to override properties -->
<property file="build.properties" />
<property file="${user.home}/.jflex.properties" />
<!-- location of development tools necessary for the build -->
<property name="lib.dir" value="lib"/>
<property name="m2repo" value="${env.HOME}/.m2/repository" />
<!-- override these if you want to use your own versions -->
<property name="bootstrap.jflex.jar" value="/usr/share/ant/lib/jflex.jar" />
<property name="cup.jar" value="/usr/share/java/cup.jar" />
<property name="junit.jar" value="${lib.dir}/junit-${junit.version}.jar" />
<!-- where to get tool jars from -->
<property name="maven.central.url" value="https://repo.maven.apache.org/maven2" />
<property name="bootstrap.jflex.jar.path" value="de/jflex/jflex/${bootstrap.version}/jflex-${bootstrap.version}.jar" />
<property name="junit.jar.path" value="junit/junit/${junit.version}/junit-${junit.version}.jar" />
<!-- where build output goes, including the jflex jar -->
<property name="build.dir" value="build"/>
<property name="generated.sources.dir" value="${build.dir}/generated-sources"/>
<property name="compile.output.dir" value="${build.dir}/classes"/>
<property name="test.compile.output.dir" value="${build.dir}/test-classes"/>
<property name="tests.dir" value="${build.dir}/tests"/>
<!-- where the output jar goes -->
<property name="output.jar.name" value="${build.dir}/jflex-${version}.jar" />
<fail message="Minimum supported Java version is ${jflex.jdk.version}. Your Java version is ${ant.java.version}.">
<condition>
<not><hasmethod classname="java.lang.Throwable" method="getSuppressed"/></not>
</condition>
</fail>
<target name="help" description="show help message">
<echo message="Ant build file for JFlex. Useful targets:"/>
<echo message=""/>
<echo message="gettools: download development tools for the build"/>
<echo message="clean: remove all generated and compiled files"/>
<echo message="compile: generates sources and compiles non-test classes"/>
<echo message="jar: make ${output.jar.name}"/>
<echo message="build: complete build from scratch (clean jar)"/>
<echo message="test: run the unit tests"/>
<echo message=""/>
<echo message="Use the gettool target or override the *.jar properties"/>
<echo message="before you do the first build."/>
</target>
<target name="gettools" description="download development tools">
<!-- Download libs from central Maven repo otherwise. -->
<get src="${maven.central.url}/${bootstrap.jflex.jar.path}" dest="${bootstrap.jflex.jar}" skipexisting="true"/>
<get src="${maven.central.url}/${junit.jar.path}" dest="${junit.jar}" skipexisting="true"/>
<get src="https://raw.githubusercontent.com/jflex-de/jflex/05632859c94c348dee7d243e4a36bd656c132e96/cup/cup/java-cup-11b.jar" dest="lib/" skipexisting="true"/>
</target>
<target name="build" depends="clean,jar"
description="complete build from scratch (clean jar)"/>
<target name="clean" description="remove all generated and compiled files">
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${build.dir}" includes="**/*"/>
</delete>
<delete file="${lib.dir}/jflex-${version}.jar" />
</target>
<target name="jar" depends="compile,-copy-resources"
description="make ${output.jar.name}">
<jar basedir="${compile.output.dir}" jarfile="${output.jar.name}">
<manifest>
<attribute name="Main-Class" value="jflex.Main"/>
</manifest>
</jar>
<copy file="${output.jar.name}" todir="${lib.dir}" />
</target>
<target name="compile" depends="-generate-scanner,-generate-parser"
description="generate sources and compile all non-test classes">
<mkdir dir="${compile.output.dir}" />
<javac destdir="${compile.output.dir}"
source="1.7"
target="1.7"
debug="on"
encoding="ISO-8859-1"
includeantruntime="true"
classpath="${cup.jar}">
<src path="src/main/java"/>
<src path="${generated.sources.dir}"/>
</javac>
</target>
<target name="test" depends="compile,-copy-resources,-compile-test">
<mkdir dir="${tests.dir}"/>
<junit dir="." printsummary="true" errorproperty="junit.failed">
<classpath>
<file file="${cup.jar}"/>
<file file="${junit.jar}"/>
<pathelement location="${compile.output.dir}"/>
<pathelement location="${test.compile.output.dir}"/>
</classpath>
<assertions>
<enable/>
</assertions>
<batchtest fork="yes" todir="${tests.dir}">
<formatter type="plain" usefile="false" /> <!-- to screen -->
<formatter type="plain"/>
<fileset dir="src/test/java">
<include name="**/*Test*.java"/>
</fileset>
</batchtest>
</junit>
<fail if="junit.failed"/>
</target>
<target name="-copy-resources">
<copy todir="${compile.output.dir}">
<fileset dir="src/main/resources"/>
</copy>
</target>
<target name="-generate-scanner">
<taskdef classname="jflex.anttask.JFlexTask"
name="jflex" classpath="${bootstrap.jflex.jar}"/>
<mkdir dir="${generated.sources.dir}"/>
<jflex file="src/main/jflex/LexScan.flex"
destdir="${generated.sources.dir}"
skeleton="src/main/jflex/skeleton.nested"
nobak="on"/>
</target>
<target name="-generate-parser">
<taskdef classname="java_cup.anttask.CUPTask"
name="cup" classpath="${cup.jar}"/>
<mkdir dir="${generated.sources.dir}"/>
<cup srcfile="src/main/cup/LexParse.cup"
destdir="${generated.sources.dir}"
interface="true"
locations="false"
parser="LexParse"/>
</target>
<target name="-compile-test" depends="compile">
<mkdir dir="${test.compile.output.dir}"/>
<javac srcdir="src/test/java"
destdir="${test.compile.output.dir}"
classpath="${compile.output.dir}:${junit.jar}"
includeantruntime="true"/>
</target>
</project>
|