0

I have a multi-module maven project. In the child module, failsafe plugin is used for the integration tests run. Some argLines are defined accordingly :

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <configuration>
        <skipAfterFailureCount>1</skipAfterFailureCount>
        <argLine>-Xmx2048M -Xss512M -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC</argLine>
    </configuration>
</plugin>

The problem is when I run the tests as mvn test or mvn integration-test, the arglines are not applied for the tests from neither the parent pom directory nor the child pom directory, but if I run the tests as mvn failsafe:integration-test from both of the directories, the arglines param are applied.

What is the reason behind this ? Is there any way to apply those params when I run the tests with mvn test command ? I tried to pass the parameters via command line as mvn test -Dchild.argline="-Xmx2048M -Xss512M -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC"

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <configuration>
        <skipAfterFailureCount>1</skipAfterFailureCount>
        <argLine>${child.argline}</argLine>
    </configuration>
</plugin> 

But it didn't work.

Also I tried to bind test and integration-test phases to failsafe integration-test and defined configuration params there, but it didn't work as well..

I set the MAVEN_OPTS accordingly but it didn't help...

user944849
  • 14,524
  • 2
  • 61
  • 83
user3088282
  • 91
  • 1
  • 9

1 Answers1

0

The failsafe plugin goals are not included in the lifecycle by default. The POM configuration must include it. See this SO answer for an example. Also ensure that the plugin definition is in the <plugins> section, not inside a <pluginManagement> element.

As for how to define options in the POM - use the names supplied in the documentation. So, to specify argLine, add

<argLine>...</argLine>

in the plugin config. To specify on the command line, note that "User property" for the value you want to set. For the failsafe plugin's argLine, the user property is also argLine, so on the command line specify

-DargLine=...

Maven knows nothing about child.argline so silently ignores it. Also note, attribute and user property names are case sensitive.

user944849
  • 14,524
  • 2
  • 61
  • 83
  • So, I have added the executions property exactly like the answer that you have mentioned and added to the configuration section, but when I run the mvn:test from the parent pom directory, still the argLine is not applied for the integration test run.. – user3088282 Mar 07 '18 at 14:05
  • This is expected. `mvn test` does not run failsafe. it only runs surefire. Try `mvn verify` or `mvn install`. Hint, reading the [Maven lifecycle docs](https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html) in detail will be useful if you will be working with Maven often. – user944849 Mar 07 '18 at 15:03