Utk*_*tku 14 proxy maven-3 maven maven-profiles
我想仅在特定配置文件处于活动状态时才使用代理.为了实现这一点,我的猜测是参数<active>化<proxy>元素的属性.但是,我不确定如何实现这一目标.
问题:如何仅在特定配置文件处于活动状态时才使用代理?
A_D*_*teo 12
您可以尝试以下方法:
<settings>
<proxies>
<proxy>
<id>httpproxy</id>
<active>${activate.proxy}</active>
<protocol>http</protocol>
<host>some.host</host>
<port>8080</port>
<nonProxyHosts>localhost|127.0.0.1</nonProxyHosts>
</proxy>
</proxies>
<profiles>
<profile>
<id>proxy-on</id>
<properties>
<activate.proxy>true</activate.proxy>
</properties>
</profile>
<profile>
<id>proxy-off</id>
<properties>
<activate.proxy>false</activate.proxy>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>proxy-off</activeProfile>
</activeProfiles>
</settings>
Run Code Online (Sandbox Code Playgroud)
所以默认proxy-off配置文件会被激活,这将设置activate.proxy到false,因此active的proxy到false.
然后执行:
mvn clean install -Pproxy-on
Run Code Online (Sandbox Code Playgroud)
将启动proxy-on配置文件,整个产业链应该导致到true了active.
这并没有回答最初的问题,即询问配置文件控制,但一种解决方法是忽略settings.xml代理并设置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"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1914 次 |
| 最近记录: |