Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

508 lines (422 sloc) 17.968 kb
<?xml version="1.0"?>
<project name="MXUnit Framework Build" default="package" basedir=".">
<description>
Build file for moving all files into a directory structure easily zippable and deployable
</description>
<!--
Committers: HOW TO CONFIGURE YOUR ENVIRONMENT
1) (one time only): get latest from repository to ensure you have all jar files from the lib directory
2) add the commons-net, jakarta-oro, mail, and activation jars to your ant classpath in eclipse (window - preferences - ant - runtime - add external jars)
3) when you last pulled, it put a directory called "buildprops" into your mxunit directory. get the unames.properties file from marc and put it in there. otherwise, this build will not work at all. nothing. nada.
-->
<!--
=================================
Target: init
Initializes the general settings and properties used in the build
=================================
-->
<target name="init">
<tstamp>
<format pattern="MM_dd_yyyy" property="nightlystamp" />
<format pattern="MM/dd/yyyy" property="nightlydate" />
</tstamp>
<property name="dist" location="dist" />
<property name="nightlyfile" location="dist/mxunit-nightly-${nightlystamp}.zip" />
<property name="unames.file" value="buildprops/unames.properties" />
<property name="version.file" value="buildprops/version.properties" />
<property name="version.nightlyfile" value="buildprops/nightlyversion.properties" />
<property name="readme.file" value="README.txt" />
<property name="readme.nightlyfile" value="README.nightly" />
<property name="antrunner.file" value="buildprops/antrunner.properties" />
<property name="testmailmessage.file" value="buildprops/testresultsmail.html" />
<!-- user property file for instance specific settings -->
<property file="${unames.file}" />
<!--
get the server, port, and webroot properties from the
antrunner file; this way each developer can have their
own version of the properties file with different
values depending on their setup
-->
<property file="${antrunner.file}" />
<!-- for the test runner -->
<property name="mxunit.jar" value="ant/lib/mxunit-ant.jar" />
<property name="junit.out.dir.xml" value="tests/testresults/${server}_${port}" />
<property name="junit.out.dir.html" value="${junit.out.dir.xml}/html" />
<property name="output.dir" value="${junit.out.dir.xml}/tmp" />
<property name="style.dir" value="ant/xsl/" />
<path id="project.classpath">
<fileset dir="lib">
<include name="*.jar" />
</fileset>
</path>
<taskdef name="mxunittask" classname="org.mxunit.ant.MXUnitAntTask" classpath="${mxunit.jar}" />
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="project.classpath" />
</target>
<!--
=================================
Target: clean
Cleans up un-needed files
=================================
-->
<target name="clean" depends="init">
<mkdir dir="${dist}" />
<delete failonerror="false">
<fileset dir="${dist}" includes="*.zip" />
</delete>
<delete failonerror="false">
<fileset dir="framework/generated" includes="*.*" />
</delete>
</target>
<!--
================================================
Intended Targets
================================================
-->
<!--
=================================
Target: publish
- publish the zip
- upload to google code
- upload version.properties to the website
- reload the website
=================================
-->
<target name="publish" depends="runTests,incrementVersion,package,upload,updatewebsite,publishTestResults" description="--> packages into a zip and uploads to google code" />
<target name="publishGitRelease" depends="runTests,incrementVersion,package">
<gitPushBuildChanges remoteName="upstream" branchName="master"/>
<gitTag remoteName="upstream" tagName="v${build.version}" message="Version ${build.version}" />
</target>
<!--
=================================
Target: publishNightly
- run tests
- update version.properties and readme.txt
- commit and push those changes to github
- tag this version as nightly_latest_stable_build and push to github
=================================
-->
<target name="publishNightly" depends="runTests,updateNightlyFiles,packageNightly" description="--> publishes the nightly build to github">
<gitPushBuildChanges remoteName="upstream" branchName="develop"/>
<gitTag remoteName="upstream" tagName="nightly_latest_stable_build"/>
</target>
<!--
=================================
Target: package
Generates the zip archive
=================================
-->
<target name="package" depends="clean,getVersion,genApiDocs" description="--> packages the appropriate files into the deployment-ready zip file. use this for testing; otherwise, use publish">
<echo message="building ${zipfile}. basedir is ${basedir}" />
<zip destfile="${zipfile}" casesensitive="false">
<zipfileset dir="${basedir}" includes="*.*,ant/,buildprops/,eclipse/,doc/,framework/,generator/,images/,PluginDemoTests/,resources/,runner/,samples/,tests/,lib/ant-contrib**,utils/" excludes=".settings/,.git/,.gitignore,MXUnitInstallTest.cfc,**/testresults/,**/stats/,**/junithtml/,.project,.deployment,**/unames.properties,tests/tmp/,ftp.listing,**/*.db,**/copysnippets.properties,**/copydictionary**,**/*.bak,buildprops/nightlyversion.properties,buildprops/testresultsmail.html,settings.xml,README.html,README.textile,README-toc.xml,**/.gitignore" prefix="mxunit" casesensitive="false" />
</zip>
</target>
<!--
=================================
Target: packageNightly
Generates the zip archive for the nightly build
=================================
-->
<target name="packageNightly" depends="package" description="--> packages the appropriate files into the deployment-ready nightly build zip file. Use this for testing; otherwise, use publishNightly">
<move file="${zipfile}" tofile="${nightlyfile}"/>
</target>
<!--
================================================
Internal Targets
Run these individually for testing only
================================================
-->
<!--
=================================
Target: runTests
Runs the MXUnit tests on MXUnit
=================================
-->
<target name="runTests" depends="init">
<delete dir="${junit.out.dir.html}" />
<delete dir="${output.dir}" />
<mkdir dir="${junit.out.dir.html}" />
<mkdir dir="${output.dir}" />
<property name="context" value="" />
<mxunittask server="${server}" port="${port}" defaultrunner="${context}/mxunit/runner/HttpAntRunner.cfc" outputdir="${output.dir}" verbose="true" testResultsSummary="my.summary" failureproperty="testsfailed">
<directory remoteMethod="run" path="${webroot}/mxunit/tests/framework/" packageName="mxunit.tests.framework" componentPath="mxunit.tests.framework" recurse="false" includes="*.cfc" excludes="" />
<directory remoteMethod="run" path="${webroot}/mxunit/tests/mightymock/" packageName="mxunit.tests.mightymock" componentPath="mxunit.tests.mightymock" recurse="false" includes="*.cfc" excludes="" />
<directory remoteMethod="run" path="${webroot}/mxunit/tests/runner" packageName="mxunit.tests.runner" componentPath="mxunit.tests.runner" recurse="false" includes="*.cfc" excludes="" />
</mxunittask>
<!-- create nice pretty report
<junitreport todir="${junit.out.dir.html}">
<fileset dir="${output.dir}">
<include name="*.xml" />
</fileset>
<report format="frames" todir="${junit.out.dir.html}" styledir="${style.dir}" />
</junitreport>-->
<fail if="testsfailed" message="Failing the build because tests failed" />
</target>
<!--
=================================
Target: incrementVersion
Increments the version for the next build
=================================
-->
<target name="incrementVersion" depends="init">
<propertyfile file="${version.file}" comment="Build version info">
<entry key="build.date" type="date" value="now" pattern="MM/dd/yyyy" />
<entry key="build.major" type="int" operation="=" value="2" />
<entry key="build.minor" type="int" operation="=" value="1" />
<entry key="build.notation" operation="=" value="" />
<entry key="build.versiondescription" operation="=" value="Release" />
<!-- this is autoincremented -->
<entry key="build.buildnum" type="int" operation="+" value="1" />
</propertyfile>
<property file="${version.file}" />
<echoproperties prefix="build" />
</target>
<!--
=================================
Target: version
Creates the zip file for the current version
=================================
-->
<target name="getVersion" depends="init">
<property file="${version.file}" />
<property name="build.version" value="${build.major}.${build.minor}.${build.buildnum}${build.notation}" />
<property name="zipfile" location="${dist}${file.separator}mxunit-${build.version}.zip" />
<echo message="build.version is ${build.version} -- zipfile is ${zipfile}" />
<!-- <replaceregexp file="${readme.file}" match="Version Info:(.*)" replace="Version Info: This is release build ${build.version}, built on ${build.date}" /> -->
</target>
<!--
=================================
Target: upload
Uploads the release zip to the Google Code site
=================================
-->
<target name="upload" depends="getVersion">
<input message="Please add a summary for this version" addproperty="build.summary" defaultvalue="MXUnit Unit Test Framework version ${build.version}" />
<taskdef classname="net.bluecow.googlecode.ant.GoogleCodeUploadTask" classpathref="project.classpath" name="gcupload" />
<gcupload username="${gc.username}" password="${gc.password}" projectname="mxunit" filename="${zipfile}" targetfilename="mxunit-${build.version}.zip" summary="${build.summary}" />
</target>
<!--
=================================
Target: updatewebsite
Updates the version on the website
=================================
-->
<target name="updatewebsite" depends="getVersion">
<!-- ftp the version file to the website and reinit the application -->
<ftp server="${ftp.site}" userid="${ftp.username}" password="${ftp.password}" remotedir="">
<fileset dir="buildprops">
<include name="version.properties" />
</fileset>
</ftp>
<!-- reinit the web app; this causes the version.properties file to be reread into the application scope -->
<loadresource property="homepage">
<!--${http.reinit} undefined: to do: talk to marc -->
<url url="http://mxunit.org/index.cfm?reinit=true" />
</loadresource>
</target>
<!--
=================================
Target: genApiDocs
Calls JS in build props which invokes the ColdDoc cfml script
=================================
-->
<target name="genApiDocs" depends="init">
<delete dir="doc/api" failonerror="false"/>
<mkdir dir="doc/api" />
<script language="javascript" src="buildprops/scripts/http_doc_gen.js" />
</target>
<!--
=================================
Target: publishTestResults
FTPs the test results to the web server
=================================
-->
<target name="publishTestResults" depends="init">
<ftp server="${ftp.site}" userid="${ftp.username}" password="${ftp.password}" remotedir="testresults">
<fileset dir="${junit.out.dir.html}">
<include name="**/*" />
</fileset>
</ftp>
</target>
<!--
=================================
Target: updateNightlyFiles
Updates version.properties and readme.txt with the appropriate nightly identifiers
=================================
-->
<target name="updateNightlyFiles" depends="init">
<propertyfile file="${version.file}" comment="Build version info">
<entry key="build.date" type="date" value="now" pattern="MM/dd/yyyy" />
<entry key="build.versiondescription" operation="=" value="Nightly Build" />
</propertyfile>
<property file="${version.file}" />
<property name="build.version" value="${build.major}.${build.minor}.${build.buildnum}${build.notation}" />
<echo message="build.version is ${build.version}" />
<replaceregexp file="${readme.file}" match="Version Info:(.*)" replace="Version Info: This is a nightly build of the ${build.version} stream, built on ${build.date}" />
</target>
<!--
=================================
Target: compileCheck
Compiles the ColdFusion files for any syntax errors
Only works on Windows with ColdFusion
=================================
-->
<target name="compileCheck" depends="init">
<echo>Check Coldfusion Compile for ${webroot}</echo>
<!-- TODO: add os check and run for linux -->
<exec failonerror="true" dir="${cfcompile_path}" executable="cmd.exe" output="${webroot}\compile.log">
<env key="JAVA_HOME" value="${JAVA_HOME}" />
<arg line="/c cfcompile.bat ${webroot}" />
</exec>
<!-- check log for failures -->
<loadfile srcfile="${webroot}compile.log" property="src.file.cferrors">
<filterchain>
<LineContainsRegExp>
<regexp pattern="Error*" />
</LineContainsRegExp>
<trim />
</filterchain>
</loadfile>
<!-- will be set if errors found else variable will be unset -->
<echo>${src.file.cferrors}</echo>
<fail message="cfcompile violation is found.">
<condition>
<isset property="src.file.cferrors" />
</condition>
</fail>
<echo>Successful ColdFusion Compile</echo>
</target>
<!--
=================================
Target: varScopeCheck
Checks the CFC files for any unscoped variables
=================================
-->
<target name="varScopeCheck" depends="init">
<!-- MUST HAVE VARSCOPER IN WEBROOT -->
<!-- not sure if we want to put the jar in the lib folder -->
<echo>Check for unscoped variables</echo>
<!-- load the varScoper task -->
<taskdef name="conGet" classname="com.varscoper.ant.task.ConditionalGet" classpathref="project.classpath" />
<property name="filePathToUse" value="${webroot}" />
<property name="recursiveDirectory" value="true" />
<conGet dest="varScoper.csv" url="http://${server}:${port}/varscoper/varScoper.cfm">
<parameter name="filePath" value="${filePathToUse}" />
<parameter name="displayFormat" value="csv" />
<parameter name="recursiveDirectory" value="${recursiveDirectory}" />
<!--
<FailIfNotFound pattern="&lt;results&gt;&lt;/results&gt;" />
<FailIfFound pattern=".cfc" message="var scope violation is found." />
<FailIfFound pattern=".cfm" message="var scope violation is found." />
-->
</conGet>
<!-- check csv file for any violations -->
<loadfile srcfile="varScoper.csv" property="varScoper.cvs">
<filterchain>
<headfilter skip="1" />
<trim />
</filterchain>
</loadfile>
<!-- will be set if violations found else variable will be unset -->
<echo>${varScoper.cvs}</echo>
<fail message="var scope violation is found.">
<condition>
<isset property="varScoper.cvs" />
</condition>
</fail>
<echo>Successful check for unscoped variables</echo>
</target>
<!--
=================================
Target: testFTP
Tests the FTP connection by uploading a file
=================================
-->
<target name="testFTP" depends="init">
<!-- <echoproperties prefix="ftp" /> -->
<ftp server="${ftp.site}" userid="${ftp.username}" password="${ftp.password}" action="list" listing="ftp.listing" verbose="true">
<fileset>
<include name="index.html" />
</fileset>
</ftp>
</target>
<!--
=================================
Target: testMail
Tests the mail sending ability
=================================
-->
<target name="testMail" depends="init">
<if>
<isset property="mail.ssl" />
<then>
<mail from="${mail.from}" tolist="${mail.to}" mailhost="${mail.host}" subject="MXUnit Build Results" charset="UTF-8" messagemimetype="text/html" user="${mail.user}" password="${mail.password}" ssl="${mail.ssl}" mailport="${mail.port}" message="&lt;h1&gt;Test Successful&lt;/h1&gt;" />
</then>
<else>
<mail from="${mail.from}" tolist="${mail.to}" mailhost="${mail.host}" subject="MXUnit Build Results" charset="UTF-8" messagemimetype="text/html" message="&lt;h1&gt;Test Successful&lt;/h1&gt;" />
</else>
</if>
</target>
<!--
=================================
git-related Macrodefs
=================================
-->
<macrodef name="gitPushBuildChanges">
<attribute name="remoteName" default="origin"/>
<attribute name="branchName" default="develop"/>
<sequential>
<git command="add" dir=".">
<args>
<arg value="."/>
</args>
</git>
<git command="commit" dir=".">
<args>
<arg value="-m"/>
<arg value="'build auto-commit'"/>
</args>
</git>
<git command="push" dir=".">
<args>
<arg value="@{remoteName}"/>
<arg value="@{branchName}"/>
</args>
</git>
</sequential>
</macrodef>
<macrodef name="gitTag">
<attribute name="remoteName" default="origin"/>
<attribute name="tagName"/>
<attribute name="message" default="Auto-tag from build"/>
<sequential>
<git command="tag" dir=".">
<args>
<arg value="-f"/>
<arg value="'@{tagName}'"/>
<arg value="-m"/>
<arg value="'@{message}'"/>
</args>
</git>
<git command="push" dir=".">
<args>
<arg value="-f"/>
<arg value="@{remoteName}"/>
<arg value="'@{tagName}'"/>
</args>
</git>
</sequential>
</macrodef>
<macrodef name = "git">
<attribute name = "command" />
<attribute name = "dir" default = "" />
<element name = "args" optional = "true" />
<sequential>
<echo message = "git @{command}" />
<exec executable = "git" dir = "@{dir}">
<arg value = "@{command}" />
<args/>
</exec>
</sequential>
</macrodef>
</project>
Jump to Line
Something went wrong with that request. Please try again.