Possible to target only one of the two TestNG xml files listed within my Maven POM File?
My Maven POM file points to two xml files: uat.xml and preprod.xml, how do i target only one of the xml files using maven commands such as mvn clean compile test?
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
<!--<executable>C:\Program Files\Java\jdk1.8.0_121\bin\javac.exe</executable> -->
<executable>${env.JAVA_HOME}\bin\javac.exe</executable>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>uat.xml</suiteXmlFile>
<suiteXmlFile>preprod.xml</suiteXmlFile>
</suiteXmlFiles>
<testErrorIgnore>false</testErrorIgnore>
<testFailureIgnore>false</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
See below. You will reference the file by name. So,
mvn clean test -Dtestfile=uat.xml
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${testfile}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
Related
I need to set -Duser.language via pom.xml since I need language specific database queries.
When I pass -Duser.language=tr to VM options upon running spring boot application on Intellij, it works. But I need this to be done in pom.xml for profiling.
Below ways are not working. Language is not set.
<profile>
<properties>
<argLine>-Duser.language=tr -Duser.region=TR</argLine>
</properties>
...
</profile>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<verbose>true</verbose>
<fork>true</fork>
<compilerArgs>
<arg>-J-Duser.language=tr_TR</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<argLine>-Duser.language=tr -Duser.region=TR</argLine>
<systemPropertyVariables>
<user.language>tr</user.language>
<user.region>TR</user.region>
</systemPropertyVariables>
</configuration>
</plugin>
Only this is working but I need to run application with mvn spring-boot:run for this to work and that is not an option.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>
-Duser.language=tr
</jvmArguments>
</configuration>
...
</plugin>
How can I pass vm arguments via pom.xml?
I have defined my profiles in pom.xml as below:
<profiles>
<profile>
<id>Test123</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<!-- put your configurations here -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/target/testdemo.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
And we I ran a command mvn test -PTest123, there is no Tests being run as shown as below:
cmd output
However, we I ran with command mvn test, it has ran the test as shown as below:
cmd output
After reviewing the output files I noticed that different versions of the maven-compiler-plugin and maven-surefire-plugin are running per profile. Is this project dependent on a parent pom.xml? Otherwise changing the versions on the plugins to:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<!-- put your configurations here -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/target/testdemo.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
should fix the problem in case the versioning is not important.
I have set up maven-surefire-plugin in POM.xml.
Ideally as per the help I got over the internet for using these plugin, my set up should run cucumber Runner files in parallel but they are always getting executed sequentially.
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<fork>true</fork>
<executable>C:\Program Files\Java\jdk1.8.0_201\bin\javac.exe</executable>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<parallel>classes</parallel>
<forkMode>perthread</forkMode>
<threadCount>2</threadCount>
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
<includes>
<include>**/*Runner.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Could you please advise me on whether or not I can dynamically change Include and Exclude for the Maven Surfire Plugin?
For example:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<includes>
<include>**/${param}Spec*.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
I would like to have $param passed from the command line when we perform the Maven test command.
Please give advice if you have a solution. I have tried argline and systemProperties
Thanks!
I don't think there is a way to pass dynamic parameter, but you can use below trick if you have limited combinations of exclusions/inclusions. Trick is using profiles with different combinations like combo1, combo2 etc. Then you can run maven build with specific profile & only those include/exclude will work.
Command = mvn clean package -P combo1
pom.xml
<profiles>
<profile>
<id>combo1</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<includes>
<include>**/Combo1Spec*.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>combo2</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<includes>
<include>**/Combo2Spec*.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
I am building an android app and I am trying to use external libraries (jar).
When I build project it throws
bad class file magic or version
I checked pom.xml files and I noticed that in the one jar it has the following
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
while in the other
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Could this justify the error?
I think that's because You can't use Java8 code in java7 project.