Subproject variant selection in Maven-publish plugin

My projects consists of 3 subprojects:

  • common” uses java plugin
  • lib” depends on “common” and uses plugin
  • purejava” depends on “common” and uses java plugin

I use the maven-publish plugin to publish “common” and “lib”. It has automatically picked up the dependency of “lib” to “common”:

api project(':common')

and added it to the generated pom.

I want to make 2 variants of “common” so that one of them is used in the “lib” subproject and the other to “purejava” subproject. How would I do that (using configurations?)? Is it possible that the maven-publish picks up the correct subproject variant dependency from “lib”'s depenencies.