Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix validation (plugin no longer words) and add publishing #11

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .project

This file was deleted.

2 changes: 0 additions & 2 deletions .settings/org.eclipse.buildship.core.prefs

This file was deleted.

54 changes: 44 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,59 @@

buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'cz.alenkacz.gradle:json-validator:1.3.0'
}
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: 'json-validator'
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.1.0'
schema_file = projectDir.getPath() + "/schema.json"
data_file = projectDir.getPath() + "/geocontext.json"
githubToken = System.getenv('GITHUB_TOKEN')
}

import cz.alenkacz.gradle.jsonvalidator.ValidateJsonTask
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);

task validate(type: ValidateJsonTask) {
targetJsonFile = file("geocontext.json") // only one of targetJsonFile or targetJsonDirectory can be specified
jsonSchema = file("schema.json")
onlyWithJsonExtension = true
ProcessingReport report = schema.validate(toValidate);
if (!report.isSuccess()) {
throw new GradleException(report.toString());
}
}
}
validate.group = 'validation'
validate.description = 'Vaidate geocontext.json'
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
}
Loading