Android and java builds of the same library


I have a multiproject build which result is a set of java libraries (using the java plugin). As a next step I want to build this libraries for Android (using the plugin). Currently it’s achieved using two separate build scripts (in the root project and all subprojects).This scripts differ a lot, but still have some common parts, like sourceSets, compiler options, application of jacoco.

What is the correct way to organize this builds?