forked from FriedrichFroebel/cmanager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
207 lines (172 loc) · 6.95 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
plugins {
// Apply the versions plugin to check for module dependency updates.
id 'com.github.ben-manes.versions' version '0.28.0'
// Apply the Google Java formatter plugin for automatically reformatting files.
id 'com.github.sherter.google-java-format' version '0.8'
// Create runtime images.
id 'org.beryx.runtime' version '1.8.4'
}
// 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 autoformatter plugin.
// Use it with the `googleJavaFormat` and `verifyGoogleJavaFormat` tasks.
apply plugin: 'com.github.sherter.google-java-format'
// In this section you declare where to find the dependencies of your project.
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
maven {
url 'https://josm.openstreetmap.de/nexus/content/groups/public/'
}
}
dependencies {
implementation group: 'commons-codec', name: 'commons-codec', version: '1.14'
implementation group: 'org.apache.commons', name: 'commons-text', version: '1.8'
implementation group: 'joda-time', name: 'joda-time', version: '2.10.6'
implementation group: 'com.github.scribejava', name: 'scribejava-core', version: '6.9.0'
implementation group: 'org.openstreetmap.jmapviewer', name: 'jmapviewer', version: '2.13'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.12'
// Use JUnit test framework.
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.6.2'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.6.2'
}
// Define the main class for the application.
mainClassName = 'cmanager.Main'
project.ext.ocOkapiPropertiesFile = projectDir.getPath() + "${File.separator}oc_okapi.properties"
sourceCompatibility = 1.8
targetCompatibility = 1.8
version = '0.4.0'
wrapper {
gradleVersion = '6.4.1'
}
// Use JUnit 5 for testing.
test {
useJUnitPlatform()
}
// Allow retrieving the configuration values from environment variables as well.
def retrieveOcOkapiProperties() {
if (file(project.ocOkapiPropertiesFile).exists()) {
Properties properties = new Properties()
File propertiesFile = new File(project.ocOkapiPropertiesFile)
properties.load(propertiesFile.newDataInputStream())
ext.oc_okapi_de_consumer_key = properties.getProperty('oc_okapi_de_consumer_key')
ext.oc_okapi_de_consumer_secret = properties.getProperty('oc_okapi_de_consumer_secret')
ext.oc_test_client_username = properties.getProperty('oc_test_client_username')
ext.oc_test_client_password = properties.getProperty('oc_test_client_password')
} else {
ext.oc_okapi_de_consumer_key = System.getenv('OC_OKAPI_DE_CONSUMER_KEY')
ext.oc_okapi_de_consumer_secret = System.getenv('OC_OKAPI_DE_CONSUMER_SECRET')
ext.oc_test_client_username = System.getenv('OC_TEST_CLIENT_USERNAME')
ext.oc_test_client_password = System.getenv('OC_TEST_CLIENT_PASSWORD')
}
// The testing values are not required.
if (ext.oc_okapi_de_consumer_key == null || ext.oc_okapi_de_consumer_secret == null) {
throw new GradleException('Configuration data missing. Please follow the instructions in the README')
}
}
task OcOkapiKeys(type: Copy) {
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
)
into 'src/main/java/cmanager/okapi'
}
task OcTestClientLogin(type: Copy) {
retrieveOcOkapiProperties()
outputs.files 'src/test/java/cmanager/okapi/helper/TestClientCredentials.java'
from('templates') {
exclude '**/*.properties', 'ConsumerKeys.java', 'Version.java'
}
expand(
oc_test_client_username: oc_test_client_username,
oc_test_client_password: oc_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 (System.getProperty('user.name').equals('travis')) version = 'ci'
manifest {
attributes 'Main-Class': mainClassName
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE // allow duplicates
from {
configurations.compileClasspath.collect {
it.isDirectory() ? it : zipTree(it)
}
}
}
// Fix the encoding on Windows systems.
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
// Formatter options.
googleJavaFormat {
// 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'
}
// 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
}
}
// Retrieve the system string for indicating the package content.
def getSystemString() {
def osName = System.properties['os.name'].toLowerCase()
if (osName.contains('windows')) return 'windows';
return osName;
}
// 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 '**/*'
archiveName "cmanager-${version}_${getSystemString()}.zip"
destinationDir file("${buildDir}/jpackage/")
}
jpackageImageZip.dependsOn jpackageImage