I am trying to migrate our codebase from Maven to Gradle. We are using the protoc-gen-jsonschema plugin to generate JSON Schema from the defined proto files. The configuration file looks like this:
The above code seems to work, but the generated JSON schema files are included in the JAR generated by the jar task. Apparently, this plugin seems to add the protoc plugin's outputSubDir to sourceSets.java regardless of the content generated by the protoc plugin. So the workaround I had to do was to move all the generated JSON schemas into a separate directory and add it to the resources sourceSet.
protobuf {
generateProtoTasks {
ofSourceSet(sourceSets["main"].name).all {
// ...
val outputBaseDir = file(outputBaseDir)
val jsonSchemaDir = outputBaseDir.resolve(jsonSchema.outputSubDir)
val jsonSchemaResDir = outputBaseDir.resolve("jsonschema")
val jsonSchemaResSubDir = jsonSchemaResDir.resolve("jsonschema")
sourceSets["main"].resources.srcDir(jsonSchemaResDir)
doLast {
copy { from(jsonSchemaDir); into(jsonSchemaResSubDir) }
delete(jsonSchemaDir)
}
// ...
}
}
}
I was wondering if there is an option to disable/customize files added to the sourceSet on a per-plugin basis. I went through the plugin code and was not able to find anything that would allow me to do this. I was also wondering if there are any other better ways to achieve the same.
Hi,
I am trying to migrate our codebase from Maven to Gradle. We are using the
protoc-gen-jsonschema
plugin to generate JSON Schema from the defined proto files. The configuration file looks like this:The above code seems to work, but the generated JSON schema files are included in the JAR generated by the
jar
task. Apparently, this plugin seems to add the protoc plugin'soutputSubDir
tosourceSets.java
regardless of the content generated by the protoc plugin. So the workaround I had to do was to move all the generated JSON schemas into a separate directory and add it to theresources
sourceSet.I was wondering if there is an option to disable/customize files added to the
sourceSet
on a per-plugin basis. I went through the plugin code and was not able to find anything that would allow me to do this. I was also wondering if there are any other better ways to achieve the same.Thanks in advance.