Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Mike Wilson www.whisperingwind.co.uk

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

'ant' build file for HelloWorldServlet and JettyLauncher

A pretty straightforward 'ant' build file. You will need to edit the jetty.home property to indicate where you installed Jetty.

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="compile" name="hello-servlet">
  <property name="build.dir"	location="classes" />
  <property name="src.dir"	location="src/main/java" />
  <property name="jetty.home"	location="/home/mrw/projects/jetty-6.1.3" />
  <property name="jetty.lib"	location="${jetty.home}/lib" />

  <path id="jetty.lib.path">
    <pathelement path="${jetty.lib}/jetty-6.1.3.jar" />
    <pathelement path="${jetty.lib}/jetty-util-6.1.3.jar" />
    <pathelement path="${jetty.lib}/servlet-api-2.5-6.1.3.jar" />
  </path>

  <target name="compile" description="Compile the project">
    <mkdir dir="${build.dir}" />
    <javac debug="true" destdir="${build.dir}" srcdir="${src.dir}"
	classpathref="jetty.lib.path">
      <compilerarg value="-Xlint:unchecked" />
      <compilerarg value="-Xlint:deprecation" />
    </javac>
  </target>

  <target name="all"  depends="clean,compile"
      description="Recompile from scratch"/>

  <target name="server" depends="compile" description="Launch the server">
    <java classname="com.babblemind.JettyLauncher" fork="true"
	classpathref="jetty.lib.path">
      <classpath>
	<pathelement path="${build.dir}" />
      </classpath>
    </java>
  </target>

  <target name="clean" description="Delete all files created by compile">
    <delete dir="${build.dir}" />
    <delete dir="docs/api" />
  </target>
</project>

Basic ant script with vim & jikes

Apache ant build XML. This will use jikes in place of javac. Any compiler error output is formatted so that vim can parse it.

ant is a modern alternative to make. The build script is an XML file. It works particularly well with java. Download it for free from the Apache ant site. Most people find ant a lot nicer to live with than make.

<?xml version="1.0"?>

<project name="Hello" default="compile" basedir=".">
  <property name="name" value="Hello"/>
  <property name="version" value="1.0"/>

  <!-- Project directories.
  -->

  <property name="build" value="build"/>
  <property name="dist" value="dist"/>
  <property name="src" value="src"/>

  <!-- Compiler directives.
  -->

  <property name="optimize" value="off"/>
  <property name="deprecation" value="on"/>
  <property name="debug" value="on"/>

  <property name="build.compiler" value="jikes"/>
  <property name="build.compiler.emacs" value="true"/>

  <target name="init">
    <tstamp/>
    <mkdir dir="${build}"/>
  </target>

  <!-- Compile all the .java files from the source directory into
       the build directory.
  -->

  <target name="compile" depends="init">
    <javac srcdir="${src}" destdir="${build}" includes="**/*.java"
      debug="${debug}" deprecation="${deprecation}" optimize="${optimize}">
    </javac>
  </target>

  <target name="clean" depends="init">
    <delete dir="${build}"/>
    <delete dir="${dist}"/>
  </target>

  <target name="test" depends="compile">
    <java classname="HelloWorld" fork="yes">
      <classpath>
        <pathelement location="${build}"/>
      </classpath>
    </java>
  </target>
</project>
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS