joelittlejohn / jsonschema2pojo

Generate Java types from JSON or JSON Schema and annotate those types for data-binding with Jackson, Gson, etc
http://www.jsonschema2pojo.org
Apache License 2.0
6.24k stars 1.66k forks source link

Gradle plugin: ability to set the sourceset to which generated files are added #1600

Open Fabilin opened 7 months ago

Fabilin commented 7 months ago

The jsonschema2pojo gradle plugin automatically attaches the generated files to the main sourceset of a project. However, some projects may wish to add generated sources to a separate sourceset, or even to generate them without using them as sources at all. As such, it would be helpful to add a (nullable) sourceSet variable to the plugin's configuration, which could default to the main sourceset.

sermarr commented 4 months ago

I think the maven plugin has 'addCompileSourceRoot' you can set to false and not add targetDirectory to the sources in the first place but the gradle one doesn't (or does it?).

I do the generation on one module (A) but set the targetDir to another (B) and get "Duplicate content root detected" warnings on InteliJ, .. but with Visual Studio Code's Java plugin... it gets messed up totally and shows red squiggly lines everywhere. .. because it added module B's generated source to module A

My workaround is keep the generated files in module A, create another task in module A that copies the contents of targetDirectory (in A) to module B