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
[u]nawk[/u] '{if (/^\${HERE}/[u]){system("cat tmp.file")}[/u] 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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值