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