Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How see all non threadsafe plugins in maven?

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
like image 409
Cherry Avatar asked Jun 25 '14 11:06

Cherry


2 Answers

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] *****************************************************************
like image 95
caduceus Avatar answered Oct 19 '22 12:10

caduceus


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.

like image 36
Genry Avatar answered Oct 19 '22 11:10

Genry