2016-09-06 2 views
6

특정 프로필이 활성화 된 경우에만 프록시를 사용하고 싶습니다. 이것을 달성하기 위해서, <active> 속성을 <proxy> 요소로 매개 변수화하는 것이 좋습니다. 그러나, 나는 이것을 정확하게 수행하는 방법을 정확히 모르겠습니다.Maven에서 특정 프로필이 활성화되어있을 때만 프록시를 사용할 수 있습니까?

질문 : 특정 프로필이 활성화 된 경우에만 어떻게 프록시를 사용할 수 있습니까?

+0

_settings.xml_ 파일에서 프록시가 프로필 요소를 벗어 났으므로 불가능합니다 (https://maven.apache.org/settings.html#Proxies) – Tome

+1

도움이 될만한 질문이 있습니다. maven이 mvn -s /path/to/settings.xml과 함께 사용하는 settings.xml을 지정할 수 있습니다 - 그래서 두 가지 구성이 가능할 수 있습니까? – wemu

답변

5

는 다음과 같은 방법을 시도해 볼 수도 있습니다 :

<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> 

그래서 기본적으로 proxy-off 프로파일이 활성화 될 것 activate.proxyfalsefalse-proxyactive 같은 설정 것이다. proxy-on 프로파일을 활성화 싶은

mvn clean install -Pproxy-on 

전체 체인 activetrue에 대해 발생해야

그럼으로 실행.

+0

@Utku이 문제를 해결 했습니까? 이 대답이 도움이 되었습니까? –

+0

나를 위해 일했습니다. –

+1

** Maven 3.3.9와 3.5.0 모두 사용하지 못합니다. – Jan

관련 문제