-
Notifications
You must be signed in to change notification settings - Fork 14
/
maven-central-stage.sh
executable file
·254 lines (232 loc) · 7.09 KB
/
maven-central-stage.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#!/bin/bash
set -e
# A space delimited list of feature IDs
features_whose_bundles_we_will_deploy="org.eclipse.ecf.remoteservice.sdk.feature
org.eclipse.ecf.core.feature
org.eclipse.ecf.core.ssl.feature
org.eclipse.ecf.filetransfer.feature
org.eclipse.ecf.filetransfer.ssl.feature
org.eclipse.ecf.filetransfer.httpclient5.feature
org.eclipse.ecf.filetransfer.httpclientjava.feature
org.eclipse.ecf.remoteservice.examples.feature
org.eclipse.ecf.remoteservices.tooling.bndtools.feature"
# Exclude orbit bundles, they should be done separately
orbit_bundles="javax.servlet
com.sun.jna
com.sun.jna.platform
org.apache.commons.codec
org.apache.commons.logging
org.apache.httpcomponents.httpclient
org.apache.httpcomponents.httpclient.win
org.apache.httpcomponents.httpcore
org.apache.httpcomponents.client5.httpclient5
org.apache.httpcomponents.client5.httpclient5-win
org.json
org.objectweb.asm"
wget 'https://downloads.sourceforge.net/project/xmltask/xmltask/1.16.1/xmltask.jar?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fxmltask%2Ffiles%2Fxmltask%2F1.16.1%2Fxmltask.jar' -O xmltask.jar
cat << EOF > xpath.xml
<project xmlns:if="ant:if" xmlns:unless="ant:unless" name="xpath" default="xpath">
<target name="init">
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" classpath="xmltask.jar"/>
</target>
<target name="xpath" depends="init">
<xmltask source="\${xml.file}">
<copy path="\${xml.path}" property="results" append="true"/>
</xmltask>
<echo if:set="results" message="\${results}" file="results" append="false"/>
<echo unless:set="results" message="" file="results" append="false"/>
</target>
</project>
EOF
deploy () {
local target=$1
mkdir -p $target
sed -e 's/-SNAPSHOT//' $(dirname $target)/pom.xml > $target/pom.xml
local pom=$target/pom.xml
local file="$(ls $target/*-SNAPSHOT.jar 2>/dev/null)"
local sources="${file%.jar}-sources.jar"
local javadoc="${file%.jar}-javadoc.jar"
# Create dummy javadoc jar
if [ -f "$file" -a ! -f "$javadoc" ] ; then
echo "Javadoc for ECF is distributed separately, please see: http://download.eclipse.org/rt/ecf/latest/javadoc/" > $target/README.txt
(cd $target && jar -cf $(basename $javadoc) README.txt)
fi
# Build properties list
local props="-DpomFile=$pom"
if [ -n "$file" ] ; then
props="$props -Dfile=$file"
else
props="$props -Dfile=$pom"
fi
if [ -f "$sources" ] ; then
props="$props -Dsources=$sources"
fi
if [ -f "$javadoc" ] ; then
props="$props -Djavadoc=$javadoc"
fi
#local settings=/opt/public/hipp/homes/genie.ecf/.m2/settings-deploy-ossrh.xml
#local settings=~/.m2/settings.xml
echo "mvn gpg:sign-and-deploy-file -DrepositoryId=ossrh " \
"-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/" \
"$props -Dtycho.mode=maven"
mvn gpg:sign-and-deploy-file -DrepositoryId=ossrh \
-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ \
$props -Dtycho.mode=maven
}
bundles=""
_add_bundle_to_list() {
local plugin=$1
local match=0
for b in $bundles; do
if [ "$b" = "$plugin" ] ; then
match=1
fi
done
if [ "$match" != "1" ] ; then
echo " $plugin"
local orbit_match=0
for o_b in $orbit_bundles ; do
if [ "$o_b" = "$plugin" ] ; then
orbit_match=1
break
fi
done
if [ "$orbit_match" != "1" ] ; then
bundles="$bundles $plugin"
fi
fi
return $match
}
features=""
_add_feature_to_list() {
local feature=$1
local match=0
for f in $features ; do
if [ "$f" = "$feature" ] ; then
match=1
fi
done
if [ "$match" != "1" ] ; then
echo " $feature"
features="$features $feature"
fi
return $match
}
xpath_call() {
local xmlfile=$1
local xmlquery=$2
ant -f xpath.xml -Dxml.file=$xmlfile -Dxml.path="$xmlquery" >/dev/null
cat results
rm -f results
}
parse_feature() {
local xml=$(find -path "*/$1/feature.xml")
# Process included plugins
local i=0
while true ; do
i=$(( $i + 1 ))
local plugin=$(xpath_call $xml "string(//plugin[$i]/@id)")
if [ -z "$plugin" ] ; then
break
else
_add_bundle_to_list $plugin || :
fi
done
# Process plugins specified as "requires"
local i=0
while true ; do
i=$(( $i + 1 ))
local entry=$(xpath_call $xml "//requires/import[$i]")
if [ -z "$entry" ] ; then
break
fi
local plugin=$(xpath_call $xml "string(//requires/import[$i]/@plugin)")
if [ -n "$plugin" ] ; then
_add_bundle_to_list $plugin || :
fi
done
# Process included features
local i=0
while true ; do
i=$(( $i + 1 ))
local subfeature=$(xpath_call $xml "string(//includes[$i]/@id)")
if [ -z "$subfeature" ] ; then
break
else
_add_feature_to_list $subfeature && parse_feature $subfeature
fi
done
# Process features specified as "requires"
local i=0
while true ; do
i=$(( $i + 1 ))
local entry=$(xpath_call $xml "//requires/import[$i]")
if [ -z "$entry" ] ; then
break
fi
local subfeature=$(xpath_call $xml "string(//requires/import[$i]/@feature)")
if [ -n "$subfeature" ] ; then
_add_feature_to_list $subfeature && parse_feature $subfeature
fi
done
}
bundles_deploy=""
check_maven_central() {
local central_metadata="$(curl https://repo1.maven.org/maven2/org/eclipse/ecf/$1/maven-metadata.xml 2>/dev/null | grep '<latest>')"
local central_version=0.0.0
if [ -n "$central_metadata" ] ; then
local central_version=$(echo $central_metadata | sed -e 's/.*>\(.*\)<.*/\1/')
fi
local jar_version=$(find -name "$1-*-SNAPSHOT.jar" | tail -n1 | sed -e "s/.*$1-\(.*\)-SNAPSHOT.jar/\1/")
local op="="
if [ $(echo $jar_version | cut -f1 -d.) -gt "$(echo $central_version | cut -f1 -d.)" ] ; then
op=">"
elif [ $(echo $jar_version | cut -f2 -d.) -gt "$(echo $central_version | cut -f2 -d.)" ] ; then
op=">"
elif [ $(echo $jar_version | cut -f3 -d.) -gt "$(echo $central_version | cut -f3 -d.)" ] ; then
op=">"
fi
if [ "$central_version" = "0.0.0" ] ; then
central_version="N/A"
fi
echo " $1 $jar_version $op $central_version"
if [ "$op" != "=" ] ; then
bundles_deploy="$bundles_deploy $1"
fi
}
# set PREVIOUS_JAVA_HOME to $JAVA_HOME
PREVIOUS_JAVA_HOME=$JAVA_HOME
PREVIOUS_PATH=$PATH
export JAVA_HOME="/opt/tools/java/openjdk/jdk-11/latest"
PATH=$JAVA_HOME/bin:$PATH
echo
echo "Parsing the following features:"
echo "==============================="
for feature in $features_whose_bundles_we_will_deploy ; do
_add_feature_to_list $feature && parse_feature $feature
done
export JAVA_HOME=$PREVIOUS_JAVA_HOME
export PATH=$PREVIOUS_PATH
echo
echo "Checking the following found bundles against maven central:"
echo "==========================================================="
bundles_sorted="$(for b in $bundles ; do echo $b ; done | sort)"
for bundle in $bundles_sorted ; do
check_maven_central $bundle
done
echo
echo "Will deploy the following bundles with newer versions:"
echo "======================================================"
for bundle in $bundles_deploy ; do
echo " $bundle"
done
# Deploy parent pom
#deploy "./target"
# Deploy all discovered bundles
echo
for b in $bundles_deploy ; do
jars=$(find -name "$b-*-SNAPSHOT.jar" | tail -n1)
for jar in $jars ; do
deploy "$(dirname $jar)"
done
done