forked from java-json-tools/json-schema-validator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/update-deps
- Loading branch information
Showing
28 changed files
with
582 additions
and
424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,41 +17,18 @@ | |
* - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt | ||
*/ | ||
|
||
/* | ||
* This has to be here... It will not be taken into account in common.gradle! | ||
* | ||
* Looks like a serious bug... See also: | ||
* | ||
* http://forums.gradle.org/gradle/topics/buildscript_in_subprojects_ignored | ||
*/ | ||
/* | ||
* This has to be here... It will not be taken into account in common.gradle! | ||
* | ||
* Looks like a serious bug... See also: | ||
* | ||
* http://forums.gradle.org/gradle/topics/buildscript_in_subprojects_ignored | ||
* | ||
* We also use Spring's propdeps plugin to have a _real_ provided scope. See: | ||
* | ||
* https://github.com/spring-projects/gradle-plugins/tree/master/propdeps-plugin | ||
*/ | ||
|
||
apply(plugin: "java"); | ||
apply(plugin: "maven"); | ||
apply(plugin: "signing"); | ||
apply(plugin: "osgi"); | ||
apply(plugin: "idea"); | ||
apply(plugin: "eclipse"); | ||
|
||
group = "com.github.fge"; | ||
version = "2.2.6"; | ||
group = "com.github.java-json-tools"; | ||
version = "2.2.7"; | ||
sourceCompatibility = "1.6"; | ||
targetCompatibility = "1.6"; // defaults to sourceCompatibility | ||
|
||
project.ext { | ||
description = "A Java implementation of the JSON Schema specification"; | ||
}; | ||
|
||
/* | ||
* Repositories to use | ||
*/ | ||
|
@@ -63,7 +40,7 @@ repositories { | |
* List of dependencies | ||
*/ | ||
dependencies { | ||
compile(group: "com.github.fge", name: "json-schema-core", version: "1.2.5"); | ||
compile(group: "com.github.java-json-tools", name: "json-schema-core", version: "1.2.8"); | ||
compile(group: "javax.mail", name: "mailapi", version: "1.4.3"); | ||
compile(group: "joda-time", name: "joda-time", version: "2.9.7"); | ||
compile(group: "com.googlecode.libphonenumber", name: "libphonenumber", version: "8.0.0"); | ||
|
@@ -87,7 +64,7 @@ javadoc.options.links("http://fge.github.io/btf/"); | |
javadoc.options.links("http://fge.github.io/msg-simple/"); | ||
javadoc.options.links("http://fge.github.io/jackson-coreutils/"); | ||
javadoc.options.links("http://fge.github.io/uri-template/"); | ||
javadoc.options.links("http://fge.github.io/json-schema-core/1.2.x/"); | ||
javadoc.options.links("http://java-json-tools.github.io/json-schema-core/1.2.x/"); | ||
|
||
|
||
/* | ||
|
@@ -125,12 +102,14 @@ javadoc.options { | |
* Equally annoyingly, the docFilesSubDirs option above does not seem to have | ||
* any effect :/ | ||
*/ | ||
task copyDocFiles(dependsOn: javadoc) << { | ||
copy { | ||
from("src/main/javadoc") { | ||
include "**/doc-files/**"; | ||
}; | ||
into javadoc.destinationDir; | ||
task copyDocFiles(dependsOn: javadoc) { | ||
doLast { | ||
copy { | ||
from("src/main/javadoc") { | ||
include "**/doc-files/**"; | ||
}; | ||
into javadoc.destinationDir; | ||
} | ||
} | ||
} | ||
|
||
|
@@ -164,38 +143,42 @@ artifacts { | |
} | ||
|
||
task wrapper(type: Wrapper) { | ||
gradleVersion = "1.11"; | ||
gradleVersion = "3.5"; | ||
distributionUrl = "http://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"; | ||
} | ||
|
||
task pom << { | ||
pom {}.writeTo("${projectDir}/pom.xml"); | ||
task pom { | ||
doLast { | ||
pom {}.writeTo("${projectDir}/pom.xml"); | ||
} | ||
} | ||
|
||
/* | ||
* SIGNING | ||
*/ | ||
|
||
project.ext { | ||
gitrwscm = sprintf("[email protected]:fge/%s", name); | ||
gitroscm = sprintf("https://github.com/fge/%s.git", name); | ||
projectURL = sprintf("https://github.com/fge/%s", name); | ||
description = "A Java implementation of the JSON Schema specification"; | ||
scmUrl = sprintf("git@github.com:box-metadata/%s", name); | ||
projectURL = sprintf("https://github.com/box-metadata/%s", name); | ||
sonatypeStaging = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"; | ||
sonatypeSnapshots = "https://oss.sonatype.org/content/repositories/snapshots/"; | ||
}; | ||
|
||
task checkSigningRequirements << { | ||
def requiredProperties = [ "sonatypeUsername", "sonatypePassword" ]; | ||
def noDice = false; | ||
requiredProperties.each { | ||
if (project.properties[it] == null) { | ||
noDice = true; | ||
System.err.printf("property \"%s\" is not defined!", it); | ||
task checkSigningRequirements { | ||
doLast { | ||
def requiredProperties = [ "sonatypeUsername", "sonatypePassword" ]; | ||
def noDice = false; | ||
requiredProperties.each { | ||
if (project.properties[it] == null) { | ||
noDice = true; | ||
System.err.printf("property \"%s\" is not defined!", it); | ||
} | ||
} | ||
if (noDice) | ||
throw new IllegalStateException("missing required properties for " + | ||
"upload"); | ||
} | ||
if (noDice) | ||
throw new IllegalStateException("missing required properties for " + | ||
"upload"); | ||
} | ||
|
||
uploadArchives { | ||
|
@@ -231,15 +214,15 @@ uploadArchives { | |
uploadArchives.repositories.mavenDeployer | ||
]*.pom*.whenConfigured { pom -> | ||
pom.project { | ||
name "${name}"; | ||
name "${project.name}"; | ||
packaging "jar"; | ||
description "${description}"; | ||
description "${project.ext.description}"; | ||
url "${projectURL}"; | ||
|
||
scm { | ||
url "${gitrwscm}"; | ||
connection "${gitrwscm}"; | ||
developerConnection "${gitroscm}"; | ||
url "${scmUrl}"; | ||
connection "scm:git:${scmUrl}"; | ||
developerConnection "scm:git:${scmUrl}"; | ||
} | ||
|
||
licenses { | ||
|
@@ -257,9 +240,9 @@ uploadArchives { | |
|
||
developers { | ||
developer { | ||
id "fge"; | ||
name "Francis Galiegue"; | ||
email "fgaliegue@gmail.com"; | ||
id "huggsboson"; | ||
name "John Huffaker"; | ||
email "jhuffaker+java-json-tools@gmail.com"; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,20 @@ | ||
#!/bin/bash | ||
|
||
# Release instructions | ||
# 1. Follow the gpg setup instructions: http://central.sonatype.org/pages/working-with-pgp-signatures.html | ||
# a. gpg2 --export-secret-keys > ~/.gnupg/secring.gpg | ||
# 2. In ~/.gradle add: | ||
# sonatypeUsername=your sonatype user name | ||
# sonatypePassword=password in vault for oss sonatype<ensure newline> | ||
# | ||
# signing.keyId=generated key | ||
# signing.password=password for gpg key | ||
# signing.secretKeyRingFile=/Users/username/.gnupg/secring.gpg | ||
# | ||
# 3. ./dorelease.sh | ||
# 4. Go to UI at: https://oss.sonatype.org | ||
# 5. Login as sonatypeUsername | ||
# 6. Follow the instructions here: http://central.sonatype.org/pages/releasing-the-deployment.html | ||
|
||
./gradlew --recompile-scripts clean test uploadArchives | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,6 @@ | ||
# | ||
# Copyright (c) 2014, Francis Galiegue ([email protected]) | ||
# | ||
# This software is dual-licensed under: | ||
# | ||
# - the Lesser General Public License (LGPL) version 3.0 or, at your option, any | ||
# later version; | ||
# - the Apache Software License (ASL) version 2.0. | ||
# | ||
# The text of this file and of both licenses is available at the root of this | ||
# project or, if you have the jar distribution, in directory META-INF/, under | ||
# the names LGPL-3.0.txt and ASL-2.0.txt respectively. | ||
# | ||
# Direct link to the sources: | ||
# | ||
# - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt | ||
# - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt | ||
# | ||
|
||
#Mon Apr 14 09:45:58 CEST 2014 | ||
#Fri Jun 02 16:48:25 PDT 2017 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip | ||
distributionUrl=http\://services.gradle.org/distributions/gradle-3.5-all.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/com/github/fge/jsonschema/keyword/validator/KeywordValidatorFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.github.fge.jsonschema.keyword.validator; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.github.fge.jsonschema.core.exceptions.ProcessingException; | ||
|
||
/** | ||
* Interface for a keyword validator factory | ||
*/ | ||
public interface KeywordValidatorFactory | ||
{ | ||
/** | ||
* Create a validator for the instance | ||
* | ||
* @param node the instance to validate | ||
* @return a validator for the given instance | ||
* @throws ProcessingException an error occurs creating the validator | ||
*/ | ||
KeywordValidator getKeywordValidator(JsonNode node) | ||
throws ProcessingException; | ||
} |
52 changes: 52 additions & 0 deletions
52
...n/java/com/github/fge/jsonschema/keyword/validator/ReflectionKeywordValidatorFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.github.fge.jsonschema.keyword.validator; | ||
|
||
import java.lang.reflect.Constructor; | ||
import java.lang.reflect.InvocationTargetException; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.github.fge.jsonschema.core.exceptions.ProcessingException; | ||
import com.github.fge.jsonschema.messages.JsonSchemaConfigurationBundle; | ||
import com.github.fge.msgsimple.bundle.MessageBundle; | ||
import com.github.fge.msgsimple.load.MessageBundles; | ||
|
||
/** | ||
* A validator factory that uses reflection to create an instance of the | ||
* specified KeywordValidator class | ||
*/ | ||
public class ReflectionKeywordValidatorFactory | ||
implements KeywordValidatorFactory | ||
{ | ||
private static final String ERRMSG = "failed to build keyword validator"; | ||
private static final MessageBundle BUNDLE | ||
= MessageBundles.getBundle(JsonSchemaConfigurationBundle.class); | ||
|
||
private final Constructor<? extends KeywordValidator> constructor; | ||
|
||
public ReflectionKeywordValidatorFactory(String name, | ||
Class<? extends KeywordValidator> clazz) | ||
{ | ||
try { | ||
constructor = clazz.getConstructor(JsonNode.class); | ||
} catch (NoSuchMethodException ignored) { | ||
throw new IllegalArgumentException(BUNDLE.printf( | ||
"noAppropriateConstructor", name, clazz.getCanonicalName() | ||
)); | ||
} | ||
} | ||
|
||
@Override | ||
public KeywordValidator getKeywordValidator(JsonNode node) | ||
throws ProcessingException | ||
{ | ||
try { | ||
return constructor.newInstance(node); | ||
} catch (InstantiationException e) { | ||
throw new ProcessingException(ERRMSG, e); | ||
} catch (IllegalAccessException e) { | ||
throw new ProcessingException(ERRMSG, e); | ||
} catch (InvocationTargetException e) { | ||
throw new ProcessingException(ERRMSG, e); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.