Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Packages #145

Closed
steowens opened this issue Feb 6, 2014 · 7 comments
Closed

Multiple Packages #145

steowens opened this issue Feb 6, 2014 · 7 comments
Labels

Comments

@steowens
Copy link

steowens commented Feb 6, 2014

Is there a way to configure the maven plugin to generate schemas in multiple packages? For example instead of:

<configuration>
   <sourceDirectory>${basedir}/src/main/resources/schema/catalog</sourceDirectory>
   <targetPackage>com.my.domain.catalog</targetPackage>
</configuration>

Why cant we have:

<configuration>
    <sources>
        <source>
           <directory>${basedir}/src/main/resources/schema/catalog</directory>
           <targetPackage>com.my.domain.catalog</targetPackage>
        </source>
        <source>
           <directory>${basedir}/src/main/resources/schema/auth</directory>
           <targetPackage>com.my.domain.auth</targetPackage>
        </source>
   </sources>
</configuration>
@joelittlejohn
Copy link
Owner

Yes you can do this in 0.4.0, just put two subfolders in your schema directory (auth and catalog) and point jsonschema2pojo at the parent directory. Use com.my.domain as the target package.

Classes generated from the auth directory will be put into com.my.domain.auth and classes generated from the catalog directory will be put into com.my.domain.catalog.

There's also a PR you can merge into your own fork if you want that does exactly what you describe. Check out the discussion there (it's the only open PR).

Rather than opening lots of issues it might be better if you send this kind of question to the mailing list as a first point of call.

Cheers

@steowens
Copy link
Author

Will do. However, I did open a new issue that seems to be a legitimate bug a few minutes ago.

@eallais
Copy link

eallais commented Oct 7, 2016

Have this issue with v0.4.26. Maven plugin seems not generated the package when used in jenkins but worked in local machine. Any ideas?

@mdnuro
Copy link

mdnuro commented May 22, 2019

Hello,

I'm trying to solve similar problem using gradle jsonschema2pojo 1.0.1 .
I have two sets of json schemas that need to be generated in two distinct packages.
eg : resource:json.abc and resource:json.xyz should generate POJO in packages com.build.abc and com.build.xyz respectively.

To achieve this, we put the json schemas in two different folders eg /json/xyz and json/abc and configure
targetPackage ="com.build".

but when I run gralde command it didn't generate POJO in separate package but rather all POJOs created in default package.

Is there anything I'm missing? any additional configuration needed? please help us with your expertise

Thanks in advance !

@joelittlejohn
Copy link
Owner

Do the schemas have javaType inside them?

@mithunj43
Copy link

Hello,

Even I am facing same issue mentioned by @mdnuro and I am using Gradle plugin 1.0.1. Seems like this fix/feature is not moved to Gradle plugin.

@joelittlejohn Since its not generating in proper packages I have added javaType in json schema as work around and its generating in proper packages.

@graveend
Copy link

Is it possible to create package for a subdirectory inside subdirectory to create a common target Package?
For example:
schema > category1 > typeA > schema_file1
schema > category2 > typeB > schema_file2
schema > category1 > typeB > schema_file3
schema > category2 > typeC > schema_file4

when I tried to give source = files("${sourceSets.main.output.resourcesDir}/schema")
and targetPackage = "com.app"

it generates imports i wrong packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants