Permalink
Browse files

Merge pull request #4 from Qafoo/feat/phplint

PHPLint should be moved to its own extension
  • Loading branch information...
2 parents 75e0bb3 + 57f7753 commit fd2228f7c4622a1ed49dffe9143f2ea524d5e3ab @jakobwesthoff jakobwesthoff committed May 30, 2012
@@ -1,5 +0,0 @@
-# Default filename for the compile cache
-compile.cachefile = ${commons.metadata.cache.dir}/compile.cache
-
-# Default compile log location
-compile.logfile = ${commons:logsdir}/compile.log
@@ -6,6 +6,7 @@ package.archive.enabled = true
; Their names should be selfexplanatory
;;;
+phplint.enabled = true
codesniffer.enabled = true
pdepend.enabled = true
phpcb.enabled = true
@@ -0,0 +1,2 @@
+phplint.cachefile = ${commons.metadata.cache.dir}/phplint.cache
+phplint.logfile = ${commons:logsdir}/phplint.log
View
@@ -29,65 +29,21 @@
<target name="compile:compile"
depends="initialize,
-compile:before~hook,
- -compile:compile,
+ -compile:main~hook,
+ -compile:fail-build-on-compile-error,
-compile:after~hook" />
<!--
- Internal target that defines the primary workflow of this build component.
- -->
- <target name="-compile:compile"
- depends="-compile:source-and-test-files,
- -compile:fail-build-on-compile-error" />
-
- <!--
- Compiles all source and test source files of the current project.
- -->
- <target name="-compile:source-and-test-files">
- <apply executable="${commons.executable.php}"
- failonerror="false"
- errorproperty="commons:out-error"
- append="true"
- output="${compile.logfile}">
- <arg value="-l" />
- <fileset dir="${commons.srcdir.php}" erroronmissingdir="false">
- <include name="**/*.php" />
- <modified>
- <param name="cache.cachefile" value="${compile.cachefile}" />
- </modified>
- </fileset>
- <fileset dir="${commons.testdir.php}" erroronmissingdir="false">
- <include name="**/*.php" />
- <exclude name="**/_source/**" />
- <exclude name="**/_files/**" />
- <exclude name="**/_code/**" />
- <exclude name="**/_fixture/**" />
- <exclude name="**/_fixtures/**" />
- <modified>
- <param name="cache.cachefile" value="${compile.cachefile}" />
- </modified>
- </fileset>
- </apply>
- </target>
-
- <!--
Lets the build fail when a compilation error occurred.
-->
- <target name="-compile:fail-build-on-compile-error">
+ <target name="-compile:fail-build-on-compile-error"
+ if="commons:out-error">
<antcall target="commons:fail-build-on-error">
<param name="commons:in-error-result" value="${commons:out-error}" />
</antcall>
</target>
<!--
- Deletes the temporary compile cache when an error occurred during the
- compilation process.
- -->
- <target name="-compile:delete-cache-on-compile-error~hooked"
- extensionOf="-commons:fail-build-on-error-before~hook">
- <delete file="${compile.cachefile}" />
- </target>
-
- <!--
EXTENSION POINTS FOR THE COMPILE MODULE
-->
@@ -98,6 +54,13 @@
<extension-point name="-compile:before~hook" />
<!--
+ This extension point will be called before during the main compile
+ phase. It is the right point to register all different kinds of compile
+ steps.
+ -->
+ <extension-point name="-compile:main~hook" />
+
+ <!--
This extension point will be called after the source compile process
has finished.
-->
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="ant-build-commons-extensions-phplint" basedir=".">
+ <!--
+ Import default properties for this extension.
+ -->
+ <property file="${resourcedir}/extensions/phplint/phplint.properties" />
+
+ <!--
+ Import utilized extensions
+ -->
+ <import file="enabled.xml" />
+ <import file="availability.xml" />
+
+ <!--
+ Shortcut for the "phplint:phplint" target
+ -->
+ <target name="phplint" depends="phplint:phplint" />
+
+ <!--
+ External entrypoint
+ -->
+ <target name="phplint:phplint"
+ depends="availability:php-srcdir-is-available"
+ if="availability:php-srcdir-is-available">
+ <common.enabled.antcall target="-phplint:phplint"
+ property="phplint.enabled" />
+ </target>
+
+ <!--
+ Runs the linter check of php against the project source code.
+ -->
+ <target name="-phplint:phplint"
+ depends="-phplint:before~hook,
+ -phplint:run,
+ -phplint:delete-cache-on-error-and-bail-out,
+ -phplint:after~hook" />
+
+ <!--
+ Compiles all source and test source files of the current project.
+ -->
+ <target name="-phplint:run">
+ <delete file="${phplint.logfile}" />
+
+ <apply executable="${commons.executable.php}"
+ failonerror="false"
+ parallel="false"
+ output="${phplint.logfile}"
+ error="${phplint.logfile}"
+ errorproperty="-phplint:error-output"
+ append="true">
+ <arg value="-l" />
+ <fileset dir="${commons.srcdir.php}" erroronmissingdir="false">
+ <include name="**/*.php" />
+ <modified>
+ <param name="cache.cachefile" value="${phplint.cachefile}" />
+ </modified>
+ </fileset>
+ <fileset dir="${commons.testdir.php}" erroronmissingdir="false">
+ <include name="**/*.php" />
+ <exclude name="**/_source/**" />
+ <exclude name="**/_files/**" />
+ <exclude name="**/_code/**" />
+ <exclude name="**/_fixture/**" />
+ <exclude name="**/_fixtures/**" />
+ <modified>
+ <param name="cache.cachefile" value="${phplint.cachefile}" />
+ </modified>
+ </fileset>
+ </apply>
+ </target>
+
+ <!--
+ Check whether an error during linting execution occured or not.
+ Setting ${-phplint:execution-error-has-occured} if something went
+ wrong
+ -->
+ <target name="-phplint:has-execution-error-occured">
+ <condition property="-phplint:execution-error-has-occured">
+ <not>
+ <equals arg1="${-phplint:error-output}"
+ arg2=""
+ trim="true" />
+ </not>
+ </condition>
+ </target>
+
+ <!--
+ Check whether the linting failed or not and delete the metadata cache
+ if it did. Otherwise a newly started linting run wouldn't yield any
+ error anymore.
+
+ Furthermore this targets fails the build if an error occurred.
+ -->
+ <target name="-phplint:delete-cache-on-error-and-bail-out"
+ depends="-phplint:has-execution-error-occured"
+ if="-phplint:execution-error-has-occured">
+ <delete file="${phplint.cachefile}" />
+ <fail message="${-phplint:error-output}" />
+ </target>
+
+
+ <!--
+ Extension points of this module
+ -->
+ <extension-point name="-phplint:before~hook" />
+ <extension-point name="-phplint:after~hook" />
+
+ <!--
+ Hook this extension into the compile step
+ -->
+ <target name="-phplint:compile:main~hooked"
+ extensionOf="-compile:main~hook"
+ depends="phplint:phplint" />
+</project>

0 comments on commit fd2228f

Please sign in to comment.