sjngm
sjngm

Reputation: 12871

Proxies in Maven's settings.xml

Coming from this question I'm trying to get my setup to work, but the tests keep failing as they can't connect to the remote site. I upgraded to Maven 3.3.9.

This is my settings.xml that I want to get working:

<settings>

  <proxies>
    <proxy>
      <id>httpProxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.local</host>
      <port>3128</port>
      <nonProxyHosts>localhost|*.local</nonProxyHosts>
    </proxy>
    <proxy>
      <id>httpsProxy</id>
      <active>true</active>
      <protocol>https</protocol>
      <host>10.20.20.208</host>
      <port>3128</port>
      <nonProxyHosts>localhost|*.local</nonProxyHosts>
    </proxy>
  </proxies>
:

This is a small part, which already doesn't work:

<settings>

  <proxies>
    <proxy>
      <protocol>https</protocol>
      <host>10.20.20.208</host>
      <port>3128</port>
    </proxy>
  </proxies>
:

I also tried to put IP-addresses in there.

I know that Maven picks that XML, because Maven says so in its debug messages and if I break the syntax of it Maven complains.

The only thing that really works is passing -Dhttps.proxyHost=proxy.local -Dhttps.proxyPort=3128 to Maven.

What is it that I'm doing wrong in my XML?

Upvotes: 0

Views: 6292

Answers (2)

sjngm
sjngm

Reputation: 12871

After reading the checked answer I tried to make it all work and actually only had to fix the plug-in configuration of maven-failsafe-plugin:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.8</version>
    <executions>
      <execution>
        <id>integration-test</id>
        <goals>
          <goal>integration-test</goal>
        </goals>
        <configuration>
          <!-- added -Dhttps.proxyHost and -Dhttps.proxyPort -->
          <argLine>-Xmx512m -XX:MaxPermSize=512m -Dhttps.proxyHost=proxy.local -Dhttps.proxyPort=3128</argLine>
          <includes>
            <include>**/*ITest.java</include>
          </includes>
        </configuration>
      </execution>
      <execution>
        <id>verify</id>
        <goals>
          <goal>verify</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

So I leave this here in case anyone stumbles across the same misunderstanding...

Upvotes: 2

Archimedes Trajano
Archimedes Trajano

Reputation: 41520

Your tests are likely not going to read the settings.xml as that's for Maven as that's for the Maven build and their plugins.

You can double check this by adding in -X and see what properties are sent to your tests when surefire is running.

Upvotes: 0

Related Questions