-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
264 lines (228 loc) · 7.92 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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.13'
}
/*
* Group name
*/
group 'ch.unibas.dmi.dbis'
/*
* The version is read
*/
version = readVersion()
/*
* Adding a description
*/
description = """
short description
Project name: ${project.name}
brief(er) description
"""
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
repositories {
mavenCentral()
}
def javafxversion = '17'
javafx {
version = javafxversion
modules = [ 'javafx.controls', 'javafx.web', 'javafx.base']
}
dependencies {
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.3'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.9.3'
implementation group: 'org.controlsfx', name: 'controlsfx', version: '11.1.2'
implementation group: 'com.j2html', name: 'j2html', version: '0.88'
// https://mvnrepository.com/artifact/commons-lang/commons-lang
implementation group: 'commons-lang', name: 'commons-lang', version: '2.6'
implementation group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1'
implementation 'com.intellij:annotations:12.0'
implementation 'org.kordamp.ikonli:ikonli-javafx:2.1.1'
//implementation 'org.kordamp.ikonli:ikonli-dashicons-pack:2.1.1' // Maven central invalid --> not found on maven central (currently ?)
implementation 'org.kordamp.ikonli:ikonli-openiconic-pack:2.1.1'
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.17.0'
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.17.0'
implementation group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.17.0'
implementation group: 'com.atlassian.commonmark', name: 'commonmark', version: '0.11.0'
implementation group: 'net.objecthunter', name: 'exp4j', version: '0.4.8'
//Export to XLS
implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '4.0.1'
testImplementation group: 'junit', name: 'junit', version: '4.11'
}
compileJava.options.encoding = 'UTF-8'
sourceSets {
main {
java {
srcDir 'src/main/java'
}
resources {
srcDir 'src/main/resources'
}
}
test {
java {
srcDir 'src/test/java'
}
resources {
srcDir 'src/test/resources'
}
}
}
mainClassName = 'ch.unibas.dmi.dbis.cs108pet.main.Main'
jar {
from {
configurations.compileClasspath.collect{ it.isDirectory() ? it : zipTree(it)}
configurations.runtimeClasspath.collect{ it.isDirectory() ? it : zipTree(it)}
}
manifest{
attributes 'Main-Class': mainClassName
attributes 'Multi-Release':true
}
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
}
processResources {
// Pass version to reqman by adding it to reqman.properties
from(sourceSets.main.resources.srcDirs) {
include 'cs108pet.properties'
expand projectVersion: project.version
}
duplicatesStrategy(DuplicatesStrategy.INCLUDE)
exclude 'log4j2-test.xml'
// Do not copy the original file, since it would not have the version in it
/*from(sourceSets.main.resources.srcDirs) {
exclude 'reqman.properties'
}*/
outputs.upToDateWhen{false}
}
/**
* From:
* https://github.com/nostra13/Android-Universal-Image-Loader/issues/1086
*/
tasks.withType(Javadoc) {
options.addStringOption('encoding', 'UTF-8')
options.addStringOption('charSet', 'UTF-8')
options.addStringOption('Xdoclint:none', '-quiet')
}
/**
* Increments the specified versionPart in the version.properties file.
* This increments the specified versionPart in the version.properties file by 1
*
* Allowed versionParts are: MajorVersion, MinorVersion, FixVersion, BuildNumber
* The versionParts following the pattern *Version are under the Apache Versioning rules.
*
* The BuildNumber is incremented whenever the project is built.
*
* @param versionPart The versionPart to increment: Either MajorVersion, MinorVersion, FixVersion or BuildNumber
*/
static void incrementVersion(String versionPart) {
String vKey = "artifact${versionPart}"
Properties p = new Properties()
File pF = new File('version.properties')
p.load(pF.newDataInputStream())
Integer version = (p.getProperty(vKey) as Integer)
Integer nextVersion = version + 1
p.setProperty(vKey, nextVersion.toString())
p.store(pF.newWriter(), null)
p.load(pF.newDataInputStream())
}
/**
* Sets the version number of given version part.
* @param versionPart
* @param number
*/
static void setVersionPart(String versionPart, int number) {
String vKey = "artifact${versionPart}"
Properties p = new Properties()
File pF = new File('version.properties')
p.load(pF.newDataInputStream())
p.setProperty(vKey, String.valueOf(number))
p.store(pF.newWriter(), null)
p.load(pF.newDataInputStream())
}
task incrementMajorVersion {
group = 'versioning'
description = 'Increments the majro version (so the M in M.m.F) number by 1. Only invoke when a major version update is appropriate.'
doFirst {
incrementVersion('MajorVersion')
setVersionPart('MinorVersion', 0)
printVersion()
}
}
task incrementMinorVersion {
group = 'versioning'
description = 'Increments the minor version (so the m in M.m.F) number by 1. Only invoke when a minor version update is appropriate.'
doFirst {
incrementVersion('MinorVersion')
setVersionPart('FixVersion', 0)
printVersion()
}
}
task incrementFixVersion {
group = 'versioning'
description = 'Increments the fix version (so the F in M.m.F) number by 1. Only invoke when a bugfix is applied.'
doFirst {
incrementVersion('FixVersion')
printVersion()
}
}
task incrementBuildNumber() {
group = 'versioning'
description = 'Increments the build number by 1. Will be invoked right after build.'
doLast {
incrementVersion('BuildNumber')
}
}
build.doLast {
//incrementVersion('BuildNumber')
}
/**
* Reads the version.properties file with its artifact version numbers and concatenats these numbers
* to the version in format M.m.F-bB where M is the artifactMajorVersion, m is the artifactMinorVersion
* F is the artifactFixVersion and B is the artifactBuildNumber.
* The versioning follows the Appache Versioning rules.
* @return The read version
*/
String readVersion() {
Properties p = new Properties()
File f = new File("${project.projectDir}/version.properties")
p.load(f.newDataInputStream())
//Integer build = (p.getProperty('artifactBuildNumber') as Integer)
String suffix = p.getProperty('artifactVersionSuffix')
suffix = suffix == null ? '' : suffix
Integer fix = (p.getProperty('artifactFixVersion') as Integer)
Integer minor = (p.getProperty('artifactMinorVersion') as Integer)
Integer major = (p.getProperty('artifactMajorVersion') as Integer)
if(suffix.isEmpty() ){
return major.toString() + '.' + minor + '.' + fix/*+ '-b' + build.toString()*/
}else{
return major.toString() + '.' + minor + '.' + fix +"-"+suffix/*+ '-b' + build.toString()*/
}
}
void printVersion() {
setVersion(readVersion())
println('v'+project.version)
}
/**
* Reads the version.properties file with its artifact version numbers and then creats the version string
* with respect to that file's content.
*/
task setupVersion {
group = 'versioning'
description = 'Reads the version from version.properties file and sets the projects version as that read version.'
doFirst {
String v = readVersion()
setVersion(v)
printVersion()
}
}
jar.doLast {
println 'Produced jar: ' + jar.archiveName
}
task reqmanVersion {
doLast {
println('Current version of pet: ')
printVersion()
}
}