1

Can Maven convert comma separated list of files into multiple <file> elements? I want to pass one arg to my suite with multiple files, like so:

-DngFiles=testng1.xml,testng2.xml

I found an example of the plugin defining multiple suite files.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <suiteXmlFiles>
      <file>src/test/resources/testng1.xml</file>
      <file>src/test/resources/testng2.xml</file>
    </suiteXmlFiles>
  </configuration>
</plugin>

I am hoping, given the above scenario, something like this might be possible?

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <suiteXmlFiles>
      <files>${ngFiles}</files>
    </suiteXmlFiles>
  </configuration>
</plugin>

Seems to me like there might be no way to do this except by modification of the behavior of the Surefire plugin itself right? Is there no Maven plugin that can do what I am wanting to do?

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
djangofan
  • 28,471
  • 61
  • 196
  • 289

1 Answers1

2

Generally speaking, Maven can't do this automatically. Either the plugin supports such a configuration or not.

In this case, the suiteXmlFiles has a corresponding user property, which is surefire.suiteXmlFiles. This means, on the command line, you can directly set it to multiple values that are comma-delimited with:

-Dsurefire.suiteXmlFiles=src/test/resources/testng1.xml,src/test/resources/testng2.xml

This means you actually don't need to define any configuration for the maven-surefire-plugin. You just need to make sure to use the latest 2.19.1 version with:

<plugin>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.19.1</version>
</plugin>

Typically, the two types of configuration for lists in plugins are:

Community
  • 1
  • 1
Tunaki
  • 132,869
  • 46
  • 340
  • 423