forked from bcgit/bc-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_module.sh
145 lines (122 loc) · 5.03 KB
/
add_module.sh
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
if ! [ -x "$(command -v openjdk_9)" ]; then
JAVA_9=/usr/lib/jvm/java-9.0.4-oracle-x64
else
JAVA_9=`openjdk_9`
fi
if ! [ -x "$(command -v openjdk_11)" ]; then
JAVA_11=/usr/lib/jvm/java-11-openjdk-amd64
else
JAVA_11=`openjdk_11`
fi
if ! [ -x "$(command -v openjdk_15)" ]; then
JAVA_15=/usr/lib/jvm/java-15-openjdk-amd64
else
JAVA_15=`openjdk_15`
fi
export JAVA_9
export JAVA_11
export JAVA_15
echo "Java 9 ---> $JAVA_9"
echo "Java 11 ---> $JAVA_11"
echo "java 15 ---> $JAVA_15"
export JAVA_HOME=$JAVA_9
export PATH="$JAVA_HOME/bin:$PATH"
if [ $# -ne 1 ]
then
echo "usage: add_module.sh prov|prov-ext|util|tls|pg|pkix|mail|jmail"
exit 0
fi
for jarName in bc$1-jdk18on-*.jar
do
rm -rf module.tmp
# Java 9 Step
(
export JAVA_HOME=$JAVA_9
export PATH="$JAVA_HOME/bin:$PATH"
mkdir -p module.tmp/v5
mkdir -p module.tmp/versions/v9
mkdir -p module.tmp/versions/v11
( cd module.tmp/v5; jar xf ../../build/artifacts/jdk1.8/jars/$jarName )
provJar=`echo build/artifacts/jdk1.8/jars/bcprov-jdk18on*.jar`
utilJar=`echo build/artifacts/jdk1.8/jars/bcutil-jdk18on*.jar`
pkixJar=`echo build/artifacts/jdk1.8/jars/bcpkix-jdk18on*.jar`
if [ $1 = "prov" ]
then
javac -target 1.9 -classpath module.tmp/v5 -d module.tmp/v9 `find $1/src/main/jdk1.9 -name "*.java"` -sourcepath $1/src/main/jdk1.9:$1/src/main/java:core/src/main/java
$JAVA_11/bin/javac -classpath module.tmp/v5 -d module.tmp/v11 `find $1/src/main/jdk1.11 -name "*.java"` -sourcepath $1/src/main/jdk1.11:$1/src/main/java:core/src/main/java
$JAVA_15/bin/javac -classpath module.tmp/v5:module.tmp/v11 -d module.tmp/v15 `find prov/src/main/jdk1.15 -name "*.java"` -sourcepath prov/src/main/jdk1.15:prov/src/main/jdk1.11:prov/src/main/java:core/src/main/java
elif [ $1 = "prov-ext" ]
then
javac -target 1.9 -classpath module.tmp/v5 -d module.tmp/v9 `find prov/src/main/ext-jdk1.9 -name "*.java"` -sourcepath prov/src/main/ext-jdk1.9:prov/src/main/java:core/src/main/java
$JAVA_11/bin/javac -classpath module.tmp/v5 -d module.tmp/v11 `find prov/src/main/jdk1.11 -name "*.java"` -sourcepath prov/src/main/jdk1.11:prov/src/main/java:core/src/main/java
$JAVA_15/bin/javac -classpath module.tmp/v5:module.tmp/v11 -d module.tmp/v15 `find prov/src/main/jdk1.15 -name "*.java"` -sourcepath prov/src/main/jdk1.15:prov/src/main/jdk1.11:prov/src/main/java:core/src/main/java
elif [ $1 = "mail" ]
then
javac -target 1.9 --module-path ${provJar}:$utilJar:$pkixJar -classpath module.tmp/v5 -d module.tmp/v9 `find $1/src/main/jdk1.9 -name "*.java"` -sourcepath $1/src/main/jdk1.9:$1/src/main/java
elif [ $1 = "jmail" ]
then
( cd build/artifacts/jdk1.8/bcjmail-jdk18on-*; mkdir src; cd src; unzip ../src.zip )
jmailSrc=`echo build/artifacts/jdk1.8/bcjmail-jdk18on-*/src/`
javac -target 1.9 --module-path ${provJar}:$utilJar:$pkixJar:libs/jakarta.mail-2.0.1.jar:libs/jakarta.activation-api-2.0.0.jar -classpath module.tmp/v5 -d module.tmp/v9 `find $1/src/main/jdk1.9 -name "*.java"` -sourcepath $1/src/main/jdk1.9:$jmailSrc
rm -r build/artifacts/jdk1.8/bcjmail-jdk18on-*/src
elif [ $1 = "pkix" ]
then
javac -target 1.9 --module-path ${provJar}:$utilJar -classpath module.tmp/v5 -d module.tmp/v9 `find $1/src/main/jdk1.9 -name "*.java"` -sourcepath $1/src/main/jdk1.9:$1/src/main/java
elif [ $1 = "tls" ]
then
javac -target 1.9 --module-path ${provJar}:$utilJar -classpath module.tmp/v5 -d module.tmp/v9 `find $1/src/main/jdk1.9 -name "*.java"` -sourcepath $1/src/main/jdk1.9:$1/src/main/java
else
javac -target 1.9 --module-path $provJar -classpath module.tmp/v5 -d module.tmp/v9 `find $1/src/main/jdk1.9 -name "*.java"` -sourcepath $1/src/main/jdk1.9:$1/src/main/java
fi
)
# Java 11 Step
(
export JAVA_HOME=$JAVA_11
export "PATH=$JAVA_HOME/bin:$PATH"
cd module.tmp
if [ -d v11 ]
then
extras=`2>&1 jar cf $jarName -C v5 . --release 9 -C v9 . --release 11 -C v11 . | egrep Warning | sed -e "s/Warning: entry //" | sed -e "s/ contains.*$//"`
else
extras=`2>&1 jar cf $jarName -C v5 . --release 9 -C v9 . | egrep Warning | sed -e "s/Warning: entry //" | sed -e "s/ contains.*$//"`
fi
for f in `echo $extras`
do
p=`echo $f | sed -e "s:META-INF/versions/9::"`
rm v9/$p
done
)
if ! [ -x "$(command -v ./bnd.sh)" ]; then
echo "WARNING: Skipping running bnd.sh"
else
sh ./bnd.sh build/artifacts/jdk1.8/jars/$jarName
fi
cp build/artifacts/jdk1.8/jars/$jarName module.tmp/$jarName
# Java 11 Step
(
export JAVA_HOME=$JAVA_11
export PATH="$JAVA_HOME/bin:$PATH"
cd module.tmp
jar uf $jarName --release 9 -C v9 .
if [ -d v11 ]
then
jar uf $jarName --release 11 -C v11 .
fi
)
# Java 15 Step
(
export JAVA_HOME=$JAVA_15
export PATH="$JAVA_HOME/bin:$PATH"
cd module.tmp
if [ -d v15 ]
then
jar uf $jarName --release 15 -C v15 .
fi
)
cp module.tmp/$jarName build/artifacts/jdk1.8/jars/$jarName
if ! [ -x "$(command -v bcsign11)" ]; then
echo "WARNING: Skipping bcsign11"
else
bcsign11 build/artifacts/jdk1.8/jars/$jarName
fi
done