[ 
https://issues.apache.org/jira/browse/MNG-6310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16515575#comment-16515575
 ] 

Brett Randall edited comment on MNG-6310 at 6/18/18 10:39 AM:
--------------------------------------------------------------

Well you can work-around this, for dependency resolution/download at least, by 
reverting to the standard JVM system-properties.  So you can toggle proxy-mode 
on/off in your shell via {{MAVEN_OPTS}}:

{{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"}}

Which works - the issue being that it takes an approach counter to the 
Maven-way to do proxies in the documentation (via {{settings.xml}}), and may 
have other side-effects.  Maybe a doc-update would suffice:
 * [https://maven.apache.org/guides/mini/guide-proxies.html]
 * [https://maven.apache.org/settings.html#Proxies]

Aside: this is precisely the approach recommended in Gradle, and works there 
with identical values in {{GRADLE_OPTS}}, but they don't mention in their docs, 
only the sysprops themselves: 
[https://docs.gradle.org/current/userguide/build_environment.html#sec:accessing_the_web_via_a_proxy]
{quote}The best and simplest solution is to use git and put things in 
.m2/repository
{quote}
I don't following how doing anything with the {{localRepository}} will help.
{quote}use different branches for the different environments
{quote}
I'd consider this as a very last resort - should not need branches for 
build-environment control.  A simple script which takes a simple look at the 
environment and sets some variable, or using some existing OS variable such as 
{{http_proxy}}/{{https_proxy}} should be able to enable or disable proxies.


was (Author: brett_s_r):
Well you can work-around this, for dependency resolution/download at least, by 
reverting to the standard JVM system-properties.  So you can toggle proxy-mode 
on/off in your shell via {{MAVEN_OPTS}}:

{{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"}}

Which works - the issue being that it takes an approach counter to the 
Maven-way to do proxies in the documentation (via {{settings.xml}}), and may 
have other side-effects.  Maybe a doc-update would suffice:
 * [https://maven.apache.org/guides/mini/guide-proxies.html]
 * [https://maven.apache.org/settings.html#Proxies]

Aside: this is precisely the approach recommended in Gradle, and works there 
with identical values in {{GRADLE_OPTS}}, but they don't mention in their docs, 
only the sysprops themselves: 
[https://docs.gradle.org/current/userguide/build_environment.html#sec:accessing_the_web_via_a_proxy]
{quote}The best and simplest solution is to use git and put things in 
.m2/repository
{quote}
I don't following how doing anything with the {{localRepository}} will help.
{quote}use different branches for the different environments
{quote}
I'd consider this as a very last resort - should not need branches for 
build-environment control.  A simple script which takes a simple look at the 
environment and sets some variable, or using some existing OS variable such as 
{{http_proxy}}/{{https_proxy}} should be able to enable or disable proxies.

> settings.xml allow proxy activation by expression
> -------------------------------------------------
>
>                 Key: MNG-6310
>                 URL: https://issues.apache.org/jira/browse/MNG-6310
>             Project: Maven
>          Issue Type: New Feature
>          Components: Bootstrap & Build
>    Affects Versions: 3.5.2
>            Reporter: Brett Randall
>            Priority: Minor
>
> Currently it appears that {{settings.xml}} proxies can only be activated via 
> a boolean {{active}} element, which does not appear to be evaluated, so you 
> cannot use a property (e.g. set by a profile), nor a system or environment 
> property.
> This comes up a lot on discussions from developers trying to automate whether 
> Maven's proxies are enabled or not, based on a system or environment property 
> etc.
> Possible solutions:
> * Change the model for (generate) {{Proxy.active}} allowing an expression to 
> then be evaluated.
> * Copy {{profiles}} approach and add an {{<activation>>}} element, but this 
> requires a settings schema rev.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to