You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2014/10/16 21:35:32 UTC
svn commit: r1632421 - in /ofbiz/trunk: build.xml common.xml
Author: jleroux
Date: Thu Oct 16 19:35:32 2014
New Revision: 1632421
URL: http://svn.apache.org/r1632421
Log:
Implements https://issues.apache.org/jira/browse/OFBIZ-5819 "Improve the build-dev ant target"
Modified:
ofbiz/trunk/build.xml
ofbiz/trunk/common.xml
Modified: ofbiz/trunk/build.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/build.xml?rev=1632421&r1=1632420&r2=1632421&view=diff
==============================================================================
--- ofbiz/trunk/build.xml (original)
+++ ofbiz/trunk/build.xml Thu Oct 16 19:35:32 2014
@@ -262,12 +262,10 @@ under the License.
<!-- ================================================================== -->
<!-- Apply patches where needed -->
<!-- ================================================================== -->
-
-
- <target name="build-dev"
- description="Patch sources in a dev environment if patch files are present in runtime/patches. Needs a Subversion client installed">
- <!-- patch task can't handle a fileset => create a global patch -->
+ <target name="build-dev"
+ description="Patch sources in a dev environment if patch files are present in runtime/patches.">
+ <!-- Ant patch task can't handle a fileset => create a global patch -->
<concat destfile="${basedir}/runtime/patches/dev.patch" encoding="UTF-8" outputencoding="UTF-8">
<fileset dir="${basedir}/runtime/patches" casesensitive="no">
<exclude name="dev.patch"/> <!-- exclude the patch itself in case it's still there -->
@@ -277,20 +275,71 @@ under the License.
<if>
<available file="${basedir}/runtime/patches/dev.patch"/>
<then>
- <exec executable="svn" dir="${basedir}">
- <arg value="patch"/>
- <arg value="${basedir}/runtime/patches/dev.patch"/>
- </exec>
- <delete>
- <fileset dir="${basedir}/runtime/patches" includes="dev.patch"/>
- </delete>
+ <antcall target="patch">
+ <param name="dir-name" value="${basedir}"/>
+ <param name="diff-file" value="${basedir}/runtime/patches/dev.patch"/>
+ </antcall>
+ <delete file="${basedir}/runtime/patches/dev.patch"/>
</then>
</if>
</target>
+ <!-- Following allow to use "svn patch" and fallback on "patch" if necessary -->
+ <target name="calculate-svn-patch-available">
+ <mkdir dir="build/svn-check"/>
+ <exec dir="build/svn-check" output="build/svn-check/svn.output" executable="svn" failonerror="true">
+ <arg value="--version" />
+ </exec>
+ <loadfile property="svn-output" srcFile="build/svn-check/svn.output"/>
+ <condition property="svn-version-ok">
+ <!-- On Linux prefer patch because "svn patch" needs "ant exec and you can't check patching errors -->
+ <and>
+ <os family="windows"/>
+ <or>
+ <!-- This might also depend on the format of the working copy -->
+ <contains string="${svn-output}" substring="1.7."/>
+ <contains string="${svn-output}" substring="1.8."/>
+ <contains string="${svn-output}" substring="1.9."/>
+ <contains string="${svn-output}" substring="1.10."/>
+ <contains string="${svn-output}" substring="1.11."/>
+ </or>
+ </and>
+ </condition>
+ <delete dir="build/svn-check"/>
+ </target>
+
+ <target name="calculate-patch-available" depends="calculate-svn-patch-available" unless="svn-version-ok">
+ <condition property="patch-ok">
+ <os family="unix"/>
+ </condition>
+ </target>
+
+ <target name="check-svn-patch-available" depends="calculate-svn-patch-available" unless="svn-version-ok">
+ <echo message="You need svn version 1.7 or higher - attempting patch instead."/>
+ </target>
+
+ <target name="check-patch-available" depends="calculate-patch-available" unless="patch-ok"/>
+
+ <target name="patch-via-svn" depends="check-svn-patch-available" if="svn-version-ok">
+ <exec dir="${basedir}" executable="svn" failonerror="true">
+ <arg value="patch" />
+ <arg value="${diff-file}" />
+ <arg value="${dir-name}" />
+ </exec>
+ </target>
+
+ <target name="patch-via-patch" depends="check-patch-available" if="patch-ok">
+ <exec dir="${basedir}" executable="patch" input="${diff-file}" failonerror="true">
+ <arg value="--binary" /><!-- To prevent EOL issues which comes when using mixed development platforms (ie Unix and Win) -->
+ <arg value="-p0" />
+ </exec>
+ </target>
+
+ <target name="patch" depends="patch-via-svn,patch-via-patch"/>
+
<target name="build-test"
description="Patch and build all sources for use in a test environment. On Windows you need to have patch.exe in the path and patch files must all be in dos format (CR+LF)">
- <subant inheritall="false" target="prepare-to-build-test">
+ <subant inheritall="false" target="prepare-to-build-test" failonerror="true">
<fileset dir="${basedir}/hot-deploy" casesensitive="no">
<exclude name="disabled/**"/>
<include name="*/build.xml"/>
@@ -301,7 +350,7 @@ under the License.
<target name="build-qa"
description="Patch and build all sources for use in a qa environment. On Windows you need to have patch.exe in the path and patch files must all be in dos format (CR+LF)">
- <subant inheritall="false" target="prepare-to-build-qa">
+ <subant inheritall="false" target="prepare-to-build-qa" failonerror="true">
<fileset dir="${basedir}/hot-deploy" casesensitive="no">
<exclude name="disabled/**"/>
<include name="*/build.xml"/>
@@ -312,7 +361,7 @@ under the License.
<target name="build-production"
description="Patch and build all sources for use in a live environment. On Windows you need to have patch.exe in the path and patch files must all be in dos format (CR+LF)">
- <subant inheritall="false" target="prepare-to-build-production">
+ <subant inheritall="false" target="prepare-to-build-production" failonerror="true">
<fileset dir="${basedir}/hot-deploy" casesensitive="no">
<exclude name="disabled/**"/>
<include name="*/build.xml"/>
Modified: ofbiz/trunk/common.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/common.xml?rev=1632421&r1=1632420&r2=1632421&view=diff
==============================================================================
--- ofbiz/trunk/common.xml (original)
+++ ofbiz/trunk/common.xml Thu Oct 16 19:35:32 2014
@@ -162,10 +162,10 @@ under the License.
<!--
This macro applies all patches found in ./patches/@{deployment} relative to ${ofbiz.home.dir}
and stops the build process if patches fail (to save time deleting all the rejects)
+ We use patch command here instead of svn patch because it's supposed to run in a server where patch is intalled in path
-->
<macrodef name="apply-patches">
<attribute name="deployment" default="dev" />
-
<sequential>
<!-- patch task can't handle a fileset => create a global patch -->
<if>
@@ -175,13 +175,11 @@ under the License.
<!-- exclude the patch itself in case it's still there -->
<fileset dir="patches" includes="@{deployment}/*.patch"/>
</concat>
-
- <patch strip="0" patchfile="patches/@{deployment}.patch" dir="${ofbiz.home.dir}"/>
-
+ <patch strip="0" patchfile="patches/@{deployment}.patch" dir="${ofbiz.home.dir}" failonerror="true"/>
<delete>
<fileset dir="patches" includes="@{deployment}.patch"/>
</delete>
- </then>
+ </then>
</if>
</sequential>
</macrodef>