forked from RoffelKartoffel/cmanager
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
212 lines (175 loc) · 6.81 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
plugins {
// Apply the versions plugin to check for module dependency updates.
id 'com.github.ben-manes.versions' version '0.51.0'
// Apply the Google Java formatter plugin for automatically reformatting files.
id 'com.github.sherter.google-java-format' version '0.9'
// Create runtime images.
id 'org.beryx.runtime' version '1.13.1'
}
// Apply the java plugin to add support for Java.
apply plugin: 'java'
// Apply the application plugin to add support for building an application.
apply plugin: 'application'
// Apply the versions plugin.
// Use it with the `dependencyUpdates` task.
apply plugin: 'com.github.ben-manes.versions'
// Apply the auto formatter plugin.
// Use it with the `googleJavaFormat` and `verifyGoogleJavaFormat` tasks.
apply plugin: 'com.github.sherter.google-java-format'
// Use definitions from external files.
apply from: 'gradle/methods.gradle'
apply from: 'gradle/keyHelper.gradle'
apply from: 'gradle/versionUtils.gradle'
// In this section you declare where to find the dependencies of your project.
repositories {
// You can declare any Maven/Ivy/file repository here.
mavenCentral()
maven {
url 'https://josm.openstreetmap.de/nexus/content/groups/public/'
}
}
dependencies {
implementation group: 'commons-codec', name: 'commons-codec', version: '1.17.1'
implementation group: 'org.apache.commons', name: 'commons-text', version: '1.12.0'
implementation group: 'com.github.scribejava', name: 'scribejava-core', version: '8.3.3'
// https://josm.openstreetmap.de/browser/osm/applications/viewer/jmapviewer
implementation group: 'org.openstreetmap.jmapviewer', name: 'jmapviewer', version: '2.22'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.11.0'
implementation group: 'org.apache.httpcomponents.client5', name: 'httpclient5', version: '5.4.1'
implementation group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.16'
// Use the JUnit testing framework.
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: '5.11.3'
testRuntimeOnly group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.11.3'
testImplementation group: 'org.mockito', name: 'mockito-inline', version: '5.2.0'
}
application {
// Define the main class for the application.
mainClass = 'cmanager.Main'
}
project.ext.ocOkapiPropertiesFile = projectDir.getPath() + "${File.separator}oc_okapi.properties"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
version = '0.7.0'
wrapper {
gradleVersion = '8.8'
}
// Use JUnit 5 for testing.
test {
useJUnitPlatform()
}
task OcOkapiKeys(type: Copy) {
project.retrieveOcOkapiProperties()
outputs.files 'src/main/java/cmanager/okapi/ConsumerKeys.java'
from('templates') {
exclude '**/*.properties', 'TestClientCredentials.java', 'Version.java'
}
expand(
oc_okapi_de_consumer_key: oc_okapi_de_consumer_key,
oc_okapi_de_consumer_secret: oc_okapi_de_consumer_secret,
oc_okapi_de_testing_consumer_key: oc_okapi_de_testing_consumer_key,
oc_okapi_de_testing_consumer_secret: oc_okapi_de_testing_consumer_secret
)
into 'src/main/java/cmanager/okapi'
}
task OcTestClientLogin(type: Copy) {
project.retrieveOcOkapiProperties()
outputs.files 'src/test/java/cmanager/okapi/helper/TestClientCredentials.java'
from('templates') {
exclude '**/*.properties', 'ConsumerKeys.java', 'Version.java'
}
expand(
oc_de_test_client_username: oc_de_test_client_username,
oc_de_test_client_password: oc_de_test_client_password,
oc_de_testing_test_client_username: oc_de_testing_test_client_username,
oc_de_testing_test_client_password: oc_de_testing_test_client_password
)
into 'src/test/java/cmanager/okapi/helper'
}
task Version(type: Copy) {
outputs.files 'src/main/java/cmanager/global/Version.java'
from('templates') {
exclude '**/*.properties', 'ConsumerKeys.java', 'TestClientCredentials.java'
}
expand(
version: version
)
into 'src/main/java/cmanager/global'
}
compileJava.dependsOn OcOkapiKeys, Version
compileTestJava.dependsOn OcTestClientLogin
clean.doFirst {
delete 'src/main/java/cmanager/okapi/ConsumerKeys.java'
delete 'src/main/java/cmanager/global/Version.java'
delete 'src/test/java/cmanager/okapi/helper/TestClientCredentials.java'
}
jar {
archiveBaseName = 'cm'
if (project.isCi()) {
archiveVersion = 'ci'
}
manifest {
attributes 'Main-Class': application.mainClass
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE // Allow duplicates.
from {
configurations.compileClasspath.collect {
it.isDirectory() ? it : zipTree(it)
}
}
}
// Only run one test at a time to avoid clashes with the site helpers.
test {
maxParallelForks = 1
}
// Fix the encoding on Windows systems.
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
// Formatter options.
googleJavaFormat {
// Use a recent version which supports JDK >= 16 as well.
// Corresponding issue: https://github.com/sherter/google-java-format-gradle-plugin/issues/68
// Releases: https://github.com/google/google-java-format/releases
toolVersion = '1.17.0'
// Use the Android style which uses 4 spaces for indentation.
// The default Google style would use 2 spaces which is too small in my opinion.
options style: 'AOSP'
}
// Make sure to not include pre-releases in the suggestions if are not yet using a pre-release for
// this package.
tasks.named("dependencyUpdates").configure {
rejectVersionIf {
project.isNonStable(it.candidate.version) && !project.isNonStable(it.currentVersion)
}
}
// Package generation options.
runtime {
// Options to pass to `jlink`.
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
// The modules to include.
modules = [
// From task `suggestModules`.
'java.scripting', 'java.xml', 'java.desktop', 'java.logging', 'java.sql', 'java.security.jgss', 'java.naming',
// See https://stackoverflow.com/questions/55439599/.
'jdk.crypto.ec',
]
// Configuration for `jpackage`.
jpackage {
imageName = 'cmanager'
imageOptions = ['--win-console']
// Do not create an installer.
skipInstaller = true
}
}
// Provide a dedicated task to create a ZIP file of the `jpackage` image.
task jpackageImageZip(type: Zip) {
group = 'Build'
description = 'Bundles the jpackage image as a ZIP file.'
from "${buildDir}/jpackage/cmanager"
include '**/*'
archiveFileName = "cmanager-${archiveVersion}_${project.getSystemString()}.zip"
destinationDirectory = file("${buildDir}/jpackage/")
}
jpackageImageZip.dependsOn jpackageImage