joelittlejohn / jsonschema2pojo

Generate Java types from JSON or JSON Schema and annotate those types for data-binding with Jackson, Gson, etc

Home Page:http://www.jsonschema2pojo.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't get fileFilter working with gradle plugin

pgalbraith opened this issue · comments

I just want the gradle plugin to process *.json schema files and ignore anything that's not *.json. This is proving to be very difficult, however. I don't doubt that this is just lack of awareness on my part to make it work correctly, but I'm really struggling to make fileFilter work.

Looking at the documentation (https://github.com/joelittlejohn/jsonschema2pojo/tree/master/jsonschema2pojo-gradle-plugin#usage) it suggests I can apply the default filter with fileFilter = new AllFileFilter(). However, trying that verbatim yields a build error unable to resolve class AllFileFilter.

I get the same error if I fully qualify the filter, fileFilter = new org.jsonschema2pojo.AllFileFilter(): unable to resolve class org.json2schema2pojo.AllFileFilter.

What I really want is to be able to specify a custom filter ala fileFilter = { it.name.endsWith('.json') } but I just can't seem to get anything to work. Would it possible to show a working example of a fileFilter defined in a gradle script?

Hi

Maybe something like

fileFilter = file -> file.path.endsWith('.json')

would do the trick ?

Thanks @unkish ... I finally figured it was failing because it's walking the entire tree and the lambda was returning false for the parent directory and thus not even looking at the schema files. This value of fileFilter does the trick:

fileFilter = { it.isDirectory() || it.name.endsWith('.json') }