Build failing on sonar

With Maven 3+ we may face some issues while running sonar code coverage for the project in surefire plugin.
Looks line may be bug in maven or surefire, can't say right now.
Here is one of the weird error I have observed

Exception in thread "main" java.lang.NoClassDefFoundError: ${surefire/jvm/args}Caused by: java.lang.ClassNotFoundException: ${surefire.jvm.args} at$ at Method) at at java.lang.ClassLoader.loadClass( at sun.misc.Launcher$AppClassLoader.loadClass( at java.lang.ClassLoader.loadClass( not find the main class: ${surefire.jvm.args}.  Program will exit.

It took really long time and lots of effort to figure out the solution for this error.
sonar goal is expecting an argument as default but failed to get and hence its throwing error.

You will need to add one extra configuration (argLine) under build section in your pom file for surefire plugin.

Please add following section in your pom to fix this error.



Here i have just mentioned the argLine=-Xmx1024m (1GB of memory), you can add any dummy argument to make build pass.

May be recent version of maven/surefire may have fixed this issue.

Popular posts from this blog

Manage Docker images on local disk

Gradle or Maven - A Dilemma

Setup Docker slaves for Jenkins