Try OpenEdge Now
skip to main content
Configuration
Configuring third-party Web applications : Sample Web application in OpenEdge Management : Compiling sample Web application using Ant
 

Compiling sample Web application using Ant

You can compile the sample Web application using an example build.xml file.
To compile the sample Web application:
1. Extract the samplewebapp.src.zip file available in the $OEM/samples directory.
2. Create a build.xml file in the top-level directory using the example file provided below.
3. Start Proenv.
4. Change the directory to the directory that contains the sample Web application code.
5. Run proant.
The following is the example build.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project name="samplewebapp" default="build" basedir=".">
<!-- make environment variables available as properties -->
<property environment="env"/>
<!-- Compiler settings. -->
<property name="javacFailOnError" value="true"/>
<property name="javacDebugInfo" value="on"/>
<property name="javacVerbose" value="false"/>
<property name="logExtension" value=".log"/>
<property name="compilerArg" value=""/>
<property name="ant.build.javac.source" value="1.8"/>
<property name="ant.build.javac.target" value="1.8"/>

<!-- directory names for convenience -->
<property name="DLC" value="${env.DLC}" />
<property name="OEM" value="${env.OEM}" />
<property name="build.src.dir" value="${basedir}/src" />
<property name="build.out.dir" value="${basedir}/build" />
<property name="build.class.dir" location="${build.out.dir}/classes" />
<property name="samplewebapp.webcontent.dir" value="${basedir}/WebContent"/>
<property name="samplewebapp.jar" location="${build.out.dir}/samplewebapp.jar" />
<property name="samplewebapp.war" location="${build.out.dir}/samplewebapp.war"/>
<property name="samplewebapp.src.zip" location="${build.out.dir}/samplewebapp.src.zip"/>

<!-- classpath for building samplewebapp.jar -->
<path id="compile.classpath">

<!-- include progress.jar -->
<pathelement path="${DLC}/java/progress.jar" />
<pathelement path="${DLC}/java/messages.jar" />

<!-- include fathom.jar -->
<pathelement path="${OEM}/jars/fathom.jar"/>

<!-- java servlet specific stuff needed for most web pages -->
<pathelement path="${OEM}/jars/servlet-api-*.jar" />
<!-- jackson JSON library for REST API-->
<pathelement path="${OEM}/jars/jackson-core-*.jar" />
<pathelement path="${OEM}/jars/jackson-annotations-*.jar" />
<pathelement path="${OEM}/jars/jackson-databind-*.jar" />

<!-- shiro for security -->
<pathelement path="${OEM}/jars/shiro-core-*.jar"/>
<pathelement path="${OEM}/jars/shiro-web-*.jar" />
</path>
<target name="build" depends="clean,compile,jar,war,zipsrc"
description="Compile all classes and build jars for samplewebapp">
</target>
<target name="compile" depends="generic.java.compile"
description="Compile all classes for samplewebapp.jar." >
</target>

<target name="generic.java.compile"
description="Compile all classes in ${build.class.dir} as javasrc ${ant.build.javac.source}">
<mkdir dir="${build.out.dir}" />
<mkdir dir="${build.class.dir}" />
<javac
srcdir="${build.src.dir}"
destdir="${build.class.dir}"
includes="**/*.java"
failonerror="${javacFailOnError}"
verbose="${javacVerbose}"
debug="${javacDebugInfo}"
includeAntRuntime="no" >
<!-- <compilerarg value="-Xlint"/> -->
<classpath refid="compile.classpath" />
</javac>
</target>
<tstamp>
<format property="TODAY" pattern="yyyy-MM-dd HH:mm:ss" />
</tstamp>
<target name="jar" description="create samplewebapp.jar">
<tstamp/>
<jar destfile="${samplewebapp.jar}"
manifest="${basedir}/META-INF/MANIFEST.MF" >
<manifest>
<attribute name="url" value="http://www.progress.com" />
<attribute name="Vendor" value="Progress Software" />
<attribute name="Bundle-Name" value="OpenEdge Management Sample Web Application" />
<attribute name="Built-Date" value="${TODAY}"/>
</manifest>
<fileset dir="${DLC}">
<include name="version" />
</fileset>
<fileset dir="${build.class.dir}">
<include name="com/**/*.class" />
</fileset>
<!-- make sure to include any config files -->
<fileset dir="${build.src.dir}" >
<include name="com/**/*.xsl" />
<include name="com/**/*.xml" />
<include name="com/**/*.txt" />
<include name="com/**/*.properties" />
</fileset>
</jar>
</target>

<target name="clean" description="clean output for sample web application">
<delete dir="${build.class.dir}" />
<delete file="${samplewebapp.jar}" />
<delete file="${samplewebapp.war}" />
<delete file="${samplewebapp.src.zip}" />
</target>
<target name="war" description="build samplewebapp .war file">
<war
destFile="${samplewebapp.war}"
webxml="${samplewebapp.webcontent.dir}/WEB-INF/web.xml">

<fileset dir="${samplewebapp.webcontent.dir}">
</fileset>
<lib dir="${build.out.dir}">
<include name="samplewebapp.jar"/>
</lib>
</war>
</target>
<target name="zipsrc" description="create source samplewebapp.zip">
<zip
destfile="${samplewebapp.src.zip}"
basedir="${basedir}"
excludes="build.xml">
</zip>
</target>
</project>
OpenEdge release 11.7 ships with a copy of Ant build tool. A script called proant which sets up and runs the Ant is available in the $DLC/bin directory. Running proant uses the build.xml file to compile and generate the samplewebapp.war file into a directory named build. The example build.xml script can be used as it is or adjusted to your own environment. The build.xml file requires some environment variables that are normally set by Proenv.
The sample Web application also contains .project and .setting files for eclipse. You can import the sample Web application source code as an eclipse project and modify it as required. You can this project to create your own Web application.