Using ANT to pack an executable bank web application directory

I am working on an open source project that uses ANT, which can fulfill all kinds of useful goals. One of them generates an executable jar and directory webappin the same directory. I tried to find ways to compose this directory webappwith the bank, there is a lot of information, but not one of them is an example that is suitable for my problem.

Open Refine is a great tool for cleaning data, you can run it with a script that takes different launch arguments. It is built using a pier web server and a web application for the user interface. The architecture is here . It uses ANT to manage deployment, where there is a task that creates a Linux bundle:

<target name="linux" depends="jar, prepare_webapp">
    <mkdir dir="${linux.dir}"/>

    <copy todir="${linux.dir}/server/lib">
        <fileset dir="${server.lib.dir}">
            <include name="**/*.jar"/>
        </fileset>
    </copy>

    <copy file="${build.dir}/${fullname}-server.jar" tofile="${linux.dir}/server/lib/${fullname}-server.jar"/>

    <copy todir="${linux.dir}/webapp">
        <fileset dir="${built.webapp.dir}">
            <include name="**"/>
        </fileset>
    </copy>

    <mkdir dir="${linux.dir}/licenses"/>
    <fixcrlf srcDir="${basedir}/licenses" destDir="${linux.dir}/licenses" eol="lf"/>

    <fixcrlf srcDir="${basedir}" destDir="${linux.dir}" eol="lf">
        <include name="refine"/>
        <include name="refine.ini"/>
        <include name="README.txt"/>
        <include name="LICENSE.txt"/>
    </fixcrlf>

    <mkdir dir="${dist.dir}"/>
    <tar longfile="gnu" compression="gzip" destfile="${dist.dir}/openrefine-linux-${version}.tar.gz">
       <tarfileset dir="${linux.dir}/.." filemode="755">
           <include name="${release.name}/refine"/>
       </tarfileset>        
       <tarfileset dir="${linux.dir}/..">
           <include name="${release.name}/**"/>
           <exclude name="${release.name}/refine"/>
       </tarfileset>        
    </tar>
</target>

This task creates the web directory that is used in the previous task:

<target name="prepare_webapp" depends="jar_webapp, build">
    <mkdir dir="${built.webapp.dir}" />

    <copy todir="${built.webapp.dir}">
        <fileset dir="${webapp.dir}">
            <include name="**/*"/>
            <exclude name="WEB-INF/classes/**"/>
            <exclude name="WEB-INF/lib-src/**"/>
            <exclude name="WEB-INF/lib/icu4j*.jar"/>
        </fileset>
    </copy>

and Jar are prepared using another ANT target as follows:

<target name="jar_webapp" depends="prepare_jar, build_webapp">
    <jar destfile="${build.dir}/${fullname}.jar" basedir="${webapp.classes.dir}"/>
</target>

The result of the launch ant linuxis the executable jar and the webapp directory. Is it possible to pack the whole thing in the form of one thick jar?

+4
source share

All Articles