Is it possible to use proxy only when a specific profile is active in Maven?
Asked Answered
F

2

18

I would like to use proxy only when a specific profile is active. To accomplish this, my guess is to parameterize the <active> property of <proxy> element. However, I am not exactly sure how to accomplish this.

Question: How can I use proxy only when a specific profile is active?

Foskett answered 6/9, 2016 at 11:57 Comment(2)
In the settings.xml file, proxies are out of the profiles element, so this will not be possible (see here: maven.apache.org/settings.html#Proxies)Excursus
what might help: you can specify the settings.xml that maven uses with mvn -s /path/to/settings.xml - so having two configurations may possible for your case?Auberta
R
1

This does not answer the original question, which asks about control-by-profile, but one workaround is to ignore settings.xml proxies and set MAVEN_OPTS when you need to activate a proxy:

export MAVEN_OPTS="-Dhttp.proxyHost=my-proxy-server -Dhttp.proxyPort=80 -Dhttp.nonProxyHosts=*.my.org -Dhttps.proxyHost=my-proxy-server -Dhttps.proxyPort=80 -Dhttps.nonProxyHosts=*.my.org"
Rickirickie answered 18/6, 2018 at 10:41 Comment(0)
B
1

With

https://github.com/volkertb/autoproxy-maven-plugin/

or

https://github.com/c-a-services/overwrite-proxy-setting-plugin

you can set/clear the proxy during a later build phase.

(settings.xml <proxy> setting is not designed by maven to be dynamic with properties as property resolving happens after reading user settings.xml)

Bateau answered 30/11, 2022 at 16:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.