11
zhanghua
2024-09-05 a77cd2572fae653df15a202bdcd692a8e9c44a04
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# linux/mac下运行脚本
# @author 47081
ARG_COUNT=$#
#echo $ARG_COUNT
if [ $ARG_COUNT -lt 1 ]; then
  echo "Usage example: ./run.sh com.netsdk.demo.RealPlayByDataType"
  exit 1
fi
current_path=`pwd`
echo $current_path
#源码路径
source_path=src/main/java
#依赖包路径
dependencies_path=libs
res_path=res
#编译输出路径
out_path=target
 
#检查编译输出路径是否存在,如果存在,删除重新创建
if [ -d $out_path ]; then
  rm -rf $out_path
fi
mkdir $out_path
#复制resources下的jar包到编译目录
cp $dependencies_path/*.jar $out_path
#复制res下xml和properties到编译目录
cp $res_path/*.xml $out_path
cp $res_path/*.properties $out_path
#复制动态库到编译目录
os=$(uname -a)
arch=$(getconf LONG_BIT)
if [[ $os =~ "Darwin" ]]; then
  cp -r $dependencies_path/mac64 $out_path/
  cp=$out_path/mac64:
elif [ $arch == '64' ]; then
  cp -r $dependencies_path/linux64 $out_path/
  cp=$out_path/linux64:
  export_path=$out_path/linux64
  echo ${current_path}/${export_path}
  export LD_LIBRARY_PATH=${current_path}/${export_path}
else
  cp -r $dependencies_path/linux32 $out_path/
  cp=$out_path/linux32:
  export_path=$out_path/linux32
  export LD_LIBRARY_PATH=${current_path}/${export_path}
fi
#获得需要编译的java文件名称,输出到list.txt文件中
find $source_path -name "*.java" >$out_path/list.txt
cp+=$source_path:
for file in $out_path/*.jar; do
  cp+=$file:
done
#javac编译
javac -encoding UTF-8 -d $out_path -cp $cp @$out_path/list.txt
#进入编译文件夹
cd $out_path
cp=.:
for file in ./*.jar; do
  cp+=$file:
done
java -Dfile.encoding=UTF-8 -cp $cp $1