Author: jleroux
Date: Mon Mar 17 21:56:45 2014
New Revision: 1578621
URL: http://svn.apache.org/r1578621
Log:
Adds new ant targets to handled patching in projects which use different
staging areas.
In create-component ant target at r1150560+1571994+r1571996 I added staging, qa
and production sub-folders under patches folder.
The reason is to allow to put there patches for different staging areas where
URLs and other parameters vary.
Then I did not add related ant targets to allow patching the corresponding
OFBiz instances in the different staging areas servers.
Also I wrongly named the "test" area "staging".
Let me explain quickly how it supposed to work. You have:
1) A "dev" environment/area (most of the time on developers own machines) where
the development is done, maybe using Derby DB for instance. Anyway an area
where all production constraints are not yet taken into account.
2) A "test" area, something like the "dev" area but with a different
environment (clustered, not the same DB, etc.) something not yet similar to
production but near. Because most of the time you don't have yet a production
area ready when you begin to test. This area remains in the hand of
developpers. Load tests for instance can be done there.
3) A "QA" area, this comes later and is a duplicate of the production area
where all tests are finally done. It's in the hand of QA engineers who
qualify/guarantee the development to be production ready.
4) A "production" area, this is the latest stage available when the development
is production ready (though it might appears before QA sometimes when the
shareholders are in a hurry...). It's in the hand of sysops (or devops if you
prefer).
So this patch adds the "build-test", "build-qa" and "build-production" targets
in the main build.xml file. For the purpose of adapting the areas when building
they calls the main build targets, but the build target does not depend on
them, so can still be used w/o them. They complete the
"create|apply|reapply|revert-ofbiz-patches" targets which target only the "dev"
area or can be used in an early stage of the development, notably on dev
machines.
Those targets depends on the "prepare-to-build-dev", "prepare-to-build-test",
"prepare-to-build-qa" and "prepare-to-build-production" targets in common.xml.
Themselves relying on the macro "apply-patches".
The "prepare-to-build-qa|production" have something specific. When you maintain
URLs and misc. parameters variation inside properties files, it's often easier
to directly maintain those files and copy them over in those areas than
maintaining/updating patches for them which can be a repetitive and tedious
task...
Moreover, sometimes you don't even create any hot-deploy components (eg. some
projects might use OFBiz as a web services API). Then currently you don't have
an easy way to keep your OFBiz working copy free from modifications (which
could else been put in one of your hot-deploy components patches directory,
which is anyway not very logical). So I created another ant target "build-dev",
it's purposely independent of any other target but relies on the content of a
new runtime/patches folder where "core" patches (those which change OFBiz as
it's OOTB)are supposed to be.
These changes add new possibilities but don't change the way things were done
so far. So you can use them or not depending on your needs. The idea for the
new "build-dev" ant target is to keep patches with features separated (ie
grouping different files changed in a patch), but you can, or may have to, do
it on a file level, notably when 2 or more features impact the same file...
Added:
ofbiz/trunk/runtime/patches/
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=1578621&r1=1578620&r2=1578621&view=diff
==============================================================================
--- ofbiz/trunk/build.xml (original)
+++ ofbiz/trunk/build.xml Mon Mar 17 21:56:45 2014
@@ -219,9 +219,68 @@ under the License.
</target>
<!-- ================================================================== -->
- <!-- Build Components -->
+ <!-- Apply patches where needed -->
<!-- ================================================================== -->
+ <target name="build-dev"
+ description="Patch and build all sources in a dev environment. This
includes patching OFBiz using patches in runtime/patches. On Windows you need
to have patch.exe in the path and patch files must all be in dos format
(CR+LF)">
+ <!-- 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 -->
+ <include name="*.patch"/>
+ </fileset>
+ </concat>
+ <if>
+ <resourceexists>
+ <file file="${basedir}/runtime/patches/dev.patch"/>
+ </resourceexists>
+ <then>
+ <patch strip="0"
patchfile="${basedir}/runtime/patches/dev.patch" dir="${basedir}"/>
+ <delete>
+ <fileset dir="${basedir}/runtime/patches"
includes="dev.patch"/>
+ </delete>
+ </then>
+ </if>
+ </target>
+
+ <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">
+ <fileset dir="${basedir}/hot-deploy" casesensitive="no">
+ <exclude name="disabled/**"/>
+ <include name="*/build.xml"/>
+ </fileset>
+ </subant>
+ <antcall target="build"/>
+ </target>
+
+ <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">
+ <fileset dir="${basedir}/hot-deploy" casesensitive="no">
+ <exclude name="disabled/**"/>
+ <include name="*/build.xml"/>
+ </fileset>
+ </subant>
+ <antcall target="build"/>
+ </target>
+
+ <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">
+ <fileset dir="${basedir}/hot-deploy" casesensitive="no">
+ <exclude name="disabled/**"/>
+ <include name="*/build.xml"/>
+ </fileset>
+ </subant>
+ <antcall target="build"/>
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Build Components -->
+ <!-- ================================================================== -->
+
<target name="build" depends="ofbiz-init">
<echo message="[build] ========== Start Building (Compile)
=========="/>
@@ -1178,6 +1237,7 @@ under the License.
<echo>======================================================</echo>
<echo>Please check that this version is appropriate for you!</echo>
</target>
+ <mkdir dir="${basedir}/hot-deploy/${component-name}/patches/qa"/>
<target name="download-sonar-ant-task" description="Download sonar related
files">
<ivy:retrieve pattern="framework/base/lib/[artifact]-[revision].[ext]"
conf="sonar-ant-task"/>
@@ -1248,7 +1308,7 @@ under the License.
<mkdir dir="${basedir}/hot-deploy/${component-name}/entitydef"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/lib"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/patches"/>
- <mkdir dir="${basedir}/hot-deploy/${component-name}/patches/staging"/>
+ <mkdir dir="${basedir}/hot-deploy/${component-name}/patches/test"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/patches/qa"/>
<mkdir
dir="${basedir}/hot-deploy/${component-name}/patches/production"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/script"/>
Modified: ofbiz/trunk/common.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/common.xml?rev=1578621&r1=1578620&r2=1578621&view=diff
==============================================================================
--- ofbiz/trunk/common.xml (original)
+++ ofbiz/trunk/common.xml Mon Mar 17 21:56:45 2014
@@ -164,4 +164,71 @@ under the License.
</target>
<target name="all" depends="jar,docs"/>
+
+ <!-- ================================================================== -->
+ <!-- Apply patches if exist -->
+ <!-- ================================================================== -->
+ <!--
+ 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)
+ -->
+ <macrodef name="apply-patches">
+ <attribute name="deployment" default="dev" />
+
+ <sequential>
+ <!-- patch task can't handle a fileset => create a global patch -->
+ <if>
+ <available file="patches"/>
+ <then>
+ <concat destfile="patches/@{deployment}.patch"
encoding="UTF-8" outputencoding="UTF-8">
+ <!-- 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}"/>
+
+ <delete>
+ <fileset dir="patches" includes="@{deployment}.patch"/>
+ </delete>
+ </then>
+ </if>
+ </sequential>
+ </macrodef>
+
+ <target name="prepare-to-build-dev"
+ description="Does everything needed to get you a ready to start
building OFBiz for development. This include generic patches for OFBiz itself,
not only hot-deploy components">
+ <apply-patches deployment="dev" />
+ </target>
+
+ <target name="prepare-to-build-test"
+ description="Does everything needed to get you a ready to start
building OFBiz for integration testing">
+ <apply-patches deployment="test" />
+ </target>
+
+ <target name="prepare-to-build-qa"
+ description="Does everything needed to get you a ready to start
building OFBiz in QA-Environment">
+ <apply-patches deployment="qa" />
+
+ <!-- need to use flatten here as qa dir might not exist and thus can't
be included in "dir" -->
+ <copy toDir="config/" overwrite="true" flatten="true">
+ <fileset dir="patches" includes="qa/*.properties"/>
+ </copy>
+ </target>
+
+ <target name="prepare-to-build-production"
+ description="Does everything needed to get you a ready to start
building OFBiz in production">
+ <apply-patches deployment="production" />
+
+ <!-- need to use flatten here as production dir might not exist and
thus can't be included in "dir" -->
+ <copy toDir="config/" overwrite="true" flatten="true">
+ <fileset dir="patches" includes="production/*.properties"/>
+ </copy>
+ <!-- Some files might need to be deleted in production, notably some
specific script files -->
+ <!--exec executable="svn" dir="${ofbiz.home.dir}">
+ <arg value="delete"/>
+ <arg value="filename.sh"/>
+ </exec-->
+ </target>
+
+
</project>