jsonschema2pojo icon indicating copy to clipboard operation
jsonschema2pojo copied to clipboard

@Generated annotation generator ignores target Java version

Open eirnym opened this issue 4 years ago • 2 comments

When use jsonschema2pojo generator with runtime java version 9+ it's impossible to generate classes for older versions of java, even target version is set to 1.7 or 1.8.

It's quite unfortunate for our project (which uses java 11+) to use detached module only to publish models compatible with java 1.8

Both maven and gradle generators are affected.

eirnym avatar Dec 23 '21 10:12 eirnym

Same issue here indeed

jrevillard avatar Apr 22 '22 13:04 jrevillard

It seems that this was a deliberate decision, see:

  • https://github.com/joelittlejohn/jsonschema2pojo/issues/835
  • https://github.com/joelittlejohn/jsonschema2pojo/pull/1202#issuecomment-787897608

Reversing that decision would mean introducing "breaking change" (for users relying on current implementation without having targetVersion overridden) as default targetVersion is 1.6 (ref). On the other other hand honoring targetVersion would make outcome predictable and correct.

unkish avatar Jun 22 '22 06:06 unkish

same issue here since we are building on java 11 but target java 8 i'd agree that targetVersion should be considered when deciding which @Generated annotation to use

i could potentially provide a PR if there is agreement on the suggestion

XN137 avatar Oct 28 '22 07:10 XN137

+1 targetVersion is an explicit command from the developer to ignore the runtime and "do what I say not what I do"

drekbour avatar Nov 16 '22 14:11 drekbour