Awk practise

1. Objective:

Create build.xml for ant, from a pre-defined template file.
One of the token should be replace by lines, which come from JAVA jar file. We should extract it and get the EJB xml discriptor.

Prepare a build tree.

2. Source:

#!/bin/ksh
module=$1
echo About to process module: $module
if [ ! -e "/export/home/liutuo/jars/${module}_ejb2.jar" ] ; then echo $module not found! ; exit 1 ;fi
mkdir -p $module
cd $module
mkdir -p EjbDescriptor JaveSource ExternalJars tmp
sed -e "s/\${JAR}/$module/g" ../template/build.properties >build.properties
unzip -t /export/home/liutuo/jars/${module}_ejb2.jar \
| grep Home.class \
| sed 's/\//./g' \
| sed 's/testing: /<arg line="/g' \
| sed 's/\.class   OK/"\/>/'> tmp.file
nawk '{if (/^\${HERE}/ ){system("cat tmp.file")} else {print}}' ../template/build.xml > build.xml
rm tmp.file
cd tmp
unzip -x -qq /export/home/liutuo/jars/${module}_ejb2.jar >/dev/null
cd META-INF
mv *.xml ../../EjbDescriptor
cd ../../
rm -rf tmp

你可能感兴趣的:(xml,ant,qq,ejb)