Barmaley
Barmaley

Reputation: 16363

Gradle build for 2 platforms: JavaFX and Android. How to?

I have an app that works on 2 platforms: Android and JavaFX.

Basically, my sources look like this:

java
   |
   |---android //android specific sources
   | 
   |---common  //plain java common sources
   |
   |---fx      //JavaFX specific sources

For the moment I'm using 2 different build files one of them build.android.gradle and the other build.fx.gradle and instantly renaming them to build.gradle depending on the situation. I mean it is an odd and real nightmare.

My intention is to have either 2 different build.gradle files (placed in different folders?) or a single build.gradle which builds APK for Android and JAR for JavaFX

The question is: how to achieve this?

Upvotes: 3

Views: 182

Answers (1)

3Fish
3Fish

Reputation: 688

I suggest using gradles suggested project structure and have both code bases and the java core be a separate subproject. The project JavaFx and Android can both depend on the java project. Then you can either build just one of them or both. Gradle will automatically rebuild the java base as well, when needed.

See Gradle project structure

Upvotes: 2

Related Questions