I have read about maven parallel build configuration in this. So how I can display all non thread safe plugins? Is there something like "plugin-not-safe-list" command in maven?
REM something like that to display all p[lugins without @threadSafe annotation
mvn help:plugin-not-safe-list
Now when you build Maven warns about plugins not marked as threadsafe:
[WARNING] *****************************************************************
[WARNING] * Your build is requesting parallel execution, but project *
[WARNING] * contains the following plugin(s) that have goals not marked *
[WARNING] * as @threadSafe to support parallel building. *
[WARNING] * While this /may/ work fine, please look for plugin updates *
[WARNING] * and/or request plugins be made thread-safe. *
[WARNING] * If reporting an issue, report it against the plugin in *
[WARNING] * question, not against maven-core *
[WARNING] *****************************************************************
[WARNING] The following plugins are not marked @threadSafe in Root Maven Parent:
[WARNING] com.googlecode.maven-download-plugin:download-maven-plugin:1.3.0
[WARNING] Enable debug to see more precisely which goals are not marked @threadSafe.
[WARNING] *****************************************************************
You can write custom rule for maven-enforcer-plugin and use it for running on your maven project.
You might also want to use the mojo-executor to parse the plugin.xml
file for checking its "thread safe" property.
A little elaboration on when and why you should use the above.
When you are working in CI/CD environment, and you want to employ the parallel compilation via maven, you should constantly monitor that your developers are not adding non-thread safe plugins, in order to ensure the consistency and correctness of the CI/CD. In order to achieve that, you can use the above mentioned maven-envorcer-plugin with custom rule. Your custom rule can use the Maven Plugin API (maven project, etc.) in order to search all the plugins in the projects, and then use the mojo-executor lib in order to read the threadSafe
property of each plugin (since the maven API does not provide that). mojo-executor lib has tools to parse the plugin.xml
file of a maven plugin where the threadSafe
property resides.
Once found, you can fail the maven build.
If you want to see only the list of the non-thread safe plugins, you can use the same technique, and just list the plugins which threadSafe
property is false.
You can then configure the maven-enforcer-plugin
to use the custom rule (for example, a profile of the project), and run it via command line in a single maven command.
BTW, what happens when you find a non-thread safe plugin in your development project, and there are no thread safe alternatives, is another question, which is also solvable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With