New Account Helpful Tips
  Common Project - BDA
  Editing the build.xml
Added by Steven Saksa, last edited by Steven Saksa on Feb 17, 2009  (view change)

Labels:

Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.

Editing the build.xml

This page will provide both and overview of the file in addition to pointing out things you may want to edit, information about things you may want to edit will be in bold.
Follow the following links for greater details about properties and macros.
If you are not using one of the targets you should remove it, you can always cut and paste it from the templates in the future if you plan to use it.
  • This section sets the property file load order. If the environment specific file does not exist the build will fail.
    • Load environment
    • Load local.properties
    • Load project.properties
    • Load ${properties.file} (environment specific)
      <?xml version="1.0" encoding="utf-8" ?>
      <!-- bda-build-templage verison 0.10.0-beta -->
      	<property environment="env" />
      	<property file="local.properties" />
      	<property file="project.properties" />
      	<property name="properties.file" value="install.properties"/>
      	<echo message="Using properties file of ${properties.file}." />
      	<available file="${properties.file}" property="properties.file.exists" />
      	<fail unless="properties.file.exists" message="The properties.file ${properties.file} does not exist, please make sure that you pass in an accurate file name with the 'ant -Dproperties.file=somepath/somefile', otherwise the build will fail." />
      	<replaceregexp file="${properties.file}" byline="true" match="^([\w\d.]+)=(.*[\w\d\/\{\}\\]+)[ \t]+\r*$" replace="\1=\2" />
      	<replaceregexp file="${properties.file}" byline="true" match="^([\w\d.]+)=[ \t]+(.*[\w\d\/\{\}\\]+)\r*$" replace="\1=\2" />
      	<property file="${properties.file}" />
  • The section is used to set directory properties built on top of the platform specific base directory. This allows the same property file to be used on multiple platforms.
    <!-- Set application.base.path based on platform -->
    	<condition property="application.base.path" value="${application.base.path.linux}">
    		<or>
    			<os family="unix" />
    			<os family="mac" />
    		</or>
    	</condition>
    	<condition property="application.base.path" value="${application.base.path.windows}">
    		<os family="windows" />
    	</condition>
    	<property name="jboss.home" value="${application.base.path}/${jboss.relative.path}"/>
    	<!-- added for remote deployments since file is copied to root of install dir -->
    	<basename property="properties.file.name" file="${properties.file}" />
  • The properties below define the structure of the project area.
    <!-- BDA standard structure -->
    	<property name="build.dir" location="." />
    	<property name="software.dir" location=".." />
    	<property name="common.dir" location="${software.dir}/common" />
    	<property name="local.repo.dir" location="${software.dir}/local-ivy-repo" />
    	<property name="target.dir" location="${software.dir}/target" />
    	<property name="bda-download.dir" location="${target.dir}/bda-download" />
    	<property name="ivy.settings.dir" location="${common.dir}/ivy" />
    	<property name="lib.dir" location="${target.dir}/lib" />
    	<property name="temp.dir" location="${target.dir}/temp" />
    	<property name="reports.dir" location="${target.dir}/reports" />
    	<property name="bda-utils.dir" location="${target.dir}/bda-utils" />
    	<property name="log.dir" location="${target.dir}/logs" />
    	<property name="dist.dir" location="${target.dir}/dist" />
    	<property name="download.dir" location="${target.dir}/download" />
    	<property name="pt.dir" location="${target.dir}/persistent-transient" />
    	<property name="working.dir" location="${target.dir}/working" />
    	<property name="cacore-sdk.dir" location="${target.dir}/${cacore-sdk.binaries.relative.dir}"/>
  • The properties below define ivy related settings.
    <!-- Ivy Related props -->
    	<property name="ivy.settings.file" value="ivy-settings.xml" />
    	<property name="ivy.file" value="ivy-2.0.0-beta2.jar" />
    	<property name="ivy-cacore.file" value="ivy-cacore-2.0.0-beta2.jar" />
  • The properties below are related to building the project, you will have to edit these to match your project.
    • The *.base.dir properties are the base directory for the sub-project
    • The *.build.file is the build file required to build the sub-project
    • The *.build.target is the target in the sub-project build script to produce the sub-project artifiacts
    • The sample has both an api and webapp set of properties. If you only have one sub-project you can remove the other set. If you require additional sub-projects defined the three variables for you new project/s.
      <!-- Properties that relate to how to call build targets from sub-projects-->
      	<!-- Working directory passed to Ant tasks -->
      	<property name="petstore-api.base.dir" value="${software.dir}/petstore" />
      	<property name="petstore-webapp.base.dir" value="${software.dir}/petstore" />
      	<!-- Build file names relative working dir above, if the basedir of the sub-project ant script is ".." you should set the *.basdir to and the build file should include the dir and build file name from the *.base.dir -->
      	<property name="petstore-webapp.build.file" value="build.xml" />
      	<property name="petstore-api.build.file" value="build.xml" />
      	<!-- The target name that should be called from the sub-project build file -->
      	<property name="petstore-api.build.target" value="build:all" />
      	<property name="petstore-webapp.build.target" value="dist" />
  • The properties below are to define the structure of your existing database scripts. Later in the dist::prep targets the files will be copied from this structure to the structure required by the install scripts.*
    <!-- Used by dist:*:prep to determin list of files to use for incremental build process.
    		Directory and files must be in svn to work.
    	-->
    	<property name="db.src.dir" value="${petstore-webapp.base.dir}/db" />
    	<property name="db-install.src.dir" value="${db.src.dir}/db-install" />
    	<property name="db-upgrade.src.dir" value="${db.src.dir}/db-upgrade" />
  • The properties below define the structure of the distribution, many of them are based on properties from project.properties.
    <!-- Distribution Structure properties, used to copy files into the distribution area.
           		Use project.propertie relative dir names becasue they are used by install also-->
    	<property name="dist.exploded.dir" value="${dist.dir}/exploded" />
    	<property name="petstore-api.dist.dir" value="${dist.exploded.dir}/${petstore-api.dist.relative.dir}" />
    	<property name="petstore-webapp.dist.dir" value="${dist.exploded.dir}/${petstore-webapp.dist.relative.dir}" />
    	<property name="tools.dist.dir" value="${dist.exploded.dir}/${tools.dist.relative.dir}" />
    	<property name="common.dist.dir" value="${dist.exploded.dir}/${common.dist.relative.dir}" />
    	<property name="db-install.dist.dir" value="${dist.exploded.dir}/${db-install.dist.relative.dir}" />
    	<property name="db-upgrade.dist.dir" value="${dist.exploded.dir}/${db-upgrade.dist.relative.dir}" />
    	<property name="jboss-conf.dist.dir" value="${dist.exploded.dir}/${jboss-conf.dist.relative.dir}" />
  • The properties below are used for setting up selenium.
    <!-- Selenium settings -->
    	<property name="selenium.jar" value="${lib.dir}/test-selenium/selenium-server-1.0-beta-1.jar" />
    	<property name="selenium.browser" value="*iexplore" />
    	<!--  What you would need for a ci server, recommend setting in local.properties
    	<property name="selenium.browser" value="*firefox /usr/lib64/firefox-1.5.0.12/firefox-bin"/>
    	-->
    	<property name="selenium.proxy.port" value="4444" />
    	<property name="selenium.report.dir" value="${reports.dir}/selenium" />
    	<property name="selenium.report.file" value="selenium-rpt.html" />
    	<property name="selenium.test.dir" value="${software.dir}/tests/functional/selenium" />
    	<property name="selenium.test.suite" value="${selenium.test.dir}/bdaTestSuite.html" />
    	<property name="selenium.url" value="http://${jboss.server.hostname}:${jboss.server.port}" />
    	<!-- Where to write files retrieved by get, into the distribution area.  The file names come from project.properties  -->
    	<property name="jboss.dest.file" value="${download.dir}/${jboss.binaries.file}" />
  • The properties below are define the install time targets used by the install and upgrade tracts of the build. They are the target that gets called in the install.xml.
    <!-- Default install time targets passed by deploy targets to the installer, can be overridden by being set on the command line if different target is desitred.  -->
    	<property name="install.target" value="install" />
    	<property name="upgrade.target" value="upgrade" />
  • The properties below are related to hot deploys.
    <!-- Hot deploy variables -->
    	<property name="jboss.deploy.dir"  value="${jboss.home}/server/${jboss.server.name}/deploy"/>
    	<property name="petstore-webapp.name"  value="petstore-webapp"/>
    	<property name="petstore-webapp.file.name"  value="${petstore-webapp.name}.war"/>
    	<property name="petstore-webapp.src.dir" value="${petstore-webapp.base.dir}/src/web"/>
  • The properties and code below download the bda-utils
    <!-- retrive ivy files then retrieve bda files and librarires -->
    	<property name="commonlibrary.dir" value="" />
    	<property name="bda-download.file" value="bda-ivy-build.xml" />
    	<mkdir dir="${bda-download.dir}" />
    	<property name="bda-download.src.url" value="http://gforge.nci.nih.gov/svnroot/automation/trunk/software/bda-download/${bda-download.file}" />
    	<get src="${bda-download.src.url}" dest="${bda-download.dir}/${bda-download.file}" />
    	<ant inheritAll="false" inheritRefs="false" antfile="${bda-download.file}" target="retrieve-bda" dir="${bda-download.dir}">
    		<property name="bda.version" value="${bda.version}" />
    		<property name="bda-utils.dir" location="${bda-utils.dir}" />
    		<property name="lib.dir" location="${lib.dir}" />
    		<property name="software.dir" location="${software.dir}" />
    		<property name="commonlibrary.dir" location="${commonlibrary.dir}" />
    	</ant>
  • The code below starts a log.
    <!-- Start logging -->
    	<mkdir dir="${log.dir}" />
    	<tstamp>
    		<format property="install.time" pattern="yyyy-MM-dd-HH-mm" />
    	</tstamp>
    	<record name="${log.dir}/install-${install.time}.log" action="start" />
  • The code below conditionally defines variables about database based on database type. This same code is in the install.xml.
    <!-- set some db variables -->
    	<switch value="${database.type}">
    		<case value="oracle">
    			<property name="database.dialect" value="org.hibernate.dialect.OracleDialect"/>
    			<property name="database.driver.file" value="${bda-utils.dir}/ojdbc14-10.2.0.3.0.jar"/>
    			<property name="database.driver" value="oracle.jdbc.driver.OracleDriver"/>
    			<property name="database.schema" value="${database.name}"/>
    		</case>
    		<case value="mysql">
    			<property name="database.dialect" value="org.hibernate.dialect.MySQLDialect"/>
    			<property name="database.driver.file" value="${bda-utils.dir}/mysql-connector-java-5.0.5.jar"/>
    			<property name="database.driver" value="com.mysql.jdbc.Driver"/>
    			<property name="database.schema" value="${database.name}"/>
    		</case>
    		<case value="postgresql">
    			<property name="database.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
    			<property name="database.driver.file" value="${bda-utils.dir}/postgresql-jdbc3-8.3-603.jar"/>
    			<property name="database.driver" value="org.postgresql.Driver"/>
    			<property name="database.schema" value="public"/>
    		</case>
    		<default>
    			<fail message="Invalid database type ${database.type}"/>
    		</default>
    	</switch>
    	<path id="jdbc.driver.classpath">
    		<pathelement location="${database.driver.file}"/>
    	</path>
  • The clean target, if you need to do additional cleaning you can add it here
    <target name="clean">
    		<delete dir="${dist.dir}" />
    		<delete dir="${temp.dir}" />
    	</target>
  • This target creates directories, can download jboss at build time if your project requires jboss to compile against if require.jboss is set.
    <target name="init" description="Sets up build are and initalizes variables">
    		<echo message=" ______   ______   _______ " />
    		<echo message="(____  \ (______) (_______)" />
    		<echo message=" ____)  ) _     _  _______ " />
    		<echo message="|  __  ( | |   | ||  ___  |" />
    		<echo message="| |__)  )| |__/ / | |   | |" />
    		<echo message="|______/ |_____/  |_|   |_|" />
    		<mkdir dir="${target.dir}" />
    		<mkdir dir="${dist.dir}" />
    		<mkdir dir="${dist.exploded.dir}" />
    		<mkdir dir="${petstore-api.dist.dir}" />
    		<mkdir dir="${petstore-webapp.dist.dir}" />
    		<mkdir dir="${common.dist.dir}" />
    		<mkdir dir="${tools.dist.dir}" />
    		<mkdir dir="${temp.dir}" />
    		<mkdir dir="${download.dir}" />
    		<mkdir dir="${pt.dir}" />
    		<available file="${jboss.dest.file}" property="jboss.tools.exists" />
    		<!-- If jboss is required to build, then check for jboss in jboss.home, then check for in jboss in working directory, if not found then download it into this that directory.
    		If found at any point set local.jboss.home to where it is found.  This can be passed to sub-projects so then can compile code against distribution.  This is especially important
    		on AntHillPro server which will not have jboss present, thus will have to use a copy in the working area.  This also makes it easier to start the project, if the developer does
    		not yet have jboss installed, build will download it and install it so build can proceed. -->
    		<if>
    			<equals arg1="${require.jboss}" arg2="true" />
    			<then>
    				<available file="${jboss.home}/lib/commons-httpclient.jar" property="rt.jboss.exists" />
    				<if>
    					<isset property="rt.jboss.exists" />
    					<then>
    						<property name="local.jboss.home" location="${jboss.home}" />
    						<echo message="JBOSS_HOME exists ${jboss.home}" />
    					</then>
    					<else>
    						<property name="local.jboss.home" location="${pt.dir}/${jboss.binaries.relative.dir}" />
    						<available file="${local.jboss.home}/lib/commons-httpclient.jar" property="local.jboss.exists" />
    						<echo message="JBOSS_HOME does not exist checking for LOCAL_JBOSS_HOME ${local.jboss.home}" />
    						<if>
    							<not>
    								<isset property="local.jboss.exists" />
    							</not>
    							<then>
    								<echo message="LOCAL_JBOSS_HOME not found downloading." />
    								<antcall target="dist:tools:retrieve:jboss" />
    								<java jar="${tools.dir}/${jboss.binaries.file}" fork="true">
    									<arg line="-installGroup ejb3 installpath=${local.jboss.home}" />
    								</java>
    							</then>
    							<else>
    								<echo message="LOCAL_JBOSS_HOME found ${local.jboss.home}" />
    							</else>
    						</if>
    					</else>
    				</if>
    			</then>
    		</if>
    	</target>
  • This target cleans the ivy cache of bda-utils and also the sub-projects, if you are using ivy in your sub-projects you would need to add calls to your sub-project build script ivy clean target.
    <target name="ivy:clean" description="Cleans up the ivy cache of this project and all sub-projects">
    		<ivy:settings file="${ivy.settings.dir}/${ivy.settings.file}" />
    		<ivy:cleancache />
    		<ant inheritAll="false" inheritRefs="false" antfile="bda-ivy-build.xml" target="ivy-cleancache" dir="${bda-download.dir}">
    			<property name="bda-utils.dir" value="${bda-utils.dir}" />
    			<property name="lib.dir" value="${lib.dir}" />
    			<property name="software.dir" value="${software.dir}" />
    		</ant>
    		<!--
    		<ant inheritAll="false" inheritRefs="false" antfile="${petstore-webapp.build.file}" target="ivy-clean" dir="${petstore-webapp.base.dir}" />
    		-->
    	</target>
  • If you are using cacore-sdk, you can download and extract it before attempting to build. We have coordinated with the cacore-sdk team to set this up. The cacore-sdk.required property determines if this done. It also downloads wscore if required.
    <target name="build:retrieve:cacore-sdk">
    		<mkdir dir="${download.dir}"/>
    		<if>
    			<and>
    				<equals arg1="${cacore-sdk.required}" arg2="true"/>
    				<not>
    					<available file="${download.dir}/${cacore-sdk.binaries.file}"/>
    				</not>
    			</and>
    			<then>
    				<get src="${cacore-sdk.src.url}" dest="${download.dir}/${cacore-sdk.binaries.file}" />
    			</then>
    		</if>
    	</target>
    	<target name="build:extract:cacore-sdk">
    		<mkdir dir="${target.dir}"/>
    		<if>
    			<and>
    				<equals arg1="${cacore-sdk.required}" arg2="true"/>
    				<not>
    					<available file="${cacore-sdk.dir}"/>
    				</not>
    			</and>
    			<then>
    				<unzip src="${download.dir}/${cacore-sdk.binaries.file}" dest="${target.dir}"/>
    			</then>
    		</if>
    	</target>
    	<target name="validate:pre:build"
    		depends="
    		build:retrieve:cacore-sdk,
    		build:extract:cacore-sdk
    		">
    		<validate-pre-build
    			/>
    	</target>
  • This target calls all the other sub-project builds. This is the default target of the build script.
    <target name="build:all" description="Builds all the sub projects, putting artifacts in the project level target directory, used by distribution targets to make distributions" depends="
    		validate:pre:build,
     		clean,
     		init,
     		build:petstore-webapp
    		" >
    	</target>
  • We have encountered several projects that had multiple sub-projects. One for their web application and one to build APIs used by the sub-project. If you only have one sub-project you can remove this block. If you have more you may have to define more. Also make sure define the right dependencies between the projects.
    <target name="build:petstore-api" depends="init" description="Call api sub-projects build target to produce artifiacts">
    		<!--
    		<ant inheritAll="false" inheritRefs="false" antfile="${petstore-api.build.file}"
    			target="${petstore-api.build.target}"
    			dir="${petstore-api.base.dir}" >
    			<property name="env.GLOBUS_LOCATION" value="${env.GLOBUS_LOCATION}"/>
    		</ant>
    		-->
    	</target>
  • This target builds the artifacts required by the webapp. It uses the properties defined above to call the build script and target. Also you can pass in variables to override the ones set in the sub-project build file. Since we want the artifacts to end up under dist.exploded.dir you should override the property in the sub-project build to make sure the artifacts end up where we need them. Also if you are using wscore you can pass in the GLOBUS_LOCATION, so you can use the ones identified or setup up by the validate-pre-build macro.
    <target name="build:petstore-webapp" depends="init, build:petstore-api" description="Call webapp sub-projects build target to produce artifiacts">
    		<!-- setting the property in the ant call overrides the property in the sub-project allowing the artifact to be produced where needed -->
    		<ant inheritAll="false" inheritRefs="false" antfile="${petstore-webapp.build.file}" target="${petstore-webapp.build.target}" dir="${petstore-webapp.base.dir}">
    			<property name="dist.dir" value="${petstore-webapp.dist.dir}" />
    			<property name="env.GLOBUS_LOCATION" value="${env.GLOBUS_LOCATION}"/>
    		</ant>
    	</target>
  • This target prepares the gui-installer, downloading izpack and setting it up.
    <target name="dist:gui-installer" description="Makes Gui-Installer distribution">
    		<delete>
    			<fileset dir="${dist.dir}">
    				<include name="*.jar"/>
    			</fileset>
    		</delete>
    		<gui-installer-prep
    			/>
    		<ant inheritAll="false" inheritRefs="false" 
    			antfile="install.xml"
    			target="build:installer"
    			dir="${build.dir}/gui-installer"
    			>
    			<property name="compile.jar.dir" value="${target.dir}/izpack-4.0.1"/>
    		</ant>
    	</target>
  • The dist targets below are responsible for producing distributions and downloading tools to include in the distribution.
    <target name="dist" description="Makes all distributions: installer, upgrader and source" depends="
    		build:all,
    		dist:installer,
    		dist:upgrader,
    		dist:src,
    		dist:gui-installer
    		">
    	</target>
    	<target name="dist:tools:retrieve" description="Downloads binary applications from commonlibrary repository" depends="
    		init,
     		dist:tools:retrieve:jboss
    		" >
    	</target>
    	<target name="dist:tools:retrieve:jboss" unless="jboss.tools.exists" description="Downloads JBOSS from binary repository and verifies checksum">
    		<get src="${jboss.src.url}" dest="${jboss.dest.file}" />
    		<get src="${jboss.src.url}.MD5" dest="${jboss.dest.file}.MD5" />
    		<checksum file="${jboss.dest.file}" verifyProperty="jboss.cksum.ok" />
    		<if>
    			<equals arg1="${jboss.cksum.ok}" arg2="true" />
    			<then>
    				<echo message="Downloaded jboss sucessfully" />
    			</then>
    			<else>
    				<fail message="Failed to download jboss file sucessfully." />
    			</else>
    		</if>
    	</target>
    	<target name="dist:tools:retrieve:jboss-bindings"  description="Downloads JBOSS bindings filefrom binary repository and verifies checksum">
    		<get src="${jboss-bindings.src.url}" dest="${dist.exploded.dir}/${jboss-bindings.file}" />
    	</target>
  • The target below copies all the files not produced by the sub-project build into the distribution area (software/target/dist/exploded). Since the database structure under the project and in the distribution may be different we copy them from the source to the desired location in the destination. The destination structure is defined below.
    • db/db-install
      • db/db-install/mysql
      • db/db-install/oracle
      • db/db-install/postgresql
    • db/db-upgrade
    • db/db-upgrade/db-upgrade.xml (liquibase change log file)
      • db/db-upgrade/mysql
      • db/db-upgrade/oracle
      • db/db-upgrade/postgresql
  • In addition we use a macro to copy over tools, bda-utils and common resources.
    <target name="dist:installer:prep" depends="dist:tools:retrieve,dist:tools:retrieve:jboss-bindings" description="Copies artifacts not generated by sub-project builds into the install distribution area">
    		<!-- Copy db-install and db-upgrade scripts from source into distribution area. The db files need to be under db-[install/upgard]/${database.type}. Because of this fact these files were not moved to the macro. -->
    		<copy todir="${db-install.dist.dir}" overwrite="true">
    			<fileset dir="${db-install.src.dir}">
    				<include name="**/*" />
    			</fileset>
    		</copy>
    		<copy todir="${db-upgrade.dist.dir}" overwrite="true">
    			<fileset dir="${db-upgrade.src.dir}">
    				<include name="**/*" />
    			</fileset>
    		</copy>
    		<dist-prep />
    	</target>
  • This target modifies the files in the distribution area to finalize them for the zip file distribution.
    • The properties file are obfuscated for use by external installations. Remote installations have their own properties files
      • Some properties are set to REPLACE, if they are not edited by a user the build will fail(required.property.list)
      • Some properties are set to replace, if they are not edited by a user the build will generate warnings.(optional.property.list)
      • some are deleted (delete.property.list)
        <target name="dist:installer" depends="dist:installer:prep" description="Produces zip file based on installer distribution area. Zip is used by deploy:remote:* or external installations">
        		<delete file="${dist.dir}/${petstore-webapp.install.zip.file}" />
        		<!-- Set environment name to external -->
        		<replaceregexp file="${dist.exploded.dir}/install.properties" byline="true" match="^(env.name)=.*" replace="\1=external" />
        		<obfuscate-properties-file
        			properties.file="${dist.exploded.dir}/install.properties"
        			required.property.list="application.base.path.linux,application.base.path.windows,database.system.user,database.system.password,database.server,database.port,database.name,database.user,database.password,mail.smtp.host,jboss.server.hostname"
        			optional.property.list="ldap.url,ldap.basedn"
        			delete.property.list="exclude.jboss.backup"
        			/>
        		<zip destfile="${dist.dir}/${petstore-webapp.install.zip.file}" basedir="${dist.exploded.dir}" />
        	</target>
  • Similar to dist:installer:prep, except only database upgrade scripts are copied.
    <target name="dist:upgrader:prep" depends="dist:tools:retrieve:jboss-bindings" description="Copies artifacts not generated by sub-project builds into the install distribution area">
    		<!-- Copy db-upgrade scripts from source into distribution area. The db files need to be under db-upgrade/${database.type}. This has not been moved to the macro because the source and dest structure may not be the same and thus this would need to be custom. -->
    		<copy todir="${db-upgrade.dist.dir}" overwrite="true">
    			<fileset dir="${db-upgrade.src.dir}">
    				<include name="**/*" />
    			</fileset>
    		</copy>
    		<dist-prep
    			copy.tools.flag="N"
    			default.target="upgrade"
    			/>
    	</target>
  • Similar to the dist:installer except it also copies in an upgrade file and changes the default properties file to upgrade.properties.
    <target name="dist:upgrader" depends="dist:upgrader:prep" description="Produces zip file based on installer distribution area. Zip is used by deploy:remote:* or external installations">
    		<delete file="${dist.dir}/${petstore-webapp.upgrade.zip.file}" />
    		<!-- Set environment name to external -->
    		<replaceregexp file="${dist.exploded.dir}/install.properties" byline="true" match="^(env.name)=.*" replace="\1=external" />
    		<obfuscate-properties-file
    			properties.file="${dist.exploded.dir}/install.properties"
    			required.property.list="application.base.path.linux,application.base.path.windows,database.system.user,database.system.password,database.server,database.port,database.name,database.user,database.password,mail.smtp.host,jboss.server.hostname"
    			optional.property.list="ldap.url,ldap.basedn"
    			delete.property.list="exclude.jboss.backup"
    			/>
    		<copy todir="${dist.exploded.dir}" overwrite="true">
    			<fileset dir="${build.dir}">
    				<include name="upgrade.properties" />
    			</fileset>              
    		</copy>         
    		<replaceregexp file="${dist.exploded.dir}/build.xml" byline="true" match="(&lt;property name=&quot;properties.file&quot;\s+value=&quot;).*(&quot;\s*\/&gt;)" replace="\1upgrade.properties\2" />
    		<zip destfile="${dist.dir}/${petstore-webapp.upgrade.zip.file}" basedir="${dist.exploded.dir}" />
    	</target>
  • This target builds the code, produces a distribution and installs it on the local machine through a macro.
    <target name="deploy:local:install" depends="build:all,dist:installer:prep" description="Installs and configures the application and required binaries and re-creates the datbase  on the local machine. Used for developer desktops and ci environments.">
    		<!--
    		  * Requires a database installation.
    		  * Will use the target from install.xml specified in ${install.target} (defaults to install unless passed in on command line).
    		  * If you want properties to be used at install time they must be included in a proeprties file.
    		  * Calls ant from exec task to ensure properties are do not carry over from current ant runtime and also to emulate a manual install.
    		  * This target will use differnt properties based on linux (linux-install.properties) or windows (windows-install.properties) installs.
    		  * It only supports using those properties files for now, so if you want to change install time properites edit these files.
    		-->
    		<deploy-local
    			target.name="${install.target}"
    			/>
    	</target>
  • This target builds the code, produces a distribution and upgrades it on the local machine through a macro.
    <target name="deploy:local:upgrade" depends="build:all,dist:upgrader:prep" description="Upgrades and configures the application and database  on the local machine. Used for developer desktops and ci environments.">
    		<!--
    		  * Requires a database installation.
    		  * Will use the target from install.xml specified in ${upgrade.target} (defaults to install unless passed in on command line).
    		  * Calls ant from exec task to ensure properties are do not carry over from current ant runtime and also to emulate a manual install, if you want properties to be used at install time they must be included in a proeprties file.
    		  * This target will use differnt properties based on linux (linux-upgrade.properties) or windows (windows-upgrade.properties) installs.
    		  * It only supports using those properties files for now, so if you want to change install time properites edit these files.
    		-->
    		<deploy-local
    			target.name="${upgrade.target}"
    			/>
    	</target>
  • This target builds the code, produces a distribution, copies it to a remote system and installs it on the remote system. This target cannot be used on NCI Tiers.
    <target name="deploy:remote:install" description="Installs and configures the application and required binaries and re-creates the datbase  on a remote machine. Used for NCI tiers (dev, qa, stg, prod)" depends="
    		build:all,
    		dist:installer
    		">
    		<!--
    		  * Will use the target from install.xml specified in ${install.target} (defaults to install unless passed in on command line).
    		  * Requires specifying -Dproperties.file=@file@ on the command line to point installer to correct enviornment to install into.
    		  * Calls ant from exec task to ensure properties are do not carry over from current ant runtime and also to emulate a manual install, if you want properties to be used at install time they must be included in a proeprties file.
    		-->
    		<!-- Call macro to deploy files on desired server -->
    		<deploy-files dist.file="${petstore-webapp.install.zip.file}" />
    		<!-- SSH to machine ant run ant command line to install application -->
    		<remote-ssh remotesshcommand=". .bash_profile;cd ${ssh.dir.temp}; ant -Dproperties.file=${properties.file.name} -Dforce.reinstall=true ${install.target}" />
    	</target>
  • This target builds the code, produces a distribution, copies it to a remote system and upgrades it on the remote system. This target is used on NCI Tiers.
    <target name="deploy:remote:upgrade" description="Installs and configures the application and required binaries and re-creates the datbase  on a remote machine. Used for NCI tiers (dev, qa, stg, prod)" depends="
    		build:all,
    		dist:upgrader
    		">
    		<!--
    		  * Will use the target from install.xml specified in ${upgrade.target} (defaults to upgrade unless passed in on command line).
    		  * Requires specifying -Dproperties.file=@file@ on the command line to point installer to correct enviornment to install into.
    		  * Calls ant from exec task to ensure properties are do not carry over from current ant runtime and also to emulate a manual install, if you want properties to be used at install time they must be included in a proeprties file.
    		-->
    		<!-- Call macro to deploy files on desired server -->
    		<deploy-files dist.file="${petstore-webapp.upgrade.zip.file}" />
    		<!-- SSH to machine ant run ant command line to install application -->
    		<remote-ssh remotesshcommand=". .bash_profile;cd ${ssh.dir.temp}; ant -Dproperties.file=${properties.file.name} -Dforce.reinstall=true ${upgrade.target}" />
    	</target>
  • This target generates grand graphs of build files. You should add your sub-project build files to this target.
    <target name="report:grand" depends="dist:installer:prep" description="Generates target flow diagrams for build files">
    		<!-- Temporary fix to make grand work for install.xml -->
    		<report-grand 
    			build.file.location="build.xml" 
    			output.file.dir="${grand.rpt.dir}" 
    			output.file.name="generic-root-build.xml" />
    		<report-grand 
    			build.file.location="${dist.exploded.dir}/build.xml" 
    			output.file.dir="${grand.rpt.dir}" 
    			output.file.name="generic-root-install.xml" />
    	</target>
  • These targets call the sub-project test targets. You need to modify them to to call your test targets.
    <target name="test:all" description="Runs test target for all sub-projects" depends="
    		clean,
    		init,
    		test:petstore-api,
    		test:petstore-webapp
    		" >
    	</target>
    	<target name="test:petstore-api" depends="init" description="Calls test target for sub-project">
    		<!--
    		<ant inheritAll="false" inheritRefs="false" antfile="${petstore-api.test.file}"
    			target="test"
    			dir="${petstore-api.base.dir}" >
    			<property name="dist" value="${petstore-api.dist.dir}" />
    		</ant>
    		-->
    	</target>
    	<target name="test:petstore-webapp" depends="init" description="Calls test target for sub-project">
    		<ant inheritAll="false" inheritRefs="false" antfile="${petstore-webapp.test.file}" target="test" dir="${petstore-webapp.base.dir}">
    			<property name="dist.dir" value="${petstore-webapp.dist.dir}" />
    		</ant>
    	</target>
  • These targets call the sub-project static-analysis targets. You need to modify them to to call your sub-project static-analysis targets.
    <target name="static-analysis:all" description="Runs static-analysis target for all sub-projects" depends="
    		clean,
    		init,
    		static-analysis:petstore-api,
    		static-analysis:petstore-webapp
    		" >
    	</target>
    	<target name="static-analysis:petstore-api" depends="init" description="Calls static-analysis target for sub-project">
    		<!--
    		<ant inheritAll="false" inheritRefs="false" antfile="${petstore-api.build.file}"
    			target="static-analysis"
    			dir="${petstore-api.base.dir}" >
    			<property name="dist" value="${petstore-api.dist.dir}" />
    		</ant>
    		-->
    	</target>
    	<target name="static-analysis:petstore-webapp" depends="init" description="Calls static-analysis target for sub-project">
    		<ant inheritAll="false" inheritRefs="false" antfile="${petstore-webapp.build.file}" target="static-analysis" dir="${petstore-webapp.base.dir}">
    			<property name="dist.dir" value="${petstore-webapp.dist.dir}" />
    		</ant>
    	</target>
  • A wrapper target that can call call from the continuous integration server.
    <target name="continuous-integration" description="calls wrapper targets for continuous integration build" depends="
    		build:all,
    		static-analysis:all
    		" >
    	</target>
  • The selenium targets, modify them if you want to use them.
    <target name="init:ivy" description="Initializes ivy-repo.based on ivy definition file and ivy settings file">
    		<mkdir dir="${local.repo.dir}" />
    		<property name="ivy.dep.file" value="${ivy.settings.dir}/ivy-test.xml" />
    		<ivy:settings file="${ivy.settings.dir}/ivy.settings.xml" />
    	</target>
    	<target name="ivy-test-selenium" depends="init:ivy" description="Downloads selenium libraries from ivy into library directory">
    		<ivy:resolve refresh="true" conf="test-selenium" />
    		<ivy:retrieve pattern="${lib.dir}/[conf]/[artifact]-[revision].[ext]" conf="test-selenium" />
    		<path id="project.test.selenium.classpath">
    			<fileset dir="${lib.dir}/test-selenium">
    				<include name="*.jar" />
    			</fileset>
    		</path>
    	</target>
    	<target name="test:seleniumrc:start">
    		<echo message="${lib.dir}/test-selenium/selenium-server-0.9.0.jar" />
    		<java jar="${lib.dir}/test-selenium/selenium-server-0.9.0.jar" fork="true" spawn="true" />
    	</target>
    	<target name="test:seleniumrc:stop" description="Stops selenuimrc server when using selenium from java">
    		<get taskname="selenium-shutdown" src="http://localhost:${selenium.proxy.port}/selenium-server/driver/?cmd=shutDown" dest="${temp.dir}/result.txt" ignoreerrors="true" />
    	</target>
    	<target name="test:selenium:init" description="Sets up environment for running selenium tests">
    		<mkdir dir="${selenium.report.dir}" />
    		<if>
    			<not>
    				<socket server="${jboss.server.hostname}" port="${jboss.server.port}" />
    			</not>
    			<then>
    				<jboss-start-jboss />
    			</then>
    		</if>
    	</target>
    	<target name="test:selenium" description="Wrapper target to selenium test suite" depends="
    		ivy-test-selenium,
    		test:selenium:init,
    		test:selenium:run,
    		test:seleniumrc:stop
    		" >
    	</target>
    	<target name="test:selenium:run" description="Executes selenium test suite">
    		<!-- Another optoin  for running tests
    		<java jar="${selenium.jar}" fork="true">
    			<arg line=" -htmlSuite &quot;${selenium.browser}&quot;"/>
    			<arg line=" &quot;${selenium.url}&quot;"/>
    			<arg line=" &quot;${selenium.test.suite}&quot;"/>
    			<arg line=" &quot;${selenium.report.dir}/${selenium.report.file}&quot;"/>
    			<arg line=" -timeout 30"/>
    			<arg line=" -log ${temp.dir}/selenium-debug.log"/>
    		</java> 
    		-->
    		<osfamily property="os.family" />
    		<if>
    			<equals arg1="${os.family}" arg2="unix" />
    			<then>
    				<echo message="To be able to selenium tests on Unix platforms you need to meet the following conditions." />
    				<echo message="You need to be logged in on the console running X (developer linux or mac workstation)." />
    				<echo message=" If you are running it from a server that does not have a console (like a CI server) you need to be running at runlevel 3,
    				
    				 running and xframe buffer ('Xvfb :1 -screen 0 1024x768x24', should be setup on a CI server) and have your DISPLAY environment variable sto to
    				
    				 match your frame buffer ('DISPLAY=:1.0', should be set in .bash_profile on CI server)." />
    				<fail unless="env.DISPLAY" message="DISPLAY environment variable not set, please set it as outlined above and run again." />
    			</then>
    		</if>
    		<taskdef resource="selenium-ant.properties" classpathref="project.test.selenium.classpath" />
    		<selenese suite="${selenium.test.suite}" browser="${selenium.browser}" results="${selenium.report.dir}/${selenium.report.file}" multiWindow="falsE" timeoutInSeconds="60" port="${selenium.proxy.port}" startURL="${selenium.url}" />
    	</target>
  • These targets can be used to hot-deploy to an appserver, may be used for quick deployments during development on your local machine. May have to be customized for your project.
    <target name="deploy:hot:jsp" description="Copies all current JSP code to the deployed application for quick update">
    		<for param="toDir">
    			<path>
    				<dirset dir="${jboss.deploy.dir}/../tmp/deploy" includes="tmp*${petstore-webapp.name}*" />
    			</path>
    			<sequential>
    				<copy todir="@{toDir}" overwrite="true">
    					<fileset dir="${petstore-webapp.src.dir}">
    						<include name="**/*.jsp" />
    						<include name="**/*.jspf" />
    						<include name="**/*.css" />
    						<include name="**/*.js" />
    						<include name="**/*.jpg" />
    						<include name="**/*.gif" />
    						<include name="**/*.png" />
    						<include name="**/*.faces" />
    						<include name="**/*.tag" />
    						<include name="**/*.tagf" />
    					</fileset>
    				</copy>
    			</sequential>
    		</for>
    	</target>
  • These targets implement Liquibase reporting targets.
    <target name="database:prep" description="Copies db files with filtering">
    		<echoproperties prefix="database"/>
    		<copy todir="${working.dir}/" filtering="true"  overwrite="true">
    			<fileset dir="${db.src.dir}">
    				<include name="**/db-upgrade/**/*"/>
    			</fileset>
    			<filterset>
    				<filtersfile file="${properties.file}"/>
    				<filtersfile file="project.properties"/>
    				<filter token="db-upgrade.run.dir" value="${working.dir}/db-upgrade/${database.type}"/>
    			</filterset>
    		</copy>
    	</target>
    	<target name="database:gencl" description="Upgrades database using BDA Datbase Upgrade process." unless="exclude.database"
    		depends="
    			database:prep
    			">
    			<database-genchangelog
    				database.changelog.file="${target.dir}/generated-change-log.xml"
    				/>
    	</target>
    	<target name="database:diff" description="Upgrades database using BDA Datbase Upgrade process." unless="exclude.database"
    		depends="
    			database:prep
    			">
    			<database-diff
    				output.file.txt="${target.dir}/generated-diff-log.txt"
    				output.file.xml="${target.dir}/generated-diff-log.xml"
    				/>
    	</target>
    	<target name="database:doc" description="Generates database documentation." unless="exclude.database"
    		depends="
    			database:prep
    			">
    		<mkdir dir="${reports.dir}/db"/>
    		<database-doc
    			output.dir="${reports.dir}/db"
    			database.changelog.file="${working.dir}/db-upgrade/db-upgrade.xml"
    			/>
    	</target>
  • Targets that use libraries to generated ERD and UML reports (HTML).
    <target name="report:erd">
    		<generate-erd   
    			schemaspy.jar="schemaspy-3.1.1.jar"
    			database.driver.jar="mysql-connector-java-5.0.5.jar"
    			/>                      
    	</target>
    	<target name="report:uml">
    		<property name="uml.dir" value="${reports.dir}/uml"/>
    		<path id="petstore.classpath.ref">
    			<fileset dir="${lib.dir}/runtime">
    				<include name="**/*.jar" />     
    			</fileset>              
    		</path>         
    		<generate-uml   
    			uml.dir="${uml.dir}"    
    			src.java.dir="${petstore-webapp.base.dir}/src/java"
    			uml.source.path="petstore.classpath.ref"
    			/>                      
    	</target>


CONTACT US PRIVACY NOTICE DISCLAIMER ACCESSIBILITY APPLICATION SUPPORT
National Cancer Institute Department of Health and Human Services National Institutes of Health USA.gov