Skip to content

Instantly share code, notes, and snippets.

@nwillc
Created May 19, 2018 16:16
Show Gist options
  • Save nwillc/4489aaa4629a64c68f6c943f51c2c075 to your computer and use it in GitHub Desktop.
Save nwillc/4489aaa4629a64c68f6c943f51c2c075 to your computer and use it in GitHub Desktop.
Gradle task to build an OS X app
task osxApp {
dependsOn jar
doLast {
def dist = "${buildDir}/app/${project.name}.app"
mkdir("$dist/Contents/MacOS")
mkdir("$dist/Contents/Resources")
ant.copy(file: "src/main/app/Info.plist", todir: "$dist/Contents")
ant.copy(file: "src/main/app/launcher", todir: "$dist/Contents/MacOS") {
filterset {
filter(token: 'APP_JAR', value: "${project.name}-${version}.jar")
filter(token: 'APP_NAME', value: project.name)
filter(token: 'JAVA_VERSION', value: jvm_version)
}
}
ant.copy(file: "src/main/app/application.icns", todir: "$dist/Contents/Resources")
ant.copy(file: "build/libs/${project.name}-${version}.jar", todir: "$dist/Contents/MacOS")
project.exec {
commandLine('chmod', '+x', "$dist/Contents/MacOS/launcher")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment