I’m still somewhat new to Gradle. I’m in a process to check if I can upgrade an old ant script to gradle. This build creates a JavaFX jar (i.e. the ant task fx:jar, not the normal jar), merges and obfuscate some of our internal libs to the main jar and then builds installers for all platforms (the last step is done in separate build script because it must be run on each target hardware because of javafx). Anyway the idea is to do the compile/test/obfuscate in one part/only once and do the packaging in paraller (since it must anyway be done on each target platform).
I would like to do the same in gradle. Has anyone experience with this?
The only gradle+javafx related “thing” seems to be https://bitbucket.org/shemnon/javafx-gradle/ and that has not been updated since 2014-10-30. Also that does not seems to give as much configuration as the ant tasks do, e.g. I need a custom .iss file override. Is the only option to try to use the ant tasks from gradle? (I have tested the javapackager command line utility a bit, but the ant task seems better).
Also for proguard, it seems all the examples I have found use local paths for injars. If one of the injars comes from internal repo, I guess the only way is to download it first to some folder under build or try to search the gradle cache? Just if there is a more “gradle way” to do it, it would be nice to know. Ultimately, the best would be if I could just create an “obfuscate” configuration scope and those would be automatically merged (also essentially removing the merged dependencies), this is something I know is doable in ant+ivy (since I have done it, but it was somewhat ugly implementation). Then I could maybe use a separate module which would use that as a “library”/dependency and create a thin JavaFX wrapper jar to launch it.
I think the only practical choise is to use the javafx ant tasks from gradle. While learning how this is done I ended up at http://stackoverflow.com/questions/21175597/how-to-set-gradle-custom-ant-task-classpath (because the overrides for certain configurations e.g. inno setup .iss script must be at certain path) where one comment pointed out that I could list every lib in a source set with
sourceSets.main.runtimeClasspath.asPath
So building a custom configuration and using the libs directly from the cache might be actually easy, I might be able to use the packaging tasks without downloading the dependencies first to the build folder.
It seems the proguard gradle task is able to take a configuration object (e.g. configurations.obfuscate if I have ‘obfuscate’ configuration) directly for injars and such settings so this is super easy!
I ended up learning to write plugins (not that difficult to do after all) so this this can be considered as solved.
I found out this blog post: http://ryansblog.jptech.ca/2012/12/javafx-and-gradle.html which was of great help. So the best option for these kind of problems in general seems to be writing custom plugins and also for javafx related packaging just wrap the ant tasks. Let me know if there are better options.
Even if its some old post: because Danno Ferrin stopped the development of his plugin, I created the javafx-gradle-plugin which is working for current JDK 8 (and even OpenJDK/OpenJFX).
P.S.: I answered to this, because I searched for “javafx gradle” with duckduckgo and found this discussion on the first page don’t want to have all users being frustrated with some old not-anymore-maintained plugin