Hi all,
Sorry for being late for update you. I sent this to the mailing list but
unfortunately it bounced back.
Last week of time I was working on creating a bash script which use to
change the exiting folder structure in to the new test/code separated
structure.
Here I had to address few different issues.
1. Creating the main/java and test/java folders in the src directory and put
test files in test/java and rest in the main/java
I did this by putting the tests in the test folders in each module in the
test/java folder. I used the following code to do that. $test variable is
the folder structure of each module.
cp main/java/$test/test/* test/java/$test/
rm -r main/java/$test/test/
2. Fixing the paths in the macros.xml file. This was achieved by the
following piece of code.
sed 's/@{prefix}src/@{prefix}src\/main\/java/' <macros.xml >temp
cat temp >macros.xml
rm temp
3. Fixing the paths in build.xml files. This was achieved by first replacing
all the paths by adding main/java/ to the baginning of each path and then
changing it with test/java if it is a test. You can see the code follows.
Also some package name the files also change when it needed to do so.
for x in $(ls main/java/$test/test/)
do
echo $x
sed 's/\.test;/;/' <main/java/$test/test/$x >temp
cat temp >main/java/$test/test/$x
j=`expr "$test" : 'org/ofbiz/base'`
if [ $j != 0 ];
then
sed 's/\.test\./\./' <main/java/$test/test/$x >temp
cat temp >main/java/$test/test/$x
fi
echo $test
sed "s#main/java/${test}test/#test/java/${test}#g" <../build.xml >temp
# ./org/ofbiz does not match
cat temp >../build.xml
done
rm temp
4. Remove the package names which include ".test." from the files. I went
through all the xml files and found out the places where it needed the
changes and hard coded since we dont need to go through every files for
changing small number of files in some of the modules(framework/service,
framework/minilang, framework/entity, framework/base,
application/securityext, application/product, application/order,
application/content, application/accounting). You can find the code follows.
if [ $dir = 'service' ];
then
sed 's/\.test\./\./'
<servicedef/services_test_se.xml >temp
cat temp >servicedef/services_test_se.xml
sed 's/\.test\./\./' <testdef/servicetests.xml >temp
cat temp >testdef/servicetests.xml
elif [ $dir = 'minilang' ];
then
sed 's/\.test\./\./' <testdef/MinilangTests.xml
>temp
cat temp >testdef/MinilangTests.xml
elif [ $dir = 'entity' ];
then
sed 's/\.test\./\./' <testdef/entitytests.xml >temp
cat temp >testdef/entitytests.xml
elif [ $dir = 'base' ];
then
sed 's/\.test\./\./' <build.xml >temp
cat temp >build.xml
sed 's/\.test\./\./' <config/test-containers.xml
>temp
cat temp >config/test-containers.xml
sed 's/\.test\./\./' <testdef/basetests.xml >temp
cat temp >testdef/basetests.xml
elif [ $dir = 'securityext' ];
then
sed 's/\.test\./\./' <testdef/securitytests.xml
>temp
cat temp >testdef/securitytests.xml
sed 's/\.test\./\./'
<testdef/data/SecurityTestData.xml >temp
cat temp >testdef/data/SecurityTestData.xml
elif [ $dir = 'product' ];
then
sed 's/\.test\./\./' <testdef/FacilityTest.xml >temp
cat temp >testdef/FacilityTest.xml
elif [ $dir = 'order' ];
then
sed 's/\.test\./\./' <servicedef/services.xml >temp
cat temp >servicedef/services.xml
sed 's/\.test\./\./' <testdef/OrderTest.xml >temp
cat temp >testdef/OrderTest.xml
elif [ $dir = 'content' ];
then
sed 's/\.test\./\./' <testdef/lucenetests.xml >temp
cat temp >testdef/lucenetests.xml
elif [ $dir = 'accounting' ];
then
sed 's/\.test\./\./' <testdef/accountingtests.xml
>temp
cat temp >testdef/accountingtests.xml
fi
If you have any suggestions or any input to improve the script please let me
know. You can find the full script in [1].
--
thanks
Ganath
[1]. https://github.com/ganathr/ofbiz/blob/trunk/old2new.sh