pierventre | 1670916 | 2020-07-16 20:48:24 +0200 | [diff] [blame] | 1 | #!/bin/bash |
pierventre | 8361142 | 2020-08-14 22:53:15 +0200 | [diff] [blame] | 2 | |
pierventre | 1670916 | 2020-07-16 20:48:24 +0200 | [diff] [blame] | 3 | # |
| 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 | # |
pierventre | 8361142 | 2020-08-14 22:53:15 +0200 | [diff] [blame] | 18 | |
| 19 | http_proxy=${http_proxy:-} |
| 20 | https_proxy=${https_proxy:-} |
| 21 | no_proxy=${no_proxy:-} |
| 22 | |
pierventre | 1670916 | 2020-07-16 20:48:24 +0200 | [diff] [blame] | 23 | if [ -f mvn_settings.custom.xml ] ; then |
| 24 | cp mvn_settings.custom.xml mvn_settings.xml |
| 25 | exit 0 |
| 26 | fi |
| 27 | |
| 28 | cat << EOF > mvn_settings.xml |
| 29 | <?xml version="1.0" encoding="UTF-8"?> |
| 30 | |
| 31 | <!-- |
| 32 | Licensed to the Apache Software Foundation (ASF) under one |
| 33 | or more contributor license agreements. See the NOTICE file |
| 34 | distributed with this work for additional information |
| 35 | regarding copyright ownership. The ASF licenses this file |
| 36 | to you under the Apache License, Version 2.0 (the |
| 37 | "License"); you may not use this file except in compliance |
| 38 | with the License. You may obtain a copy of the License at |
| 39 | |
| 40 | http://www.apache.org/licenses/LICENSE-2.0 |
| 41 | |
| 42 | Unless required by applicable law or agreed to in writing, |
| 43 | software distributed under the License is distributed on an |
| 44 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 45 | KIND, either express or implied. See the License for the |
| 46 | specific language governing permissions and limitations |
| 47 | under 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--> |
Daniele Moro | f969c74 | 2022-01-03 22:01:00 +0100 | [diff] [blame] | 55 | <!--MIRRORS--> |
pierventre | 1670916 | 2020-07-16 20:48:24 +0200 | [diff] [blame] | 56 | </settings> |
| 57 | EOF |
| 58 | |
| 59 | if [ "$http_proxy$https_proxy" != "" ] ; then |
| 60 | echo " <proxies>" >> mvn_settings.proxy.xml |
| 61 | for PROTOCOL in http https ; do |
| 62 | proxy="${PROTOCOL}_proxy" |
| 63 | proxy="${!proxy}" |
| 64 | if [ "$proxy" = "" ] ; then continue ; fi |
| 65 | |
| 66 | # username/password not yet included |
| 67 | PROXY_HOST=$(echo "$proxy" | sed "s@.*://@@;s/.*@//;s@:.*@@") |
| 68 | PROXY_PORT=$(echo "$proxy" | sed "s@.*://@@;s@.*:@@;s@/.*@@") |
| 69 | NON_PROXY=$(echo "$no_proxy" | sed "s@,@|@g") |
| 70 | |
| 71 | echo " <proxy> |
| 72 | <id>$PROTOCOL</id> |
| 73 | <active>true</active> |
| 74 | <protocol>$PROTOCOL</protocol> |
| 75 | <host>$PROXY_HOST</host> |
| 76 | <port>$PROXY_PORT</port> |
| 77 | <nonProxyHosts>$NON_PROXY</nonProxyHosts> |
| 78 | </proxy>" >> mvn_settings.proxy.xml |
| 79 | done |
| 80 | echo " </proxies>" >> mvn_settings.proxy.xml |
| 81 | |
| 82 | sed -i '/<!--PROXY-->/r mvn_settings.proxy.xml' mvn_settings.xml |
| 83 | rm mvn_settings.proxy.xml |
| 84 | fi |
| 85 | |
Daniele Moro | f969c74 | 2022-01-03 22:01:00 +0100 | [diff] [blame] | 86 | if [ "$USE_LOCAL_SNAPSHOT_ARTIFACTS" == "true" ]; then |
| 87 | # When using local SNAPSHOT artifacts, we need to prevent maven to fetch from the Sonatype repository. |
| 88 | # However, we need to point to a valid maven repository otherwise maven fails. For this reason we |
| 89 | # mirror snapshots to maven central (that won't contain any SNAPSHOT artifacts). |
| 90 | echo " <mirrors> |
| 91 | <mirror> |
| 92 | <id>central_snapshots</id> |
| 93 | <name>central_snapshots</name> |
| 94 | <url>https://repo.maven.apache.org/maven2</url> |
| 95 | <mirrorOf>snapshots</mirrorOf> |
| 96 | </mirror> |
| 97 | </mirrors>" >> mvn_settings.mirror.xml |
| 98 | sed -i '' -e '/<!--MIRRORS-->/r mvn_settings.mirror.xml' mvn_settings.xml |
| 99 | rm mvn_settings.mirror.xml |
| 100 | fi |
| 101 | |
pierventre | 1670916 | 2020-07-16 20:48:24 +0200 | [diff] [blame] | 102 | if [ -f mvn_settings.extra.xml ] ; then |
| 103 | sed -i 's/<!--EXTRA-->/r mvn_settings.extra.xml' mvn_settings.xml |
| 104 | fi |