Skip to content

Mis en ligne par admin - 18 novembre 2011 - Astuces Diverses

Script Ant typique d’une application JSF simple

Juste un petit exemple très simple de script ant pour une application JSF (note: directory names standard Eclipse)


<project name="appli.war" basedir="." default="war">
  <!-- Local system paths -->
  <property name="webroot.dir" value="${basedir}/WebContent" />
  <property name="src.dir" value="${basedir}/JavaSource" />
  <property name="webinf.dir" value="${webroot.dir}/WEB-INF" />

  <!-- Project settings -->
  <property name="project.distname" value="appli" />
  <property name="build.dir" value="build/" />

  <!-- classpath for compiling  -->
  <path id="compile.classpath">
    <fileset dir="lib/" includes="**/*.jar" />
    <fileset dir="${webinf.dir}/lib" includes="**/*.jar" />
    <pathelement path="${webinf.dir}/classes" />
  </path>

  <!-- Check timestamp on files -->
  <target name="prepare" depends="clean">
    <tstamp />
  </target>

  <!-- Normal build of application -->
  <target name="compile" depends="prepare">
    <javac srcdir="${src.dir}" destdir="${webinf.dir}/classes" debug="true">
      <classpath refid="compile.classpath" />
    </javac>
  </target>

  <!-- Remove classes directory for clean build -->
  <target name="clean" description="Prepare for clean build">
    <delete dir="${webinf.dir}/classes" />
    <mkdir dir="${webinf.dir}/classes" />
  </target>

  <!-- Build entire project -->
  <target name="build" depends="prepare,compile" />
  <target name="rebuild" depends="clean,prepare,compile" />

  <!-- Create binary distribution -->
  <target name="war" depends="build">
    <delete file="${build.dir}/${project.distname}.war" />
    <mkdir dir="${build.dir}" />
    <war basedir="${webroot.dir}" warfile="${build.dir}/${project.distname}.war" webxml="${webinf.dir}/web.xml">
      <exclude name="WEB-INF/${build.dir}/**" />
      <exclude name="WEB-INF/src/**" />
      <exclude name="WEB-INF/web.xml" />
    </war>
  </target>

</project>

Articles similaires

Les articles suivants abordent des thèmes communs.

Commentaires

Partagez vos remarques.

Il n'y a pas de commentaires pour cet article.

Add a Comment

Fill in the form and submit.