Find number of available processors in maven (platform-independent)
-
03-06-2021 - |
سؤال
Is it possible to retrieve the number of available processors in maven in a platform-independent way? I'd like to be able to activate a profile if available_processors > 1
.
المحلول
There's no easy way to do that. You'd have to write a Maven extension that stores the result of Runtime.availableProcessors()
in a System Property. You'd have to put that extension in $Maven_HOME/lib/ext
(see MNG-4984). Writing a Maven Plugin is not enough, Plugin resolution happens after profile activation. I don't think it would be possible to write a custom ProfileActivator
, mainly because the pom.xml XSD won't allow it.
لا تنتمي إلى StackOverflow