blob: d7d7301bd8b45b0c093675dcd7402a79fc9df11a [file] [log] [blame]
Matt Jeanneretc7b437c2019-05-13 12:33:08 -04001#!/bin/bash
Joey Armstrong695ba5c2023-01-20 11:17:49 -05002# Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
Matt Jeanneretc7b437c2019-05-13 12:33:08 -04003#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15if [ -f mvn_settings.custom.xml ] ; then
16 cp mvn_settings.custom.xml mvn_settings.xml
17 exit 0
18fi
19
20if [ "$http_proxy$https_proxy" != "" ] ; then
21 echo " <proxies>" >> mvn_settings.proxy.xml
22 for PROTOCOL in http https ; do
23 proxy="${PROTOCOL}_proxy"
24 proxy="${!proxy}"
25 if [ "$proxy" = "" ] ; then continue ; fi
26
27 # username/password not yet included
28 PROXY_HOST=$(echo "$proxy" | sed "s@.*://@@;s/.*@//;s@:.*@@")
29 PROXY_PORT=$(echo "$proxy" | sed "s@.*://@@;s@.*:@@;s@/.*@@")
30 NON_PROXY=$(echo "$no_proxy" | sed "s@,@|@g")
31
32 echo " <proxy>
33 <id>$PROTOCOL</id>
34 <active>true</active>
35 <protocol>$PROTOCOL</protocol>
36 <host>$PROXY_HOST</host>
37 <port>$PROXY_PORT</port>
38 <nonProxyHosts>$NON_PROXY</nonProxyHosts>
39 </proxy>" >> mvn_settings.proxy.xml
40 done
41 echo " </proxies>" >> mvn_settings.proxy.xml
42
43 sed -i '/<!--PROXY-->/r mvn_settings.proxy.xml' mvn_settings.xml
44fi
45
46if [ -f mvn_settings.extra.xml ] ; then
47 sed -i 's/<!--EXTRA-->/r mvn_settings.extra.xml' mvn_settings.xml
48fi