设为首页
收藏本站
用户名
Email
自动登录
找回密码
密码
登录
注册
快捷导航
平台
Portal
论坛
BBS
文库
项目
群组
Group
我的博客
Space
搜索
搜索
热搜:
shell
linux
mysql
本版
用户
LinuxSir.cn,穿越时空的Linuxsir!
»
论坛
›
Linux 综合讨论区 —— LinuxSir.cn
›
shell进阶应用、shell编程
›
写了个build java工程的
返回列表
查看:
622
|
回复:
1
写了个build java工程的
[复制链接]
rainytooo
rainytooo
当前离线
积分
143
IP卡
狗仔卡
发表于 2009-4-2 19:44:32
|
显示全部楼层
|
阅读模式
实在是受够了ant 和 maven
于是自己写了一个
#!/bin/bash
## java project builder tools
## create date 2009-04-02
## version 0.0.1
### define the source dir
java_file_sources_dir=src
out_put_dir=bin
lib_directory=lib
###define the JAVA_HOME and PATH CLASSPATH if you needed
#JAVA_HOME=/usr/lib/java/jdk1.6.0_11
#PATH=$JAVA_HOME/bin:$PATH
export LANG=zh_CN.UTF-8
CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:"$out_put_dir/":"$java_file_sources_dir"
for jar in `ls $lib_directory/*.jar`
do
CLASSPATH="$CLASSPATH:""$jar"
done
echo -e '\E[31;48m'"\033[1m **************************** build xmhi backgroud project start **************************** \033[0m"
echo -e '\E[32;48m'"\033[1m JAVA_HOME : \033[0m" $JAVA_HOME
echo -e '\E[32;48m'"\E[1m CLASSPATH : \E[0m" $CLASSPATH
echo -e '\E[32;48m'"\E[1m PATH : \E[0m" $PATH
clear_bin()
{
echo -e '\E[33;48m'"\033[1m start to clear project ...... \033[0m"
if [ -e $out_put_dir ] ; then
rm -rf "$out_put_dir"
mkdir "$out_put_dir"
else
mkdir "$out_put_dir"
fi
}
## compile all the java source in the source dirctory to the output directory you defined
compile_source()
{
# init a array for the all java source folder
declare -a java_source_folder_array
folder_number=0
for java_source_name in ` find $java_file_sources_dir/ -type f -name '*.java' `
do
java_sources_names=${java_source_name%/*.java}
has_it_flag=0
for i in ${#java_source_folder_array[@]}
do
if [ "${java_source_folder_array[$i]}" = "$java_sources_names" ] ; then
has_it_flag=1
elif [ "$java_sources_names" = "$java_file_sources_dir/" ] ; then
has_it_flag=1
fi
done
if [ "$has_it_flag" = 0 ] ; then
let "folder_number+=1"
java_source_folder_array[$folder_number]="$java_sources_names"
fi
#javac -encoding "UTF-8" -d $out_put_dir "$java_sources_names"
done
echo -e '\E[33;48m'"\033[1m start to compile java source ...... \033[0m"
#echo "total source folder number :" "${#java_source_folder_array[@]}"
#echo "total source folders :" "${java_source_folder_array[@]}"
echo "total package number : " "$[folder_number]"
java_source_files=""
for (( a=1 ; a <= $[folder_number] ; a++ ))
do
java_source_files="$java_source_files ""${java_source_folder_array[$a]}""/*.java"
#javac -encoding "UTF-8" -nowarn -d $out_put_dir $java_source_files
done
echo "java source files name : " "$java_source_files"
echo "total java source count :" ` find $java_file_sources_dir/ -name *.java |wc -l `
javac -encoding "UTF-8" -nowarn -d $out_put_dir $java_source_files
echo "total class file count :" ` find $out_put_dir/ -name *.class |wc -l `
}
## copy the resource not include java source
copy_resources_files()
{ echo -e '\E[33;48m'"\033[1m start to copy resource file ...... \033[0m"
for resources_file_name in `find $java_file_sources_dir/ \( -type f -name '**.java*' -o -type d -o -path '*.svn*' \) -o -print`
do
#get the file name not include the resource path name
resource_file_name_nsp=${resources_file_name#"$java_file_sources_dir/"}
echo $resource_file_name_nsp
#copy the resource file to the output directory
cp -fu $resources_file_name "$out_put_dir""/$resource_file_name_nsp"
done
}
start()
{
if [ -z $1 ] ; then
clear_bin
compile_source
copy_resources_files
fi
}
time start
echo -e '\E[31;48m'"\033[1m **************************** build xmhi backgroud project end **************************** \033[0m"
复制代码
回复
使用道具
举报
提升卡
置顶卡
沉默卡
喧嚣卡
变色卡
显身卡
ginkgo
ginkgo
当前离线
积分
714
IP卡
狗仔卡
发表于 2009-4-2 21:05:46
|
显示全部楼层
多了还是用ant方便,maven太依赖网络了。
回复
支持
反对
使用道具
举报
显身卡
返回列表
高级模式
B
Color
Image
Link
Quote
Code
Smilies
您需要登录后才可以回帖
登录
|
注册
本版积分规则
发表回复
回帖后跳转到最后一页
浏览过的版块
红旗 REDFLAG Linux
Mandriva Linux
网络技术\网络安全讨论
LFS(LinuxfromScratch)
服务器架设、应用、维护
硬件设备 Linux 驱动
开源软件专题讨论
Linux 输入开发与研究
SuSE Linux
Copyright © 2002-2023
LinuxSir.cn
(http://www.linuxsir.cn/) 版权所有 All Rights Reserved.
Powered by
RedflagLinux!
技术支持:
中科红旗
|
京ICP备19024520号
快速回复
返回顶部
返回列表