I have tried below ways but nothing work...
i am trying to access jmx remotely from server.
<jvmArgs>
<jvmArg>-Dcom.sun.management.jmxremote.port=9999</jvmArg>
<jvmArg>-Dcom.sun.management.jmxremote.authenticate=false</jvmArg>
<jvmArg>-Dcom.sun.management.jmxremote.ssl=false</jvmArg>
</jvmArgs>
<!-- <systemPropertyVariables>
<com.sun.management.jmxremote.port>9999</com.sun.management.jmxremote.port>
<com.sun.management.jmxremote.authenticate>false</com.sun.management.jmxremote.a uthenticate>
<com.sun.management.jmxremote.ssl>false</com.sun.management.jmxremote.ssl>
</systemPropertyVariables> -->
<!-- <jvmArguments>
<jvmArgument>- Dcom.sun.management.jmxremote.port=9999</jvmArgument>
<jvmArgument>- Dcom.sun.management.jmxremote.authenticate=false</jvmArgument>
<jvmArgument>- Dcom.sun.management.jmxremote.ssl=false</jvmArgument>
</jvmArguments> -->
I also tried
<options>
<option>-Dcom.sun.management.jmxremote.port=9999</option>
<option>-Dcom.sun.management.jmxremote.authenticate=false</option>
<option>-Dcom.sun.management.jmxremote.ssl=false</option>
</options>
You can do this in few different ways.
Using the Maven Compiler Plugin
You can use the compileArgs property of the plugin to specify the Xmx, Xms, Xss VM arguments.
Below is an example
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<compilerArgs>
<arg>-Xmx512M</arg> // You can provide comma separated values if you have more than one
</compilerArgs>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
Refer to the Maven Compiler Plugin for more details.
Using the Maven Surefire Plugin
You can use the argLine property of the plugin to specify the Xmx, Xms, Xss VM arguments.
Below is an example
</project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<configuration>
<argLine>-Xmx512M</argLine> // You can provide comma separated values if you have more than one
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
Refer to the Maven Surefire Plugin for more details.
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 would like to know if there is a way to specify findbugs attribute for plugins, pluginList as maven dependencies instead as a file path.
I mean, if I use this configuration:
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.3</version>
<configuration>
<xmlOutput>true</xmlOutput>
<xmlOutputDirectory>target/site</xmlOutputDirectory>
<pluginList>/my/path/fb-contrib-6.2.3.jar</pluginList>
</configuration>
</plugin>
</plugins>
</reporting>
Findbugs load the plugins jar and analyze the code as I want. But as you can see, jar location is a fixed path. I would like to use something like this:
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.3</version>
<configuration>
<xmlOutput>true</xmlOutput>
<xmlOutputDirectory>target/site</xmlOutputDirectory>
<pluginList>
<dependency>
<groupId>com.mebigfatguy.fb-contrib</groupId>
<artifactId>fb-contrib</artifactId>
<version>6.2.3</version>
</dependency>
</pluginList>
</configuration>
</plugin>
</plugins>
</reporting>
Obviously, the last configuration does not work, but it is more convenient from a Maven point of view.
Yes you can do it with the <plugins> parameter, and not <pluginList>.
Quoting the documentation:
The pluginList option specifies a comma-separated list of optional BugDetector Jar files to add.
...
The plugins option defines a collection of PluginArtifact to work on.
A sample configuration would be:
<configuration>
<plugins>
<plugin>
<groupId>com.mebigfatguy.fb-contrib</groupId>
<artifactId>fb-contrib</artifactId>
<version>6.2.3</version>
</plugin>
</plugins>
</configuration>
I want to run test classes whose name end with ResourceTest.java, so I defined following execution.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</configuration>
<version>2.12.2</version>
<executions>
<execution>
<id>resource-tests</id>
<phase>resource-tests</phase>
<goals>
<goal>resource-tests</goal>
</goals>
<configuration>
<includes>**/*ResourceTest.java</includes>
<!-- <exludes>**/*.java</exludes> -->
</configuration>
</execution>
</executions>
</plugin>
But I'm not sure how to run this, I've searched a lot and I'm missing something.
I tried surefire:test, it skipped all the test cases as defined in above configuration. So, I tried surefire:resource-tests, maven is saying no goal is not defined.
I'm using eclipse to run my maven build, by passing these parameters. How can I run by the execution id?
How to select a specific execution when running with surefire:test when I've mulltiple executions defined in my pom?
What am I missing? Any help would be appreciated.
There are several problems with your current configuration :
you are forcing the maven-surefire-plugin to be executed in the resource-tests phase but this phase does not exist. You should delete that declaration to keep the default plugin binding phase, which is test.
you are invoking the goal resource-tests but maven-surefire-plugin does not define such a goal.
the <includes> element is ill-defined. There should be a <include> tag under it.
you are excluding all Java files from the plugin configuration so no test will be run
the configuration of the plugin should be done under the <configuration> element not for each <executions>.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.2</version>
<configuration>
<includes>
<include>**/*ResourceTest.java</include>
</includes>
</configuration>
</plugin>
When you have multiple executions and you want "select" one of them, you can use a profile:
<profiles>
<profile>
<id>resource-tests</id>
<properties>
<test-classes>**/*ResourceTest.java</test-classes>
</properties>
</profile>
<profile>
<id>task-tests</id>
<properties>
<test-classes>**/*TaskTest.java</test-classes>
</properties>
</profile>
</profiles>
with the following plugin configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.2</version>
<configuration>
<includes>
<include>${test-classes}</include>
</includes>
</configuration>
</plugin>
With such a configuration:
when you run mvn clean test -Presource-tests, only the classes matching **/*ResourceTest.java will be tested
when you run mvn clean test -Ptask-tests, only the classes matching **/*TaskTest.java will be tested
I have a multi-module Maven 3 project. We are using Cobertura as our code coverage tool, but the excludes tag is not working. We have some bad tests from a package we inherited from another team, but need to consume.
The structure is as follows:
<module1>
.../com/aaaa/...
<module2>
.../com/aaaa/...
<module3>
.../com/aaaa/...
...
<moduleN>
packages with .../com/xx/... WE WANT TO EXCLUDE
pacakges with .../com/aaaa/... WE WANT TO STILL INCLUDE
parent-pom.xml
Our parent POM is configured as such:
<build>
...
<plugins>
<other plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<aggregate>true</aggregate>
<outputDirectory>coverageReports</outputDirectory>
<instrumentation>
<excludes>
<exclude>**/com/xx/**/*</exclude>
</excludes>
</instrumentation>
/configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<aggregate>true</aggregate>
<outputDirectory>coverageReports</outputDirectory>
</configuration>
</plugin>
</plugins>
</reporting>
I've tried a lot of various configurations, including:
Excluding the test/com/xx files as well
Adding the exclusion pattern to ignore
Setting exclude in the reporting AND build section
Multiple permutations of the exclude file pattern, including being more implicit
Any thoughts? I've had some other build engineers look at my various POM configurations and it always seems valid, but we never get accurate reports.
Put the exclude configuration into the pom.xml file of moduleN that you want to do the exclusions from:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<instrumentation>
<excludes>
<exclude>com/aaa/**/*.class</exclude>
<exclude>com/xxx/**/*.class</exclude>
</excludes>
</instrumentation>
</configuration>
</plugin>