-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.gradle
59 lines (50 loc) · 1.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
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.github.breadmoirai:github-release:2.5.2"
classpath(group: "com.github.java-json-tools", name: "json-schema-validator", version: "2.2.14");
}
}
apply plugin: "com.github.breadmoirai.github-release"
import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jackson.JsonLoader;
import com.github.fge.jsonschema.core.report.ProcessingReport;
import com.github.fge.jsonschema.main.JsonSchema;
import com.github.fge.jsonschema.main.JsonSchemaFactory;
ext {
version = '0.3.0'
schema_file = projectDir.getPath() + "/schema.json"
data_file = projectDir.getPath() + "/geocontext.json"
githubToken = System.getenv('GITHUB_TOKEN')
}
task validate() {
inputs.file(schema_file);
inputs.file(data_file);
doLast {
final JsonNode schemaFile = JsonLoader.fromPath(schema_file);
final JsonNode toValidate = JsonLoader.fromPath(data_file);
final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
final JsonSchema schema = factory.getJsonSchema(schemaFile);
ProcessingReport report = schema.validate(toValidate);
if (!report.isSuccess()) {
throw new GradleException(report.toString());
}
}
}
validate.group = 'validation'
validate.description = 'Vaidate the json data'
githubRelease {
token project.ext.githubToken == null ? "" : project.ext.githubToken
owner = "simonpoole"
tagName = project.ext.version
releaseName = project.ext.version
targetCommitish = "main"
generateReleaseNotes = true
releaseAssets data_file, schema_file
overwrite = true
}