简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM