crotwell / gradle-macappbundle

A Gradle Plugin to create a Mac OSX .app application and dmg based on the project.
Apache License 2.0
94 stars 33 forks source link

Document method to disable the attempt at DMG creation on Windows/Linux. #33

Closed msgilligan closed 8 years ago

msgilligan commented 8 years ago

I do my builds on Mac OS X, but as I'm asking others to contribute to the project, their builds are failing on Windows and Linux. I've been telling them to comment out the plugin configuration lines, but there has to be a better way.

I'm sure there's already a way to do it by reconfiguring the existing Gradle tasks. If I find it, I'll share it here. It should certainly be documented.

crotwell commented 8 years ago

Issue is that you have "bundleJRE = true" but do not set jreHome, so in this case macAppBundle tries to find where java in installed by running /usr/libexec/java_home. Actually there was another bug in the printlin that was trying to say this, so the error message was confusing.

I will attempt to move that code out of the configure section, and only run it right before task execution, so that as long as you do not actually run a task that needs jreHome, it should be ok.

This is a little weird in that the createApp task, or at least the bundleJRE task, really needs to know where to get the JRE from in order to bundle it, and on a non-Mac system, you probably have to set jreHome manually as this is an important part of the task's configuration. But to actually do the bundle each of your developers would need to download the mac java. Perhaps instructions for your developers to download the oracle mac jre into the development directory and then you set jreHome to something in the build directory would help? Still seems awkward and I am not sure of the best way around this.

msgilligan commented 8 years ago

Thanks for the response. Is there an easy way to disable the tasks on platforms other than Mac? Builds of the Mac version will be done on the Mac (at least for now).

msgilligan commented 8 years ago

Here's a workaround that solves my problem in the short run:

// For now, only bundle the JRE if building under Mac OS X
bundleJRE = System.getProperty("os.name").toLowerCase().contains("mac os")
crotwell commented 8 years ago

I think I have fixed this with commit 8cd2fba, changes in github. Will try to push out a new version shortly.

I think your work-around should be ok as long as you are not too international. I think there are potential problems in the locale is non-english but not sure. Other option is to use: import org.apache.tools.ant.taskdefs.condition.Os and then bundleJRE = Os.isFamily(Os.FAMILY_MAC)

msgilligan commented 8 years ago

This technique was suggested by someone from Gradle, Inc. on their support forum, so I'm assuming the string is not localized.

crotwell commented 8 years ago

Should be fixed in 2.1.2, please let me know if you still have troubles.