2

I'm having a problem with Maven behind a squid proxy server.

I have a module of my system that depends external communication with a remote webservice.

I have my maven proxy configurations under ~/.m2/settings.xml, but apparently, these information are been used just for dependencies downloads.

When I run 'mvn test', these configurations aren't used on command line execution call. This is the instruction echoed on console:

${JAVA_HOME}/bin/java -jar /tmp/surefirebooter4156656684210940660.jar /tmp/surefire2646147996861949548tmp /tmp/surefire3498083351425809633tmp

There's a way to pass arguments to JVM during tests and other maven method executions?

Alexander Farber
  • 18,345
  • 68
  • 208
  • 375
Andre Pastore
  • 2,557
  • 4
  • 28
  • 42

2 Answers2

4

Perhaps this can be of interest to you: How do I configure proxy settings for Java. Alternatively you can try these startup parameters:

-Dhttp.proxyHost=url
-Dhttp.proxyPort=port
-Dhttp.proxyUser=user
-Dhttp.proxyPassword=pass

[EDIT]

These properties can also be set in MAVEN_OPTS. This post describes how this would work for the test-profile.

Community
  • 1
  • 1
Johan Sjöberg
  • 43,692
  • 19
  • 120
  • 139
  • I have thios configurations on my JRE jvmargs defined on Eclipse environment. But, MVN ignore this. The same applies to command line environment. How can I inject these jvmargs on mvn context, independently of runtime environment. Until now, dependencies are supported by ~/.m2/settings.xml. Each user have yours. – Andre Pastore Feb 16 '11 at 12:46
  • 1
    And [this](http://maven.apache.org/settings.html#Proxies) is what you're using? Have you tried setting the proxy information in `MAVEN_OPTS`? Also have a look at [this](http://stackoverflow.com/questions/824019/maven-2-1-0-not-passing-on-system-properties-to-java-virtual-machine) issue. – Johan Sjöberg Feb 16 '11 at 12:49
  • This is exactly the configuration defined on ~/.m2/settings.xml. I'll check MAVEN_OPTS and report here. Thanks by helping! – Andre Pastore Feb 16 '11 at 12:52
  • I used the argument explained on post that you suggested and it's working! Using "-DforkMode=never", i.e. 'mvn test -DforkMode=never', Surefire doesn't fork the execution from parent jvm process. Thanks! PS: how can I check your comment as Right Response? – Andre Pastore Feb 16 '11 at 13:14
1

To fix some arguments on pom.xml, we can configure -DforkMode=never directly on surefire plugin configuration. i.e.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.5</version>
  <configuration>
    <argLine>-DforkMode=never</argLine>
  </configuration>
</plugin>

The solution based on -DforkMode was suggested by this post, referenced by @johan-sjoberg on comments posted here

Karl Richter
  • 6,271
  • 17
  • 57
  • 120
Andre Pastore
  • 2,557
  • 4
  • 28
  • 42