Build the same source tree using different plugins

(Likely a n00b question, appreciate your patience!)

I’ve written a Java library that depends on a third party library (opencv), which is available for both Android and PC.
I would like to make my library usable by either Android or PC (i.e. produce different artifacts depending on the circumstances). However, I cannot simply apply both the ‘com.android.library’ and the ‘java’ plugins and furthermore it is not clear to me how I can specify that the different artifacts (android/PC) depend on different variants of opencv.
Seems like this should be a common enough problem. What is the best practice for doing something like that?

Thanks!