Skip to content

Commit a027d41

Browse files
committed
Update build.gradle: remove macappbundle plugin, add application plugin, + other improvements
1 parent e14895a commit a027d41

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+184
-92
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
if: matrix.os == 'macOS-latest'
2121
uses: eskatos/gradle-command-action@v1
2222
with:
23-
arguments: createApp
23+
arguments: createMacApp
2424
wrapper-cache-enabled: true
2525
dependencies-cache-enabled: true
2626
- name: Create Linux tar.gz

.idea/blobsaver.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules/blobsaver.main.iml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules/blobsaver.test.iml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

blobsaver.iml

Lines changed: 0 additions & 11 deletions
This file was deleted.

build.gradle

Lines changed: 106 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,26 @@
1616
* along with blobsaver. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19+
import org.apache.tools.ant.filters.ReplaceTokens
20+
import org.apache.tools.ant.taskdefs.condition.Os
21+
1922
plugins {
2023
id 'java'
24+
id 'application'
2125
id 'edu.sc.seis.launch4j' version '2.4.6' // for bundling into .exe
22-
id "edu.sc.seis.macAppBundle" version "2.3.0" // for bundling into .app
2326
id 'com.github.johnrengelman.shadow' version '6.0.0' // for fat jar
2427
id 'com.github.ben-manes.versions' version '0.29.0'
2528
}
2629

27-
version null
28-
sourceCompatibility = 1.8
29-
3030
/*
3131
* REMEMBER: also update the version string in:
3232
* - Main.java
33-
* - blobsaver.iss
3433
*/
35-
String appVersion = "v2.5.3"
34+
version "v2.5.3"
35+
sourceCompatibility = 1.8
36+
mainClassName = "airsquared.blobsaver.app.Main"
37+
String appIdentifier = "airsquared.blobsaver.app"
38+
String copyright = "Copyright (c) 2020 airsquared"
3639

3740
repositories {
3841
mavenCentral()
@@ -48,67 +51,112 @@ dependencies {
4851
testImplementation 'org.junit.jupiter:junit-jupiter:5.6.2'
4952
}
5053

51-
compileJava {
52-
options.fork = true
53-
options.forkOptions.javaHome = new File("${System.properties.'java.home'}")
54-
options.compilerArgs << "-XDignore.symbol.file=true"
54+
disableTasks jar, startScripts, distTar, distZip, startShadowScripts, shadowDistTar, shadowDistZip
55+
56+
private static void disableTasks(Task... tasks) {
57+
for (Task task : tasks)
58+
task.enabled = false
59+
}
60+
private ExecResult exec(String... args) {
61+
exec { commandLine args }
5562
}
5663

5764
jar {
58-
manifest {
59-
attributes 'Main-Class': 'airsquared.blobsaver.app.Main'
60-
}
61-
jar.enabled = false
62-
jar.finalizedBy shadowJar // make shadowJar always overwrite the jar task
65+
finalizedBy shadowJar // make shadowJar always overwrite the jar task
6366
}
6467

6568
shadowJar {
66-
archiveClassifier.set(null) // remove '-all' suffix
69+
archiveFileName.set "blobsaver.jar"
6770
// the jna libraries are bundled separately to reduce application size
6871
exclude "about.fxml", "about.css",
6972
"**/aix-ppc/*", "**/aix-ppc64/*", "**/linux-ppc/*", "**/linux-ppc64le/*", "**/linux-s390x/*", "**/linux-mips64el/*",
7073
"**/darwin/*", "**/win32-x86/*", "**/win32-x86-64/*", "**/openbsd-x86/*", "**/openbsd-x86-64/*",
7174
"**/freebsd-x86/*", "**/freebsd-x86-64/*", "**/sunos-sparc/*", "**/sunos-sparcv9/*", "**/sunos-x86/*", "**/sunos-x86-64/*"
7275
includeEmptyDirs = false
76+
distTar.enabled = false
7377
}
7478

75-
macAppBundle {
76-
mainClassName = "airsquared.blobsaver.app.Main"
77-
icon = "icons/blob_emoji.icns"
78-
backgroundImage = "icons/dmg_background.png"
79-
appName = 'blobsaver'
80-
dmgName = 'blobsaver-macos'
81-
volumeName = 'blobsaver-macos'
82-
jarTask = "shadowJar"
83-
bundleExtras.put("LSUIElement", "YES")
84-
createDmg.group = "build"
85-
}
86-
87-
task copyFilesIntoMacApp(dependsOn: createApp) {
88-
inputs.files(createApp.outputs)
79+
task createMacApp(dependsOn: shadowJar) {
80+
inputs.files(shadowJar.outputs)
8981
inputs.dir("${projectDir}/dist/macos")
9082
inputs.files("${projectDir}/LICENSE", "${projectDir}/libraries_used.txt")
9183
outputs.dir("${buildDir}/macApp/blobsaver.app")
9284

93-
doFirst {
85+
doLast {
9486
copy {
95-
from "${projectDir}/dist/macos/Frameworks"
96-
into "${buildDir}/macApp/blobsaver.app/Contents/Frameworks"
87+
from "${projectDir}/dist/macos/Contents"
88+
into "${buildDir}/macApp/blobsaver.app/Contents"
9789
}
9890
copy {
99-
from "${projectDir}/dist/macos/tsschecker"
100-
into "${buildDir}/macApp/blobsaver.app/Contents/MacOS"
91+
from "${projectDir}/dist/macos/Info.plist"
92+
expand(CFBundleIdentifier: appIdentifier, NSHumanReadableCopyright: copyright, JVMMainClassName: mainClassName, CFBundleName: project.name,
93+
version: version)
94+
into "${buildDir}/macApp/blobsaver.app/Contents"
10195
}
10296
copy {
10397
from "${projectDir}/LICENSE", "${projectDir}/libraries_used.txt"
10498
into "${buildDir}/macApp/blobsaver.app/Contents/Resources"
10599
}
100+
copy {
101+
from shadowJar.archiveFile into "${buildDir}/macApp/blobsaver.app/Contents/Java"
102+
}
106103
}
107-
createApp.finalizedBy copyFilesIntoMacApp
108-
group = "macappbundle"
109104
}
110105

111-
task createLinuxTargz(type: Tar, dependsOn: shadowJar) {
106+
task createDmg(dependsOn: createMacApp, group: "build") {
107+
inputs.files(createMacApp.outputs)
108+
inputs.dir("${buildDir}/macApp")
109+
inputs.dir("${projectDir}/dist/macos")
110+
111+
doLast {
112+
copy {
113+
from "${projectDir}/dist/macos/dmg_background.png" into "${buildDir}/macApp/.background"
114+
}
115+
def tmpDmgFile = "${buildDir}/tmp/dmg/blobsaver-macos.dmg"
116+
mkdir "${buildDir}/tmp/dmg"
117+
mkdir "${buildDir}/distributions"
118+
if (new File("/Volumes/blobsaver").exists()) {
119+
// if volume already mounted, maybe due to previous build, unmount
120+
exec "hdiutil", "detach", "/Volumes/blobsaver"
121+
}
122+
exec "hdiutil", "create", "-srcfolder", "${buildDir}/macApp", "-format", "UDRW", "-fs", "HFS+",
123+
"-volname", "blobsaver", "-attach", "-ov", tmpDmgFile
124+
125+
if (!new File("/Volumes/blobsaver").exists()) {
126+
throw new GradleException("Unable to find volume mount point to set background image.")
127+
}
128+
// https://stackoverflow.com/a/1513578
129+
exec "osascript", "-e", """
130+
tell application "Finder"
131+
tell disk "blobsaver"
132+
open
133+
set current view of container window to icon view
134+
set toolbar visible of container window to false
135+
set statusbar visible of container window to false
136+
set the bounds of container window to {0, 0, 453, 478}
137+
set viewOptions to the icon view options of container window
138+
set arrangement of viewOptions to not arranged
139+
set icon size of viewOptions to 72
140+
set background picture of viewOptions to file ".background:dmg_background.png"
141+
make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
142+
set position of item "blobsaver.app" of container window to {160, 205}
143+
set position of item "Applications" of container window to {360, 205}
144+
set position of item ".background" of container window to {100, 550}
145+
set position of item ".fseventsd" of container window to {120, 550}
146+
update without registering applications
147+
close
148+
end tell
149+
end tell
150+
"""
151+
// sleep 4000
152+
exec "hdiutil", "detach", "/Volumes/blobsaver"
153+
exec "hdiutil", "convert", tmpDmgFile, "-format", "UDZO", "-imagekey", "zlib-level=9", "-ov", "-quiet",
154+
"-o", "${buildDir}/distributions/blobsaver-macos.dmg"
155+
}
156+
assemble.dependsOn createDmg
157+
}
158+
159+
task createLinuxTargz(type: Tar, dependsOn: shadowJar, group: "build") {
112160
inputs.files(shadowJar.outputs)
113161
inputs.file("${buildDir}/libs/blobsaver.jar")
114162
inputs.dir("${projectDir}/dist/linux/")
@@ -120,48 +168,55 @@ task createLinuxTargz(type: Tar, dependsOn: shadowJar) {
120168
from "${buildDir}/libs/blobsaver.jar", "${projectDir}/dist/linux/"
121169

122170
assemble.dependsOn createLinuxTargz
123-
group = "build"
124171
}
125172

126173
launch4j { // Windows only, don't use this, use createWindowsInstaller
127174
mainClassName = "airsquared.blobsaver.app.Main"
128-
copyright = "Copyright (c) 2020 airsquared"
175+
launch4j.copyright = copyright
129176
downloadUrl = "https://github.com/airsquared/blobsaver/wiki/Making-sure-you-have-the-right-Java-version"
130-
icon = "${projectDir}/icons/blob_emoji.ico"
177+
icon = "${projectDir}/dist/windows/blob.ico"
131178
mutexName = "airsquared.blobsaver.app"
132-
windowTitle = "blobsaver " + appVersion
179+
windowTitle = "blobsaver"
180+
jar = "${buildDir}/libs/blobsaver.jar"
133181
jreRuntimeBits = "64"
134182
jreMinVersion = "1.8.0"
135183
jreMaxVersion = "1.8.0_999"
136184
createExe.dependsOn shadowJar
137185
}
138186

139187
// if your platform isn't Windows, wine is required to run this task
140-
task createWindowsInstaller(dependsOn: createExe) {
188+
task createWindowsInstaller(dependsOn: createExe, group: "build") {
141189
inputs.files(createExe.outputs)
142190
inputs.dir("${projectDir}/dist/windows/")
143191
inputs.file("${buildDir}/launch4j/blobsaver.exe")
144192
outputs.file("${buildDir}/distributions/blobsaver-windows.exe")
145193

146194
doFirst {
195+
delete "${buildDir}/tmp/innosetup"
147196
copy {
148-
from "${projectDir}/dist/windows/", "${buildDir}/launch4j/blobsaver.exe"
149-
into "${buildDir}/tmp/innosetup/"
150-
197+
from "${projectDir}/dist/windows"
198+
into "${buildDir}/tmp/innosetup"
151199
rename "LICENSE_windows", "LICENSE"
152200
rename "libraries_used_windows.txt", "libraries_used.txt"
153201
}
154-
new File("${buildDir}/distributions/").mkdirs()
202+
copy {
203+
from "${projectDir}/dist/windows/blobsaver.iss"
204+
filter(ReplaceTokens, tokens: [MyAppName: project.name, MyAppVersion: version, AppMutex: appIdentifier])
205+
into "${buildDir}/tmp/innosetup"
206+
}
207+
copy {
208+
from "${buildDir}/launch4j/blobsaver.exe" into "${buildDir}/tmp/innosetup/files"
209+
}
210+
mkdir "${buildDir}/distributions/"
155211
println "running Inno Setup Compiler"
156212
exec {
157213
workingDir = projectDir
158-
if (System.getProperty("os.name").toUpperCase().contains("WINDOWS")) {
159-
commandLine 'gradle\\InnoSetup6\\ISCC.exe', '/Qp', 'blobsaver.iss'
214+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
215+
commandLine "gradle\\InnoSetup6\\ISCC.exe", "/Qp", "${buildDir}\\tmp\\innosetup\\blobsaver.iss"
160216
} else {
161-
commandLine "wine", "gradle/InnoSetup6/ISCC.exe", "/Qp", "blobsaver.iss"
217+
commandLine "wine", "gradle/InnoSetup6/ISCC.exe", "/Qp", "${buildDir}/tmp/innosetup/blobsaver.iss"
162218
}
163219
}
164220
}
165221
assemble.dependsOn createWindowsInstaller
166-
group = "build"
167222
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)