Browse files

# Commons structure changed to reflect some aspects of maven.

  • Loading branch information...
1 parent 0e4da6b commit 0a30d6c013b99e8049202fd946f601ba1ea2400a @manuelpichler committed Feb 22, 2011
Showing with 734 additions and 399 deletions.
  1. +5 −6 build-commons.properties
  2. +7 −392 build-commons.xml
  3. +1 −1 build.properties.template
  4. +42 −0 compile.xml
  5. +36 −0 integration-test.xml
  6. +458 −0 package.xml
  7. +57 −0 test.xml
  8. +128 −0 verify.xml
View
11 build-commons.properties
@@ -3,13 +3,12 @@ project.name = ${ant.project.name}
project.version = 0.0.0
project.stability = alpha
-# The local code layout for source and test files
-localdir.src = src/main
-localdir.test = src/test
-
+# The project's root source directory
+project.root = ${basedir}/src
+
# By default we follow the maven directory structure
-basedir.src = ${basedir}/${localdir.src}
-basedir.test = ${basedir}/${localdir.test}
+basedir.src = ${project.root}/main
+basedir.test = ${project.root}/test
# Base directories with PHP source and test files
php.basedir.src = ${basedir.src}/php
View
399 build-commons.xml
@@ -32,13 +32,15 @@
-->
<import file="build-commons-rcs.xml" />
<import file="build-commons-pear.xml" />
+ <import file="verify.xml" />
<!--
Some common settings for all project.
-->
<property name="builddir" location="${basedir}/../build" />
<property name="distdir" location="${builddir}/dist" />
- <property name="scriptdir" location="${basedir}/setup/scripts" />
+ <property name="logsdir" location="${builddir}/logs" />
+ <property name="scriptdir" location="${common-ant-targets.basedir}/scripts" />
<property name="tmpdir" location="${builddir}/tmp" />
<!--
@@ -47,7 +49,7 @@
<tstamp>
<format property="build.date" pattern="yyyy-MM-dd" />
</tstamp>
-
+<!--
<target name="dist-continuous-integration"
depends="init-continuous-integration-properties, dist"
description="Continuous integration distribution build" />
@@ -58,18 +60,14 @@
<property name="build.version" value="${project.version}build${build.number}" />
<property name="build.name" value="${project.name}" />
<property name="build.file" value="${build.name}-${build.version}" />
-
- <property name="phar.archive.bootstrap" value="" />
</target>
-
- <target name="dist" depends="build,pack,tag" description="Default distribution build" />
+-->
+ <target name="dist" depends="build,package,tag" description="-> Default distribution build" />
<target name="init-properties" unless="build.version">
<property name="build.version" value="${project.version}" />
<property name="build.name" value="${project.name}" />
<property name="build.file" value="${build.name}-${build.version}" />
-
- <property name="phar.archive.bootstrap" value="" />
</target>
<target name="clean">
@@ -84,395 +82,12 @@
<mkdir dir="${builddir}" />
<mkdir dir="${tmpdir}" />
<mkdir dir="${distdir}" />
- <mkdir dir="${builddir}/logs" />
+ <mkdir dir="${logsdir}" />
<mkdir dir="${builddir}/phpcb" />
<mkdir dir="${builddir}/coverage" />
</target>
<!--
- Tests several aspects of the project.
-
- - Unit Tests
- - Other Tests
- - Static code analysis
- - Lint checks
- -->
- <target name="test" depends="test-static, test-dynamic" />
-
- <target name="test-static" depends="prepare">
- <parallel>
- <antcall target="lint" />
- <antcall target="checkstyle" />
- <antcall target="phpmd" />
- <antcall target="pdepend" />
- <antcall target="phpcpd" />
- </parallel>
- </target>
-
- <target name="test-dynamic" depends="prepare, test-all, test-unit" />
-
- <!--
- Performance syntax error checks on the project sources.
- -->
- <target name="lint">
- <apply executable="php" failonerror="true">
- <arg value="-l" />
- <fileset dir="${php.basedir.src}">
- <include name="**/*.php" />
- </fileset>
- <fileset dir="${php.basedir.test}">
- <include name="**/*.php" />
- <exclude name="**/_source/**" />
- <exclude name="**/_files/**" />
- <exclude name="**/_code/**" />
- </fileset>
- </apply>
- </target>
-
- <target name="phpmd">
- <exec dir="${basedir}" executable="phpmd" failonerror="false">
- <arg line="${php.basedir.src}" />
- <arg line="xml" />
- <arg line="codesize,unusedcode,naming,design" />
- <arg line="--reportfile ${builddir}/logs/pmd.xml" />
- </exec>
- </target>
-
- <target name="pdepend">
- <exec dir="${basedir}" executable="pdepend" failonerror="false">
- <arg line="--summary-xml=${builddir}/logs/pdepend.xml" />
- <arg line="--jdepend-xml=${builddir}/logs/jdepend.xml" />
- <arg line="${php.basedir.src}" />
- </exec>
- </target>
-
- <target name="phpcpd">
- <exec dir="${basedir}" executable="phpcpd" failonerror="false">
- <arg line="--log-pmd ${builddir}/logs/cpd.xml" />
- <arg line="${php.basedir.src}" />
- </exec>
- </target>
-
- <!--
- Executes all tests for a project, includes unit, functional, integration
- or compatibility tests.
- -->
- <target name="test-all">
- <exec dir="${basedir}" failonerror="true" executable="phpunit">
- <arg line="${phpunit.testsuite.class}" />
- <arg line="${php.basedir.test}/${phpunit.testsuite.file}" />
- </exec>
- </target>
-
- <!--
- Executes all unittests for a project and collects the coverage data for
- the project sources.
- -->
- <target name="test-unit">
- <exec dir="${basedir}" failonerror="true" executable="phpunit">
- <arg line="--group unittest" />
- <arg line="--coverage-html ${builddir}/coverage" />
- <arg line="--coverage-clover ${builddir}/logs/clover.xml" />
- <arg line="--log-junit ${builddir}/logs/junit.xml" />
- <arg line="${phpunit.testsuite.class}" />
- <arg line="${php.basedir.test}/${phpunit.testsuite.file}" />
- </exec>
- </target>
-
- <!--
- Validates that the project code is compatible with the project's coding
- conventions.
- -->
- <target name="checkstyle">
- <exec dir="${basedir}" failonerror="true" executable="phpcs">
- <arg line="--standard=${coding.standard}" />
- <arg line="--report=checkstyle" />
- <arg line="--report-file=${builddir}/logs/checkstyle.xml" />
- <arg line="${php.basedir.src}" />
- </exec>
- </target>
-
- <!--
- Creates different binary releases of the current project.
- -->
- <target name="pack" depends="pack-phar-archive,pack-pear-archive,pack-tar-archive" />
-
- <!--
- Creates a phar archive of the project source
- -->
- <target name="pack-phar-archive" depends="prepare,copy-files-for-phar-archive">
- <property name="phar.archive.filename" value="${distdir}/${build.file}.phar" />
-
- <antcall target="~pack-phar-archive-before">
- <param name="phar.archive.filename" value="${phar.archive.filename}" />
- </antcall>
-
- <exec dir="${basedir}" executable="${scriptdir}/create.phar.php">
- <arg line="${project.name}" />
- <arg line="${phar.archive.filename}" />
- <arg line="${builddir}/phar-archive" />
- <arg line="${phar.archive.bootstrap}" />
- </exec>
-
- <chmod file="${phar.archive.filename}" perm="755" />
-
- <antcall target="~pack-phar-archive-after">
- <param name="phar.archive.filename" value="${phar.archive.filename}" />
- </antcall>
- </target>
-
- <!--
- Hook target that will be called before the phar archive will be created.
-
- Parameters:
- ${phar.archive.filename} Name of the phar file to create.
- -->
- <target name="~pack-phar-archive-before" />
-
- <!--
- Hook target that will be called after the phar archive was created.
-
- Parameters:
- ${phar.archive.filename} Name of the created phar file.
- -->
- <target name="~pack-phar-archive-after" />
-
- <!--
- Copies all files for the project's phar archive.
- -->
- <target name="copy-files-for-phar-archive">
- <copy todir="${builddir}/phar-archive">
- <fileset dir="${php.basedir.src}" />
- <filterchain>
- <replacestring from="@package_version@" to="${project.version}" />
- </filterchain>
- </copy>
-
- <antcall target="copy-library-dir-if-exists">
- <param name="output.dir" value="${builddir}/phar-archive" />
- </antcall>
-
- <antcall target="do-copy-files-for-xyz-archive">
- <param name="output.dir" value="${builddir}/phar-archive" />
- </antcall>
- </target>
-
- <!--
- Creates a pear archive of the project source
- -->
- <target name="pack-pear-archive"
- description="Creates a PEAR archive with the project's source code."
- depends="prepare,
- copy-files-for-pear-archive,
- -common-pear-prepare">
- <antcall target="~pack-pear-archive-before" />
-
- <antcall target="common-pear-channel-discover" />
-
- <exec dir="${distdir}" executable="pear" failonerror="true">
- <arg line="-c" />
- <arg line="${common-pear-config}" />
- <arg line="package" />
- <arg line="${builddir}/pear-archive/package.xml" />
- </exec>
-
- <antcall target="~pack-pear-archive-after" />
- </target>
-
- <!--
- Empty hook target that will be called before the pear archive will be build.
- -->
- <target name="~pack-pear-archive-before" />
-
- <!--
- Empty hook target that will be called after the pear archive was build.
- -->
- <target name="~pack-pear-archive-after" />
-
- <!--
- Copies all files for the project's pear archive.
- -->
- <target name="copy-files-for-pear-archive">
- <copy todir="${builddir}/pear-archive/${project.dir}">
- <fileset dir="${php.basedir.src}"/>
- <fileset dir="${basedir}">
- <include name="**.sh" />
- <include name="**.php" />
- <include name="**.bat" />
- </fileset>
- </copy>
-
- <antcall target="copy-docs-dir-if-exists">
- <param name="output.dir" value="${builddir}/pear-archive" />
- </antcall>
-
- <copy file="${basedir}/LICENSE" todir="${builddir}/pear-archive" />
- <copy file="${basedir}/CHANGELOG" todir="${builddir}/pear-archive" />
-
- <copy file="${basedir}/package.xml" tofile="${builddir}/pear-archive/package.xml">
- <filterchain>
- <replacestring from="${project.name}" to="${build.name}" />
- <replacestring from='name="source"' to='name="${project.name}"' />
- <replacestring from="1970-01-01" to="${build.date}" />
- <replacestring from="0.0.0" to="${build.version}" />
- <replacestring from="devel" to="${project.stability}" />
- </filterchain>
- </copy>
-
- <antcall target="do-copy-files-for-xyz-archive">
- <param name="output.dir" value="${builddir}/pear-archive" />
- </antcall>
- </target>
-
- <!--
- Creates a tar.bz2 archive of the project source
- -->
- <target name="pack-tar-archive" depends="prepare,copy-files-for-tar-archive">
- <tar basedir="${builddir}/tar-archive"
- destfile="${distdir}/${build.file}.tar.bz2"
- compression="bzip2"
- longfile="gnu">
-
- <include name="${build.file}/**" />
- </tar>
- </target>
-
- <!--
- Copies all files for the project's tar archive.
- -->
- <target name="copy-files-for-tar-archive">
- <property name="output.dir" value="${builddir}/tar-archive/${build.file}" />
-
- <copy todir="${output.dir}/source">
- <fileset dir="${php.basedir.src}"/>
- <filterchain>
- <replacestring from="@package_version@" to="${project.version}" />
- </filterchain>
- </copy>
-
- <antcall target="copy-optional-dirs">
- <param name="output.dir" value="${output.dir}" />
- </antcall>
-
- <copy file="${basedir}/LICENSE" todir="${output.dir}" />
- <copy file="${basedir}/CHANGELOG" todir="${output.dir}" />
-
- <antcall target="do-copy-files-for-xyz-archive">
- <param name="output.dir" value="${output.dir}" />
- </antcall>
- </target>
-
- <!--
- Hook method for copying files for the project's xyz archive format.
-
- Parameters:
- output.dir Output directory for the temporary build tree.
- -->
- <target name="do-copy-files-for-xyz-archive">
- <!-- Implement this target in the concrete project build.xml -->
- </target>
-
- <!--
- Copies several optional directories into the output dir.
-
- Parameters:
- output.dir Output directory for the temporary build tree.
- -->
- <target name="copy-optional-dirs" depends="copy-library-dir-if-exists,copy-docs-dir-if-exists" />
-
- <!--
- Optionally copies a library directory into a temporary build tree.
-
- Parameters:
- output.dir Output directory for the temporary build tree.
- -->
- <target name="copy-library-dir-if-exists" depends="test-library-dir-exists,copy-library-dir" />
-
- <!--
- Checks if the current project contains a library folder with external
- dependencies.
- -->
- <target name="test-library-dir-exists">
- <available file="${basedir}/lib" property="library-dir-exists" />
- </target>
-
- <!--
- Copies the library directory of the current project into a temporary
- build source tree.
-
- Parameters:
- output.dir Output directory for the temporary build tree.
- -->
- <target name="copy-library-dir" if="library-dir-exists">
- <property name="library.dir" value="${output.dir}/lib" />
-
- <antcall target="~copy-library-dir-before">
- <param name="output.dir" value="${output.dir}" />
- <param name="library.dir" value="${library.dir}" />
- </antcall>
-
- <copy todir="${output.dir}/lib">
- <fileset dir="${basedir}/lib" />
- </copy>
-
- <antcall target="~copy-library-dir-after">
- <param name="output.dir" value="${output.dir}" />
- <param name="library.dir" value="${library.dir}" />
- </antcall>
- </target>
-
- <!--
- Hook that will be called before we copy the project's library directory.
-
- Parameters:
- output.dir Output directory for the temporary build tree.
- library.dir The library directory in the temporary build tree.
- -->
- <target name="~copy-library-dir-before" />
-
- <!--
- Hook that will be called after we have copied the project's library
- directory.
-
- Parameters:
- output.dir Output directory for the temporary build tree.
- library.dir The library directory in the temporary build tree.
- -->
- <target name="~copy-library-dir-after" />
-
- <!--
- Optionally copies a documentation directory into a temporary build
- source tree.
-
- Parameters:
- output.dir Output directory for the temporary build tree.
- -->
- <target name="copy-docs-dir-if-exists" depends="test-docs-dir-exists,copy-docs-dir" />
-
- <!--
- Checks if the current project has a document directory.
- -->
- <target name="test-docs-dir-exists">
- <available file="${basedir}/docs" property="docs-dir-exists" />
- </target>
-
- <!--
- Copies the documentation directory of the current project into a
- temporary build source tree
-
- Parameters:
- output.dir Output directory for the temporary build tree.
- -->
- <target name="copy-docs-dir" if="docs-dir-exists">
- <copy todir="${output.dir}/docs">
- <fileset dir="${basedir}/docs" />
- <filterchain>
- <replacestring from="__DIR__ . '/../../source" to="'${project.name}" />
- </filterchain>
- </copy>
- </target>
-
- <!--
Automatically creates a repopositoy tag when all tests have passed.
-->
<target name="tag" depends="test-is-svn-checkout,tag-if-project-is-svn-checkout" />
View
2 build.properties.template
@@ -7,4 +7,4 @@ coding.standard = PEAR
phpunit.testsuite.class = \Your\Main\TestSuite
phpunit.testsuite.file = Your/Main/TestSuite.php
-phar.archive.bootstrap = conf/phar_bootstrap.stub
+package.phar.bootstrap.file = conf/phar_bootstrap.stub
View
42 compile.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<project name="ant-build-commons-compile">
+
+ <description>
+ This build file cpntains compile/lint specific targets for the project
+ source code.
+ </description>
+
+ <!--
+ Main public target of this build file.
+ -->
+ <target name="compile"
+ depends="prepare, -compile"
+ description="-> Performs a static syntax check of the project." />
+
+ <!--
+ Internal target that defines the primary workflow of this build component.
+ -->
+ <target name="-compile"
+ depends="-compile:before~hook,
+ -compile:compile,
+ -compile:after~hook" />
+
+ <target name="-compile:before~hook" />
+
+ <target name="-compile:after~hook" />
+
+ <target name="-compile:compile">
+ <apply executable="php" failonerror="true" output="${logsdir}/compile.log">
+ <arg value="-l" />
+ <fileset dir="${php.basedir.src}">
+ <include name="**/*.php" />
+ </fileset>
+ <fileset dir="${php.basedir.test}">
+ <include name="**/*.php" />
+ <exclude name="**/_source/**" />
+ <exclude name="**/_files/**" />
+ <exclude name="**/_code/**" />
+ </fileset>
+ </apply>
+ </target>
+</project>
View
36 integration-test.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="and-build-commons-integration-test" basedir=".">
+
+ <description>
+ This ant build file contains targets that are used to perform
+ integration tests against the project's source code.
+ </description>
+
+ <!--
+ Declare basedir for the verify build file.
+ -->
+ <dirname property="-integration-test:basedir" file="${ant.file.ant-build-commons-integration-test}" />
+
+ <!--
+ Import the parent target file.
+ -->
+ <import file="package.xml" />
+
+ <!--
+ Runs the project's integration tests.
+
+ TODO: These tests should run against the source in each package format.
+ -->
+ <target name="integration-test"
+ depends="package"
+ description="-> Runs all tests for the project." >
+
+ <exec dir="${basedir}" failonerror="true" executable="phpunit">
+ <arg value="--group" />
+ <arg value="integrationtest" />
+ <arg value="${phpunit.testsuite.class}" />
+ <arg value="${php.basedir.test}/${phpunit.testsuite.file}" />
+ </exec>
+ </target>
+
+</project>
View
458 package.xml
@@ -0,0 +1,458 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<project name="ant-build-commons-package">
+
+ <description>
+ This is ant file contains targets for different package/distribution
+ formats used to deliver php application.
+ </description>
+
+ <!--
+ Declare basedir for commons pear
+ -->
+ <dirname property="-package:basedir" file="${ant.file.ant-build-commons-package}" />
+
+ <!--
+ Import the parent target file.
+ -->
+ <import file="test.xml" />
+
+ <!--
+ Creates different binary releases of the current project.
+ -->
+ <!--<target name="package" depends="pack-phar-archive,pack-pear-archive,pack-tar-archive" />-->
+ <target name="package"
+ depends="test, package:phar, package:pear, package:archive"
+ description="-> Generates distributable packages of the project." />
+
+<!-- {{{ PHAR SUPPORT -->
+
+ <!--
+ Enable phar package format by default
+ -->
+ <property name="package.phar.enabled" value="true" />
+
+ <!--
+ Default phar bootstrap file is empty, which means we will generate a
+ phar archive without bootstrapper.
+ -->
+ <property name="package.phar.bootstrap.file" value="" />
+
+ <!--
+ Creates a phar archive of the project source
+ -->
+ <target name="package:phar"
+ if="-package:phar:is.enabled"
+ depends="prepare, -package:phar:is-enabled">
+
+ <antcall target="-package:phar" />
+ </target>
+
+ <!--
+ Tests if the phar package format is enabled?
+ -->
+ <target name="-package:phar:is-enabled">
+ <condition property="-package:phar:is.enabled">
+ <istrue value="${package.phar.enabled}" />
+ </condition>
+ </target>
+
+ <!--
+ Executes all steps required to generate a phar archive.
+ -->
+ <target name="-package:phar"
+ depends="-package:phar:prepare,
+ -package:phar:before~hook,
+ -package:phar:main,
+ -package:phar:after~hook" />
+
+ <!--
+ Hook target that will be called before the phar archive will be created.
+
+ Parameters:
+ ${-package:phar:filename} Name of the phar file to create.
+ -->
+ <target name="-package:phar:before~hook" />
+
+ <!--
+ Hook target that will be called after the phar archive was created.
+
+ Parameters:
+ ${-package:phar:filename} Name of the created phar file.
+ -->
+ <target name="-package:phar:after~hook" />
+
+ <!--
+ Initializes the required environment to generate a phar archive
+ -->
+ <target name="-package:phar:prepare"
+ depends="-package:phar:prepare-properties,
+ -package:phar:prepare-files" />
+
+ <!--
+ Initializes the required phar archive properties
+ -->
+ <target name="-package:phar:prepare-properties">
+ <property name="-package:phar:filename" value="${distdir}/${build.file}.phar" />
+ <property name="-package:phar:builddir" value="${builddir}/phar-archive" />
+ </target>
+
+ <!--
+ Copies all files for the project's phar archive.
+ -->
+ <target name="-package:phar:prepare-files">
+ <copy todir="${-package:phar:builddir}">
+ <fileset dir="${php.basedir.src}" />
+ <filterchain>
+ <replacestring from="@package_version@" to="${project.version}" />
+ </filterchain>
+ </copy>
+
+ <antcall target="copy-library-dir-if-exists">
+ <param name="output.dir" value="${-package:phar:builddir}" />
+ </antcall>
+
+ <antcall target="do-copy-files-for-xyz-archive">
+ <param name="output.dir" value="${-package:phar:builddir}" />
+ </antcall>
+ </target>
+
+ <!--
+ Primary ant target for the phar archive generation. This target will
+ generate the project's archive.
+ -->
+ <target name="-package:phar:main">
+ <exec dir="${basedir}"
+ failonerror="true"
+ executable="${scriptdir}/create.phar.php">
+
+ <arg line="${project.name}" />
+ <arg line="${-package:phar:filename}" />
+ <arg line="${-package:phar:builddir}" />
+ <arg line="${project.root}/${package.phar.bootstrap.file}" />
+ </exec>
+
+ <chmod file="${-package:phar:filename}" perm="755" />
+ </target>
+
+<!-- }}} PHAR SUPPORT -->
+
+<!-- {{{ PEAR SUPPORT -->
+
+ <!--
+ Enable pear package format by default
+ -->
+ <property name="package.pear.enabled" value="true" />
+
+ <!--
+ Creates a pear package of the project source
+ -->
+ <target name="package:pear"
+ if="-package:pear:is.enabled"
+ depends="prepare, -package:pear:is-enabled">
+
+ <antcall target="-package:pear" />
+ </target>
+
+ <!--
+ Tests if the pear package format is enabled for this project.
+ -->
+ <target name="-package:pear:is-enabled">
+ <condition property="-package:pear:is.enabled">
+ <istrue value="${package.pear.enabled}" />
+ </condition>
+ </target>
+
+ <!--
+ This target defines the main workflow required/used to generate a
+ pear package file.
+ -->
+ <target name="-package:pear"
+ depends="-package:pear:prepare,
+ -package:pear:before~hook,
+ -package:pear:main,
+ -package:pear:after~hook" />
+
+ <!--
+ Hook target that will be called before the pear package will be build.
+ -->
+ <target name="-package:pear:before~hook" />
+
+ <!--
+ Hook target that will be called after the pear package was build.
+ -->
+ <target name="-package:pear:after~hook" />
+
+ <!--
+ Initializes the required environment to generate pear package file.
+ -->
+ <target name="-package:pear:prepare"
+ depends="-package:pear:prepare-properties,
+ -package:pear:prepare-files,
+ -common-pear-prepare,
+ common-pear-channel-discover" />
+
+ <!--
+ Defines all properties required for pear package generation.
+ -->
+ <target name="-package:pear:prepare-properties">
+ <property name="package.pear.builddir" location="${builddir}/pear-archive" />
+ </target>
+
+ <!--
+ Copies all files required to generate the project's pear package.
+ -->
+ <target name="-package:pear:prepare-files">
+ <copy todir="${package.pear.builddir}/${project.dir}">
+ <fileset dir="${php.basedir.src}"/>
+ <fileset dir="${project.root}/bin">
+ <include name="**.sh" />
+ <include name="**.php" />
+ <include name="**.bat" />
+ </fileset>
+ </copy>
+
+ <antcall target="copy-docs-dir-if-exists">
+ <param name="output.dir" value="${package.pear.builddir}" />
+ </antcall>
+
+ <copy file="${basedir}/LICENSE" todir="${package.pear.builddir}" />
+ <copy file="${basedir}/CHANGELOG" todir="${package.pear.builddir}" />
+
+ <copy file="${project.root}/conf/package.xml" todir="${package.pear.builddir}">
+ <filterchain>
+ <replacestring from="${project.name}" to="${build.name}" />
+ <replacestring from='name="source"' to='name="${project.name}"' />
+ <replacestring from="1970-01-01" to="${build.date}" />
+ <replacestring from="0.0.0" to="${build.version}" />
+ <replacestring from="devel" to="${project.stability}" />
+ </filterchain>
+ </copy>
+
+ <antcall target="do-copy-files-for-xyz-archive">
+ <param name="output.dir" value="${package.pear.builddir}" />
+ </antcall>
+ </target>
+
+ <!--
+ Creates a pear archive of the project source
+ -->
+ <target name="-package:pear:main">
+ <exec dir="${distdir}" executable="pear" failonerror="true">
+ <arg line="-c" />
+ <arg line="${common-pear-config}" />
+ <arg line="package" />
+ <arg line="${package.pear.builddir}/package.xml" />
+ </exec>
+ </target>
+
+<!-- }}} PEAR SUPPORT -->
+
+<!-- {{{ ARCHIVE SUPPORT -->
+
+ <!--
+ Enable archive package format by default
+ -->
+ <property name="package.archive.enabled" value="true" />
+
+ <!--
+ Creates a archive package of the project source
+ -->
+ <target name="package:archive"
+ if="-package:archive:is.enabled"
+ depends="prepare, -package:archive:is-enabled">
+
+ <antcall target="-package:archive" />
+ </target>
+
+ <!--
+ Tests if the archive package format is enabled for this project.
+ -->
+ <target name="-package:archive:is-enabled">
+ <condition property="-package:archive:is.enabled">
+ <istrue value="${package.archive.enabled}" />
+ </condition>
+ </target>
+
+ <!--
+ This target defines the main workflow required/used to generate a
+ archive package file.
+ -->
+ <target name="-package:archive"
+ depends="-package:archive:prepare,
+ -package:archive:before~hook,
+ -package:archive:main,
+ -package:archive:after~hook" />
+
+ <!--
+ Hook target that will be called before the archive package will be build.
+ -->
+ <target name="-package:archive:before~hook" />
+
+ <!--
+ Hook target that will be called after the archive package was build.
+ -->
+ <target name="-package:archive:after~hook" />
+
+ <!--
+ Initializes the environment required to generated a project archive.
+ -->
+ <target name="-package:archive:prepare"
+ depends="-package:archive:prepare-properties,
+ -package:archive:prepare-files" />
+
+ <!--
+ Defines the properties required to generate a project archive.
+ -->
+ <target name="-package:archive:prepare-properties">
+ <property name="-package:archive:builddir" location="${builddir}/tar-archive" />
+ <property name="-package:archive:filename" location="${distdir}/${build.file}.tar.bz2" />
+ </target>
+
+ <target name="-package:archive:prepare-files">
+ <property name="output.dir" value="${-package:archive:builddir}/${build.file}" />
+
+ <copy todir="${output.dir}/source">
+ <fileset dir="${php.basedir.src}"/>
+ <filterchain>
+ <replacestring from="@package_version@" to="${project.version}" />
+ </filterchain>
+ </copy>
+
+ <antcall target="copy-optional-dirs">
+ <param name="output.dir" value="${output.dir}" />
+ </antcall>
+
+ <copy file="${basedir}/LICENSE" todir="${output.dir}" />
+ <copy file="${basedir}/CHANGELOG" todir="${output.dir}" />
+
+ <antcall target="do-copy-files-for-xyz-archive">
+ <param name="output.dir" value="${output.dir}" />
+ </antcall>
+ </target>
+
+ <!--
+ Creates a tar.bz2 archive of the project source
+ -->
+ <target name="-package:archive:main">
+ <tar basedir="${-package:archive:builddir}"
+ destfile="${distdir}/${build.file}.tar.bz2"
+ compression="bzip2"
+ longfile="gnu">
+
+ <include name="${build.file}/**" />
+ </tar>
+ </target>
+
+<!-- }}} ARCHIVE SUPPORT -->
+
+ <!--
+ Hook method for copying files for the project's xyz archive format.
+
+ Parameters:
+ output.dir Output directory for the temporary build tree.
+ -->
+ <target name="do-copy-files-for-xyz-archive">
+ <!-- Implement this target in the concrete project build.xml -->
+ </target>
+
+ <!--
+ Copies several optional directories into the output dir.
+
+ Parameters:
+ output.dir Output directory for the temporary build tree.
+ -->
+ <target name="copy-optional-dirs" depends="copy-library-dir-if-exists,copy-docs-dir-if-exists" />
+
+ <!--
+ Optionally copies a library directory into a temporary build tree.
+
+ Parameters:
+ output.dir Output directory for the temporary build tree.
+ -->
+ <target name="copy-library-dir-if-exists" depends="test-library-dir-exists,copy-library-dir" />
+
+ <!--
+ Checks if the current project contains a library folder with external
+ dependencies.
+ -->
+ <target name="test-library-dir-exists">
+ <available file="${basedir}/lib" property="library-dir-exists" />
+ </target>
+
+ <!--
+ Copies the library directory of the current project into a temporary
+ build source tree.
+
+ Parameters:
+ output.dir Output directory for the temporary build tree.
+ -->
+ <target name="copy-library-dir" if="library-dir-exists">
+ <property name="library.dir" value="${output.dir}/lib" />
+
+ <antcall target="~copy-library-dir-before">
+ <param name="output.dir" value="${output.dir}" />
+ <param name="library.dir" value="${library.dir}" />
+ </antcall>
+
+ <copy todir="${output.dir}/lib">
+ <fileset dir="${basedir}/lib" />
+ </copy>
+
+ <antcall target="~copy-library-dir-after">
+ <param name="output.dir" value="${output.dir}" />
+ <param name="library.dir" value="${library.dir}" />
+ </antcall>
+ </target>
+
+ <!--
+ Hook that will be called before we copy the project's library directory.
+
+ Parameters:
+ output.dir Output directory for the temporary build tree.
+ library.dir The library directory in the temporary build tree.
+ -->
+ <target name="~copy-library-dir-before" />
+
+ <!--
+ Hook that will be called after we have copied the project's library
+ directory.
+
+ Parameters:
+ output.dir Output directory for the temporary build tree.
+ library.dir The library directory in the temporary build tree.
+ -->
+ <target name="~copy-library-dir-after" />
+
+ <!--
+ Optionally copies a documentation directory into a temporary build
+ source tree.
+
+ Parameters:
+ output.dir Output directory for the temporary build tree.
+ -->
+ <target name="copy-docs-dir-if-exists" depends="test-docs-dir-exists,copy-docs-dir" />
+
+ <!--
+ Checks if the current project has a document directory.
+ -->
+ <target name="test-docs-dir-exists">
+ <available file="${basedir}/docs" property="docs-dir-exists" />
+ </target>
+
+ <!--
+ Copies the documentation directory of the current project into a
+ temporary build source tree
+
+ Parameters:
+ output.dir Output directory for the temporary build tree.
+ -->
+ <target name="copy-docs-dir" if="docs-dir-exists">
+ <copy todir="${output.dir}/docs">
+ <fileset dir="${basedir}/docs" />
+ <filterchain>
+ <replacestring from="__DIR__ . '/../../source" to="'${project.name}" />
+ </filterchain>
+ </copy>
+ </target>
+
+</project>
View
57 test.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<project name="ant-build-commons-test">
+
+ <description>
+ This is ant file contains targets that will execute the projects unit
+ tests.
+ </description>
+
+ <!--
+ Declare basedir for commons pear
+ -->
+ <dirname property="-test:basedir" file="${ant.file.ant-build-commons-test}" />
+
+ <!--
+ Import the parent target file.
+ -->
+ <import file="compile.xml" />
+
+ <!--
+ Creates different binary releases of the current project.
+ -->
+ <target name="test"
+ depends="compile, -test"
+ description="-> Runs the unit tests for the project." />
+
+
+ <target name="-test"
+ depends="-test:before~hook,
+ -test:test,
+ -test:after~hook" />
+
+ <!--
+ Hook target that will be called by the build framework before it starts
+ the project's unittests.
+ -->
+ <target name="-test:before~hook" />
+
+ <!--
+ Hook target that will be called by the build framework after it has
+ executed the project's unittests.
+ -->
+ <target name="-test:after~hook" />
+
+ <!--
+ Executes the project's unittests.
+ -->
+ <target name="-test:test">
+ <exec dir="${basedir}" failonerror="true" executable="phpunit">
+ <arg value="--group" />
+ <arg value="unittest" />
+ <arg value="--log-junit" />
+ <arg value="${logsdir}/junit.xml" />
+ <arg value="${phpunit.testsuite.class}" />
+ <arg value="${php.basedir.test}/${phpunit.testsuite.file}" />
+ </exec>
+ </target>
+</project>
View
128 verify.xml
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<project name="ant-build-commons-verify" basedir="..">
+
+ <description>
+ This is ant file contains targets for different static analysis and
+ quality checks used for the project source.
+ </description>
+
+ <!--
+ Declare basedir for the verify build file.
+ -->
+ <dirname property="-verify:basedir" file="${ant.file.ant-build-commons-verify}" />
+
+ <!--
+ Import the parent target file.
+ -->
+ <import file="integration-test.xml" />
+
+ <!--
+ Verifies that the source is valid and meets quality criterias.
+ -->
+ <target name="verify"
+ depends="integration-test, -verify"
+ description="-> Verifies that the source is valid and meets quality criterias." />
+
+ <!--
+ Internal verify implementation that defines the main workflow of the
+ verify target.
+ -->
+ <target name="-verify"
+ depends="-verify-before~hook,
+ -verify:verify,
+ -verify-after~hook" />
+
+ <!--
+ Hook target that will be called before the main verification phase
+ of the project's source starts.
+ -->
+ <target name="-verify-before~hook" />
+
+ <!--
+ Hook target that will be called after the main verification phase
+ of the project's source has finished.
+ -->
+ <target name="-verify-after~hook" />
+
+ <!--
+ This target calls several quality tools parallel and generates the
+ different reports.
+ -->
+ <target name="-verify:verify">
+ <parallel>
+ <antcall target="-verify:coverage" />
+ <antcall target="-verify:checkstyle" />
+ <antcall target="-verify:phpcpd" />
+ <antcall target="-verify:phploc" />
+ <sequential>
+ <antcall target="-verify:pdepend" />
+ <antcall target="-verify:phpmd" />
+ </sequential>
+ </parallel>
+ </target>
+
+ <!--
+ Executes all project tests and collects
+ -->
+ <target name="-verify:coverage">
+ <exec dir="${basedir}" failonerror="true" executable="phpunit">
+ <arg value="--coverage-html" />
+ <arg value=" ${builddir}/coverage" />
+ <arg value="--coverage-clover" />
+ <arg value="${logsdir}/clover.xml" />
+ <arg value="--log-junit" />
+ <arg value="${logsdir}/junit.xml" />
+ <arg value="${phpunit.testsuite.class}" />
+ <arg value="${php.basedir.test}/${phpunit.testsuite.file}" />
+ </exec>
+ </target>
+
+ <!--
+ Validates that the project code is compatible with the project's coding
+ conventions.
+ -->
+ <target name="-verify:checkstyle">
+ <exec dir="${basedir}" failonerror="true" executable="phpcs">
+ <arg line="--standard=${coding.standard}" />
+ <arg line="--report=checkstyle" />
+ <arg line="--report-file=${logsdir}/checkstyle.xml" />
+ <arg line="${php.basedir.src}" />
+ </exec>
+ </target>
+
+ <target name="-verify:phpmd">
+ <exec dir="${basedir}" executable="phpmd" failonerror="false">
+ <arg line="${php.basedir.src}" />
+ <arg line="xml" />
+ <arg line="codesize,unusedcode,naming,design" />
+ <arg line="--reportfile ${logsdir}/pmd.xml" />
+ </exec>
+ </target>
+
+ <target name="-verify:pdepend">
+ <exec dir="${basedir}" executable="pdepend" failonerror="false">
+ <arg line="--summary-xml=${logsdir}/pdepend.xml" />
+ <arg line="--jdepend-xml=${logsdir}/jdepend.xml" />
+ <arg line="${php.basedir.src}" />
+ </exec>
+ </target>
+
+ <target name="-verify:phpcpd">
+ <exec dir="${basedir}" executable="phpcpd" failonerror="false">
+ <arg line="--log-pmd ${logsdir}/cpd.xml" />
+ <arg line="${php.basedir.src}" />
+ </exec>
+ </target>
+
+ <target name="-verify:phploc">
+ <exec dir="${basedir}" executable="phpcpd" failonerror="false">
+ <arg value="--count-tests" />
+ <arg value="--log-xml" />
+ <arg value="${logsdir}/phploc.xml" />
+ <arg value="--log-csv" />
+ <arg value="${logsdir}/phploc.csv" />
+ <arg value="${php.basedir.src}" />
+ </exec>
+ </target>
+
+</project>

0 comments on commit 0a30d6c

Please sign in to comment.