javaType : generate classes in subpackage of the target package
See original GitHub issueSuppose I generate my classes in target package com.example
.
If I specify a javaType
property of Foo
, it will be generated as com.example.Foo
, as expected.
However if I specify a javaType
property of bar.Foo
(with a dot), it will be generated as bar.Foo
(i.e. in package bar
).
To me it would make more sense to generate it in package com.example.bar.Foo
, i.e. a subpackage of the target package. As it is now, if I want to generate classes in subpackages of the target package, I have to repeat the fully qualified package name in every javaType
property. And of course if I want to change it I will have to change in all the places it is referenced…
If we want to preserve this behavior for compatibility and still allow generating classes in subpackages, I suggest we introduce the convention that if the javaType begins with a dot, it’s considered relative to the target package.
For example:
- javaType=
bar.Foo
-> generates classbar.Foo
(same as current behavior) - javaType=
.bar.Foo
-> generates classcom.example.bar.Foo
What do you think?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Thanks @ogerardin. I have reopened #195.
Nothing, and that would work, but I shouldn’t have to use
com.example
in the schema because it’s a generation-time parameter. I want to be able to put the generated classes in subpackages of the target package, without knowing what it will be.