Skip to content

Commit

Permalink
Add initial version of building binary
Browse files Browse the repository at this point in the history
Add shadow jar and jpackager plugins that allow the building of platform-specific binaries and installers.
  • Loading branch information
alkum committed Apr 8, 2022
1 parent 4f4be7e commit a4b36c4
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 2 deletions.
89 changes: 89 additions & 0 deletions desktopapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ plugins {
id 'application'
/* id 'distribution'*/ //todo as long we dont need a jar we leave that out, speeds up build
alias(libs.plugins.openjfx)
alias(libs.plugins.jpackage)
alias(libs.plugins.shadow)
}

apply from: '../buildSrc/bisq-version.gradle'
Expand Down Expand Up @@ -76,3 +78,90 @@ dependencies {
implementation 'org.fxmisc.richtext:richtextfx:0.10.9'

}

distZip.enabled = false
distTar.enabled = false
shadowDistZip.enabled = false
shadowDistTar.enabled = false

tasks.jpackage {
dependsOn rootProject.clean
dependsOn tasks.build, tasks.shadowJar

appName = "Bisq 2"
// Remove the -SNAPSHOT suffix from the version string (originally defined in build.gradle)
// Having it in would have resulted in an invalid version property for several platforms (mac, linux/rpm)
appVersion = version.replaceAll("-SNAPSHOT", "")
copyright = 'Copyright (c) 2013-2022 The Bisq developers'
appDescription = 'A decentralized bitcoin exchange network.'
vendor = 'Bisq'
mainClass = "bisq.desktopapp.Main"
mainJar = jar.archiveFileName.get()
verbose = true
// arguments = --arguments <main class arguments>
destination = "$buildDir/$distsDirName"
input = "$buildDir/$libsDirName"
licenseFile = "../LICENSE"
// resourceDir = --resource-dir <resource dir path> // TODO
runtimeImage = System.getProperty("java.home")
// launchers = --add-launcher <name>=<property file> // TODO add multiple launchers? desktopapp / satoshiapp

winMenu = true
winDirChooser = true
// winUpgradeUuid = win-upgrade-uuid <id string> // TODO
// winMenuGroup = --win-menu-group <menu group name> // TODO
winShortcut = true
winPerUserInstall = true
winConsole = false

// macPackageIdentifier = --mac-package-identifier <ID string> // TODO
// macPackageName = --mac-package-name <name string> // TODO
// macPackageSigningPrefix = --mac-package-signing-prefix <prefix string> // TODO
macSign = false
// macSigningKeychain = --mac-signing-keychain <file path> // TODO
// macSigningKeyUserName = --mac-signing-key-user-name <team name> // TODO

linuxPackageName = 'bisq2'
linuxDebMaintainer = '[email protected]'
linuxMenuGroup = 'Network'
linuxRpmLicenseType = 'AGPLv3' // https://fedoraproject.org/wiki/Licensing:Main?rd=Licensing#Good_Licenses
// This represents the linux package version (revision)
// By convention, this is part of the deb/rpm package names, in addition to the software version
linuxAppRelease = '1'
// linuxAppCategory = --linux-app-category <category value> // TODO
linuxShortcut = true

mac {
// Avoid error "The first number in an app-version cannot be zero or negative."
appVersion = appVersion.startsWith('0') ? '1.0.0' : appVersion
// icon = "icons/icons.icns" // TODO
}

linux {
// Had issues when using package-manager-installed-jdk
// Worked well when using IntelliJ IDEA SDKs (File > Project Structure > SDKs > + sign > Download JDK
runtimeImage = "/home/user/.jdks/openjdk-17.0.2"
// icon = "icons/icons.ico" // TODO
}

additionalParameters = ['--verbose']

// TODO Choose sane defaults
javaOptions = [
'-Dfile.encoding=UTF-8',
'-Dbisq.application.appName=bisq_Alice',
'-Dbisq.networkServiceConfig.supportedTransportTypes.0=CLEAR',
'-Dbisq.networkServiceConfig.seedAddressByTransportType.clear.0=127.0.0.1:8000',
'-Dbisq.networkServiceConfig.seedAddressByTransportType.clear.1=127.0.0.1:8001'
]

doLast() {
File binariesFolderPath = new File("$buildDir/$distsDirName")
ant.checksum(algorithm: 'SHA-256') {
ant.fileset(dir: "${binariesFolderPath}")
}
println "The binaries and checksums are ready:"
FileCollection collection = layout.files { binariesFolderPath.listFiles() }
collection.collect { it.path }.sort().each { println it }
}
}
18 changes: 17 additions & 1 deletion docs/dev-gradle.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,25 @@ To summarize:
direct and transitive.


## Package binaries

Platform-specific binaries and installers can be generated with

```
./gradlew :desktopapp:jpackage
```

Requirements[^7] for building on:
- Fedora: `rpm-build`
- Debian: `fakeroot`
- macOS: Xcode command line tools are required when the `--mac-sign` or `--icon` options are used.
- Windows: WiX 3.0 or later is required


[^1]: https://gradle.org/release-checksums/
[^2]: https://docs.gradle.org/7.4.1/userguide/platforms.html#sub:platforms-vs-catalog
[^3]: https://docs.gradle.org/7.4.1/userguide/platforms.html#sub:version-catalog-declaration
[^4]: https://docs.gradle.org/current/userguide/dependency_management_terminology.html#sub:terminology_dependency_constraint
[^5]: https://docs.gradle.org/7.4.1/userguide/rich_versions.html
[^6]: https://docs.gradle.org/current/userguide/java_platform_plugin.html
[^6]: https://docs.gradle.org/current/userguide/java_platform_plugin.html
[^7]: https://docs.oracle.com/en/java/javase/17/jpackage/packaging-overview.html#GUID-786E15C0-2CE7-4BDF-9B2F-AC1C57249134
6 changes: 5 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ bouncycastle-lib = { strictly = '1.67' } # Oldest version without known CVE
google-gson-lib = { strictly = '2.9.0' }
google-guava-lib = { strictly = '31.1-jre' }
i2p-lib = { strictly = '1.7.0' }
jpackage-plugin = { strictly = '1.3.1' }
junit-jupiter-lib = { strictly = '5.8.2' }
kotlindsl-plugin = { strictly = '2.1.7' }
logback-lib = { strictly = '1.2.11' }
lombok-lib = { strictly = '1.18.22' }
openjfx-plugin = { strictly = '0.0.12' }
protobuf-plugin = { strictly = '0.8.18' }
protobuf-java-lib = { strictly = '3.19.4' }
shadow-plugin = { strictly = '7.1.2' }
slf4j-lib = { strictly = '1.7.36' }
typesafe-config-lib = { strictly = '1.4.2' }

Expand Down Expand Up @@ -51,5 +53,7 @@ i2p = ['i2p-core', 'i2p-router', 'i2p-streaming']
# `alias(libs.plugins.protobuf)` mechanism, there is no risk of loading multiple versions.
[plugins]
kotlindsl = { id = 'org.gradle.kotlin.kotlin-dsl', version.ref = 'kotlindsl-plugin' }
jpackage = { id = 'org.panteleyev.jpackageplugin', version.ref = 'jpackage-plugin' }
openjfx = { id = 'org.openjfx.javafxplugin', version.ref = 'openjfx-plugin' }
protobuf = { id = 'com.google.protobuf', version.ref = 'protobuf-plugin' }
protobuf = { id = 'com.google.protobuf', version.ref = 'protobuf-plugin' }
shadow = { id = 'com.github.johnrengelman.shadow', version.ref = 'shadow-plugin' }

0 comments on commit a4b36c4

Please sign in to comment.