-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
27 lines (26 loc) · 1 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
import java.nio.file.Files
tasks.register('validate') {
File folder = file('src/messages')
Files.list(folder.toPath()).forEach {
String fileName = it.toFile().getName();
Properties properties = new Properties()
properties.load(it.newInputStream())
properties.each {
if (it.key == null || it.key.toString().isBlank() || it.value == null) {
throw new IllegalArgumentException('Failed validation on file ' + fileName)
}
String value = it.value.toString();
boolean failed = false
if (value.startsWith("\'") || value.startsWith("\"")) {
failed = true
} else if (value.count('{') != value.count('}')) {
failed = true
} else if (value.isBlank()) {
failed = true
}
if (failed) {
throw new IllegalArgumentException('Failed validation on file ' + fileName + ': ' + it.key)
}
}
}
}