From e5227c0eed0f953b4dbf85c44b4febd8c32add0e Mon Sep 17 00:00:00 2001 From: unkish <3533269+unkish@users.noreply.github.com> Date: Thu, 10 Aug 2023 11:56:30 +0300 Subject: [PATCH] Allow URL(s) as source in jsonschema2pojo-gradle-plugin Closes #1010 --- jsonschema2pojo-gradle-plugin/example/java/build.gradle | 5 +++++ .../jsonschema2pojo/gradle/GenerateJsonSchemaJavaTask.groovy | 2 +- .../org/jsonschema2pojo/gradle/JsonSchemaPluginSpec.groovy | 2 -- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/jsonschema2pojo-gradle-plugin/example/java/build.gradle b/jsonschema2pojo-gradle-plugin/example/java/build.gradle index 8f1bf4031..ae8644dca 100644 --- a/jsonschema2pojo-gradle-plugin/example/java/build.gradle +++ b/jsonschema2pojo-gradle-plugin/example/java/build.gradle @@ -29,6 +29,11 @@ dependencies { } jsonSchema2Pojo { + // omitting 'source' will force plugin to look for sources under ${project.sourceSets.main.output.resourcesDir}/json + source = [ + 'https://raw.githubusercontent.com/joelittlejohn/jsonschema2pojo/master/jsonschema2pojo-integration-tests/src/test/resources/schema/ref/recursiveTreeNode.json', + file("src/main/resources/json") + ] targetPackage = 'example' includeJsr303Annotations = true propertyWordDelimiters = ['_'] as char[] diff --git a/jsonschema2pojo-gradle-plugin/src/main/groovy/org/jsonschema2pojo/gradle/GenerateJsonSchemaJavaTask.groovy b/jsonschema2pojo-gradle-plugin/src/main/groovy/org/jsonschema2pojo/gradle/GenerateJsonSchemaJavaTask.groovy index 12997fbc0..e7f0f937e 100644 --- a/jsonschema2pojo-gradle-plugin/src/main/groovy/org/jsonschema2pojo/gradle/GenerateJsonSchemaJavaTask.groovy +++ b/jsonschema2pojo-gradle-plugin/src/main/groovy/org/jsonschema2pojo/gradle/GenerateJsonSchemaJavaTask.groovy @@ -56,7 +56,7 @@ class GenerateJsonSchemaJavaTask extends DefaultTask { setTargetVersion configuration inputs.property("configuration", configuration.toString()) - inputs.files project.files(configuration.sourceFiles) + inputs.files project.files(configuration.source.findAll { 'file'.equals(it.protocol) }) } } diff --git a/jsonschema2pojo-gradle-plugin/src/test/groovy/org/jsonschema2pojo/gradle/JsonSchemaPluginSpec.groovy b/jsonschema2pojo-gradle-plugin/src/test/groovy/org/jsonschema2pojo/gradle/JsonSchemaPluginSpec.groovy index 5878a7137..8ad76eb42 100644 --- a/jsonschema2pojo-gradle-plugin/src/test/groovy/org/jsonschema2pojo/gradle/JsonSchemaPluginSpec.groovy +++ b/jsonschema2pojo-gradle-plugin/src/test/groovy/org/jsonschema2pojo/gradle/JsonSchemaPluginSpec.groovy @@ -16,7 +16,6 @@ package org.jsonschema2pojo.gradle import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; import java.lang.reflect.Field @@ -24,7 +23,6 @@ import org.apache.commons.io.FileUtils import org.gradle.tooling.BuildLauncher import org.gradle.tooling.GradleConnector import org.gradle.tooling.ProjectConnection -import org.jsonschema2pojo.gradle.JsonSchemaExtension import org.junit.Test class JsonSchemaPluginSpec {