Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > 03a94d8f913fd31140f11f39714fa79d > files > 10

ant-antlr3-20110110-8.mga3.noarch.rpm

<project name="d2u" default="dist" basedir=".">
    <description>
        More than a DOS to UNIX conversion of line ends.
    </description>

    <property name="project.name" value="d2u" />

    <!-- program version -->
    <property name="version" value="1.02" />

    <!-- set global properties for this build -->
    <property name="build" location="."/>

    <!-- directory layout for this build:

         .
         +- src
         +- grammar
         +- classes
         +- dist
              +- javadoc

         the following properties reflect this hierarchy
    -->

    <!-- the src directory in this example -->
    <property name="src" location="src"/>

    <!-- name of the package -->
    <property name="package" value="org/myorg/${project.name}"/>

    <!-- where to write/find token files -->
    <property name="token.lib" location="${src}/${package}" />

    <!-- where to find the grammar files
         in this example the grammar file is placed in a separat
         directory. Some people might prefer to locate it in the
         source directory. To do so, just change

         location="grammar" into
         location="${src}"

         if you like.
    -->
    <property name="grammar" location="grammar"/>

    <!-- where to write compiled sources -->
    <property name="classes" location="classes"/>

    <!-- distribution directory -->
    <property name="dist" location="dist" />

    <!-- where to write java doc files -->
    <property name="doc" location="${dist}/javadoc"/>

    <!-- A convenience macro which invokes antlr
         Be aware that JVM arguments can be specified via the jvmarg directive
    -->
    <macrodef name="antlr3">
        <attribute name="grammar.name"/>
        <attribute name="package" default="${package}"/>
        <attribute name="verbose" default="True"/>
        <attribute name="debug" default="False"/>
        <attribute name="multithreaded" default="True"/>
        <sequential>
            <echo message="antlr ${grammar}/@{grammar.name}" />
            <antlr:ant-antlr3 xmlns:antlr="antlib:org/apache/tools/ant/antlr"
                              target="${grammar}/@{grammar.name}"
                              outputdirectory="${src}/@{package}"
                              libdirectory="${src}/@{package}"
                              multithreaded="@{multithreaded}"
                              verbose="@{verbose}"
                              debug="@{debug}">
                <jvmarg value="-Xmx512M"/>
            </antlr:ant-antlr3>
        </sequential>
    </macrodef>

    <target name="init" depends="antlr_classpath">
        <!-- Create the time stamp -->
        <tstamp />
        <!-- Create the build directory structure used by compile -->
        <mkdir dir="${grammar}" />
        <mkdir dir="${src}/${package}" />
        <mkdir dir="${classes}/${package}" />
        <mkdir dir="${classes}/META-INF" />
        <mkdir dir="${dist}" />
        <mkdir dir="${doc}/${package}" />
    </target>

    <!-- Check if Antlr is in classpath -->
    <target name="antlr_classpath">
        <whichresource property="antlr.in.classpath" class="org.antlr.Tool" />
        <fail message="Antlr library not found via CLASSPATH ${java.class.path}">
            <condition>
                <not>
                    <isset property="antlr.in.classpath"/>
                </not>
            </condition>
        </fail>
        <echo>Antlr found via CLASSPATH</echo>
    </target>

    <!-- Antlr is called here -->
    <!-- The antlr3 macro is doing the work -->
    <target name="antlr" depends="init">
        <antlr3 grammar.name="d2u.g"/>
    </target>

    <target name="compile" depends="init, antlr" description="compile">
        <!-- Compile the java code from ${src} into ${classes} -->
        <javac debug="true" srcdir="${src}" destdir="${classes}"
               listfiles="Yes" deprecation="Yes" includeantruntime="false">
            <compilerarg value="-Xlint:unchecked"/>
            <classpath>
                <pathelement path="${java.class.path}"/>
            </classpath>
        </javac>
    </target>

    <target name="manifest">
        <manifest file="${classes}/META-INF/MANIFEST.MF">
            <attribute name="Main-Class" value="org.myorg.${project.name}.Main" />
        </manifest>
    </target>

    <target name="dist" depends="compile, manifest"
            description="generate for distribution">
        <jar jarfile="${dist}/${project.name}.jar" basedir="${classes}"
             manifest="${classes}/META-INF/MANIFEST.MF"/>
    </target>

    <target name="doc" depends="init" description="generate documentation">
        <javadoc destdir="${doc}"
                 author="true"
                 version="true"
                 use="true"
                 windowtitle="${project.name}"
                 sourcepath="${src}"
                 Protected="All" Private="All"
                 Public="All"
                 linksource="yes"
                 breakiterator="Yes">
        </javadoc>
    </target>

    <target name="run" depends="dist">
        <echo message="Convert line ends from dos to mac format"/>
        <echo message="Input is read from d2u.stg. Output is written to tmp.ant"/>
        <java classname="org.myorg.${project.name}.Main"
              input="d2u.stg"
              output="tmp.ant"
              fork="true"
              failonerror="true"
              maxmemory="128m">
            <arg value="mac"/>
            <classpath>
                <pathelement path="${java.class.path}"/>
                <pathelement path="${dist}/${project.name}.jar"/>
            </classpath>
        </java>
    </target>

    <target name="clean" description="clean up">
        <delete>
            <fileset dir="${src}" includes="**/*.class,**/*.tokens,**/*.g*" />
            <fileset dir="${classes}" />
            <fileset dir="${dist}" includes="**/*.jar" />
            <fileset dir="${doc}" />
        </delete>
    </target>

    <target name="all" depends="init, clean, compile, dist, doc, run" description="do all"/>

</project>