blob: b2e72e0f7e1976a5823c040cc11f138cb3640754 [file] [log] [blame]
pierventre16709162020-07-16 20:48:24 +02001#!/bin/bash
pierventre83611422020-08-14 22:53:15 +02002
pierventre16709162020-07-16 20:48:24 +02003#
4# Copyright 2020-present Open Networking Foundation
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
pierventre83611422020-08-14 22:53:15 +020018
19http_proxy=${http_proxy:-}
20https_proxy=${https_proxy:-}
21no_proxy=${no_proxy:-}
22
pierventre16709162020-07-16 20:48:24 +020023if [ -f mvn_settings.custom.xml ] ; then
24 cp mvn_settings.custom.xml mvn_settings.xml
25 exit 0
26fi
27
28cat << EOF > mvn_settings.xml
29<?xml version="1.0" encoding="UTF-8"?>
30
31<!--
32Licensed to the Apache Software Foundation (ASF) under one
33or more contributor license agreements. See the NOTICE file
34distributed with this work for additional information
35regarding copyright ownership. The ASF licenses this file
36to you under the Apache License, Version 2.0 (the
37"License"); you may not use this file except in compliance
38with the License. You may obtain a copy of the License at
39
40 http://www.apache.org/licenses/LICENSE-2.0
41
42Unless required by applicable law or agreed to in writing,
43software distributed under the License is distributed on an
44"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
45KIND, either express or implied. See the License for the
46specific language governing permissions and limitations
47under the License.
48-->
49
50<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
51 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
52 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
53 <!--PROXY-->
54 <!--EXTRA-->
55</settings>
56EOF
57
58if [ "$http_proxy$https_proxy" != "" ] ; then
59 echo " <proxies>" >> mvn_settings.proxy.xml
60 for PROTOCOL in http https ; do
61 proxy="${PROTOCOL}_proxy"
62 proxy="${!proxy}"
63 if [ "$proxy" = "" ] ; then continue ; fi
64
65 # username/password not yet included
66 PROXY_HOST=$(echo "$proxy" | sed "s@.*://@@;s/.*@//;s@:.*@@")
67 PROXY_PORT=$(echo "$proxy" | sed "s@.*://@@;s@.*:@@;s@/.*@@")
68 NON_PROXY=$(echo "$no_proxy" | sed "s@,@|@g")
69
70 echo " <proxy>
71 <id>$PROTOCOL</id>
72 <active>true</active>
73 <protocol>$PROTOCOL</protocol>
74 <host>$PROXY_HOST</host>
75 <port>$PROXY_PORT</port>
76 <nonProxyHosts>$NON_PROXY</nonProxyHosts>
77 </proxy>" >> mvn_settings.proxy.xml
78 done
79 echo " </proxies>" >> mvn_settings.proxy.xml
80
81 sed -i '/<!--PROXY-->/r mvn_settings.proxy.xml' mvn_settings.xml
82 rm mvn_settings.proxy.xml
83fi
84
85if [ -f mvn_settings.extra.xml ] ; then
86 sed -i 's/<!--EXTRA-->/r mvn_settings.extra.xml' mvn_settings.xml
87fi