Skip to content

Commit 6842e0a

Browse files
committed
Merge branch 'wip/packaging' into release
2 parents 820c77f + 08f4d00 commit 6842e0a

File tree

1 file changed

+126
-6
lines changed

1 file changed

+126
-6
lines changed

microtrafficsim-ui/build.gradle

Lines changed: 126 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import org.gradle.internal.hash.HashUtil;
2+
13
plugins {
24
id 'application'
3-
id "edu.sc.seis.macAppBundle" version "2.1.6"
5+
id 'edu.sc.seis.macAppBundle' version '2.1.6'
6+
id 'nebula.ospackage' version '4.4.0'
47
}
58

6-
79
dependencies {
810
compile project(':microtrafficsim-core')
911

@@ -19,13 +21,20 @@ run {
1921
}
2022

2123

22-
mainClassName = "microtrafficsim.ui.Main"
24+
def distName = 'microtrafficsim'
25+
def distVersion = '1.0.0'
26+
def distRelease = '1'
27+
28+
def main = 'microtrafficsim.ui.Main'
29+
30+
31+
mainClassName = "${main}"
2332
macAppBundle {
24-
mainClassName = "microtrafficsim.ui.Main"
33+
mainClassName = "${main}"
2534
}
2635
jar {
2736
manifest {
28-
attributes "Main-Class": "$mainClassName"
37+
attributes "Main-Class": "${main}"
2938
}
3039

3140
from {
@@ -34,11 +43,122 @@ jar {
3443
}
3544

3645

46+
ospackage {
47+
packageName = "${distName}"
48+
version = "${distVersion}"
49+
release = "${distRelease}"
50+
os = LINUX
51+
type = BINARY
52+
53+
maintainer = 'github.com/sgs-us'
54+
uploaders = 'github.com/sgs-us'
55+
56+
into "/usr/share/${distName}"
57+
58+
from(jar.outputs.files) {
59+
into 'lib'
60+
}
61+
from(configurations.runtime) {
62+
into 'lib'
63+
}
64+
from(startScripts.outputDir) {
65+
into 'bin'
66+
exclude '*.bat'
67+
fileMode 0550
68+
}
69+
70+
link("/usr/bin/${distName}", "/usr/share/${distName}/bin/${distName}")
71+
}
72+
73+
task distRpm(type: Rpm) {
74+
dependsOn startScripts
75+
}
76+
77+
task distDeb(type: Deb) {
78+
dependsOn startScripts
79+
}
80+
81+
task distApp(type: Zip) {
82+
dependsOn createApp
83+
84+
from fileTree("${->project.buildDir}/${->project.macAppBundle.appOutputDir}/${->project.macAppBundle.appName}.app") {
85+
into 'microtrafficsim.app'
86+
}
87+
88+
destinationDir = file("${->project.buildDir}/distributions")
89+
archiveName = "${distName}_${distVersion}-${distRelease}_all.app.zip"
90+
}
91+
92+
distZip {
93+
archiveName = "$distName"
94+
95+
doLast {
96+
def name = "${distName}_${distVersion}-${distRelease}_all.zip"
97+
archivePath.renameTo(file("${->project.buildDir}/distributions/${name}"))
98+
}
99+
}
100+
101+
task writeArchPkgbuild() {
102+
dependsOn distZip
103+
104+
doLast {
105+
def distZipName = "${distName}_${distVersion}-${distRelease}_all.zip"
106+
def distZipNameVar = "\${pkgname}_\${pkgver}-\${pkgrel}_all.zip"
107+
def distTag = "v\${pkgver}"
108+
def distZipUrl = "https://github.com/sgs-us/microtrafficsim/releases/download/${distTag}/${distZipNameVar}"
109+
def distZipSha256 = HashUtil.sha256(file("${->project.buildDir}/distributions/${distZipName}")).asHexString()
110+
def tmpdir = "${->project.buildDir}/tmp/archpkg"
111+
file(tmpdir).mkdirs()
112+
113+
def pkgbuild = ""
114+
pkgbuild <<= "pkgname=${distName}\n"
115+
pkgbuild <<= "pkgver=${distVersion}\n"
116+
pkgbuild <<= "pkgrel=${distRelease}\n"
117+
pkgbuild <<= "pkgdesc='Microscopic Traffic Simulation using OpenStreetMap'\n"
118+
pkgbuild <<= "arch=('any')\n"
119+
pkgbuild <<= "url='https://github.com/sgs-us/microtrafficsim/'\n"
120+
pkgbuild <<= "license=('GPL-3.0')\n"
121+
pkgbuild <<= "\n"
122+
pkgbuild <<= "depends=('java-environment')\n"
123+
pkgbuild <<= "source=(\"${distZipUrl}\")\n"
124+
pkgbuild <<= "sha256sums=('${distZipSha256}')\n"
125+
pkgbuild <<= "\n"
126+
pkgbuild <<= "package() {\n"
127+
pkgbuild <<= " mkdir -p \"\${pkgdir}/usr/\"{bin,share}\n"
128+
pkgbuild <<= " cp -r \"\${pkgname}\" \"\${pkgdir}/usr/share/\"\n"
129+
pkgbuild <<= " rm \"\${pkgdir}/usr/share/\${pkgname}/bin/\${pkgname}.bat\"\n"
130+
pkgbuild <<= " chmod 755 \"\${pkgdir}/usr/share/\${pkgname}/bin/\${pkgname}\"\n"
131+
pkgbuild <<= " ln -s \"/usr/share/\${pkgname}/bin/\${pkgname}\" \"\${pkgdir}/usr/bin/\${pkgname}\"\n"
132+
pkgbuild <<= "}\n"
133+
134+
file("$tmpdir/PKGBUILD").write(pkgbuild.toString())
135+
}
136+
}
137+
138+
task distArchPkg(type: Zip) {
139+
dependsOn writeArchPkgbuild
140+
141+
from fileTree("${->project.buildDir}/tmp/archpkg") {
142+
into 'microtrafficsim'
143+
}
144+
145+
destinationDir = file("${->project.buildDir}/distributions")
146+
archiveName = "${distName}_${distVersion}-${distRelease}_all.archlinux.zip"
147+
}
148+
149+
150+
task distAll {
151+
dependsOn distZip
152+
dependsOn distRpm
153+
dependsOn distDeb
154+
dependsOn distArchPkg
155+
dependsOn distApp
156+
}
157+
37158

38159
// set jar, distribution and application name
39160
jar.baseName = 'microtrafficsim-ui'
40161
distributions.main.baseName = 'microtrafficsim-ui'
41162
startScripts.applicationName = 'microtrafficsim'
42163

43164
applicationDefaultJvmArgs = ['-Xmx3g']
44-

0 commit comments

Comments
 (0)