forked from nehemiaharchives/bbl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
216 lines (181 loc) · 7.08 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
buildscript {
ext {
kotlin_version = '1.7.20'
lucene_version = '9.4.0'
tinlylog_version = '2.5.0'
junit_version = '5.9.1'
}
}
plugins {
id 'org.jetbrains.kotlin.jvm' version "$kotlin_version"
id 'org.jetbrains.kotlin.plugin.serialization' version "$kotlin_version"
id 'application'
id "org.beryx.jlink" version "2.25.0"
id "org.javamodularity.moduleplugin" version "1.8.12"
}
group = 'org.gnit.bible'
version = '1.4'
task versionTxt() {
doLast {
new File(projectDir, "src/main/resources/version.txt").text = """
bbl version $version
While you are in front of your console, you are not alone. God is with you.
Always go back to the Word of God especially in difficulty.
""".stripIndent()
}
}
repositories {
mavenCentral()
}
dependencies {
implementation "com.github.ajalt.clikt:clikt:3.5.0"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1"
implementation 'org.slf4j:slf4j-api:2.0.3'
implementation "org.tinylog:slf4j-tinylog:$tinlylog_version"
implementation "org.tinylog:tinylog-impl:$tinlylog_version"
implementation 'net.java.dev.jna:jna:5.12.1'
//search
implementation 'com.google.jimfs:jimfs:1.2'
implementation "org.apache.lucene:lucene-queryparser:$lucene_version"
implementation "org.apache.lucene:lucene-analysis-common:$lucene_version"
implementation "org.apache.lucene:lucene-analysis-smartcn:$lucene_version"
implementation "org.apache.lucene:lucene-analysis-kuromoji:$lucene_version"
implementation "org.apache.lucene:lucene-analysis-nori:$lucene_version"
implementation "org.apache.lucene:lucene-analysis-morfologik:$lucene_version"
//test
implementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junit_version"
}
//https://stackoverflow.com/questions/25873971/docker-cache-gradle-dependencies
task resolveDependencies {
doLast {
project.rootProject.allprojects.each { subProject ->
subProject.buildscript.configurations.each { configuration ->
configuration.resolve()
}
subProject.configurations.each { configuration ->
if(configuration.canBeResolved == true){
configuration.resolve()
}
}
}
}
}
test {
useJUnitPlatform()
}
compileKotlin {
kotlinOptions.jvmTarget = '17'
}
compileTestKotlin {
kotlinOptions.jvmTarget = '17'
}
sourceSets {
main {
resources {
srcDirs "src/main/resources"
}
}
}
processResources {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
processResources.dependsOn(versionTxt)
compileKotlin.destinationDirectory = compileJava.destinationDirectory
application {
mainClassName = 'org.gnit.bible.MainKt'
mainModule = 'org.gnit.bible'
}
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from('src/main/resources') {
include 'data/**/*.txt'
}
exclude 'tinylog-dev.properties'
}
jlink {
mergedModule {
additive = true
forceMerge "kotlin"
}
def resourceDir = "src/main/resources/installer"
launcher {
name = 'bbl'
}
//https://badass-jlink-plugin.beryx.org/releases/latest/#_jpackage
jpackage {
installerName = 'bbl'
appVersion = "$version"
installerOptions += [
'--copyright', 'Copyright © 2022, Joel H. Ide, gnit.org',
'--vendor', 'Gospel and Information Technology',
'--description', 'bbl, command line bible reader'
]
//https://wix-tutorial-ja.github.io/ch01/index.html
if (org.gradle.internal.os.OperatingSystem.current().windows) {
icon = "$resourceDir/bbl.ico"
installerOptions += ['--win-per-user-install',
'--win-dir-chooser',
'--win-menu',
'--win-shortcut',
'--resource-dir', (resourceDir + "/windows")]
imageOptions += ['--win-console']
installerType = 'msi'
targetPlatform("windows-x64") {
//jdkHome = "C:\\Program Files\\OpenJDK\\jdk-16"
jdkHome = "$System.env.JAVA_HOME"
}
outputDir = "jpackage/windows"
}
//https://docs.oracle.com/javase/jp/14/docs/specs/man/jpackage.html
//https://developer.apple.com/jp/developer-id/
//https://stackoverflow.com/questions/44081611/how-can-i-change-the-icon-used-by-javapackager-for-pkg-installers
if (org.gradle.internal.os.OperatingSystem.current().macOsX) {
icon = "$resourceDir/bbl.icns"
installerType = 'pkg'
installerOptions += [/*'--mac-sign', //TODO input after enrolling developer program
'--mac-signing-key-user-name', 'x',*/
'--resource-dir', (resourceDir + "/macos")]
outputDir = "jpackage/macos"
}
//https://docs.oracle.com/en/java/javase/16/jpackage/override-jpackage-resources.html#GUID-405708DC-0243-49FC-84D9-B2A7F0A011A9
//https://docs.oracle.com/javase/jp/14/jpackage/override-jpackage-resources.html#GUID-1B718F8B-B68D-4D46-B1DB-003D7729AAB6
//https://www.debian.org/doc/manuals/debian-faq/pkg-basics.ja.html#maintscripts
//https://www.ep.sci.hokudai.ac.jp/~epnetfan/zagaku/2000/1006/deb-make.html
//https://github.com/ewxrjk/greed/tree/master/debian
//https://www.debian.org/doc/debian-policy/ch-controlfields.html
//https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html
if (org.gradle.internal.os.OperatingSystem.current().linux) {
icon = "$resourceDir/bbl.png"
installerOptions += ['--install-dir', '/usr/local/lib',
'--resource-dir', (resourceDir + "/linux"),
'--linux-deb-maintainer', '[email protected]'
]
installerType = 'deb'
targetPlatform("linux-x64") {
//in wsl2
//jdkHome = "/usr/lib/jvm/java-17-openjdk-amd64"
//in gradle:7.5.1-jdk17-focal docker image
jdkHome = "/opt/java/openjdk"
}
outputDir = "jpackage/linux"
}
}
tasks.register('cookbook') {
doLast {
println "deleting deb package file in cookbook dir."
delete fileTree('bbl_install/files') {
include '*.deb'
}
println "copying new deb to cookbook dir"
copy {
from layout.buildDirectory.dir("jpackage/linux")
include "*.deb"
into "bbl_install/files"
}
println "integration test ready for linux. move to cookbook dir and run: bundle exec kitchen test"
}
}
}