title: XJC Generating Java objects on different packages using maven jaxb2 plugin
body: <p>In my resources folder <code>src/main/resources</code>, I have an <strong>xsd</strong> folder with subfolders named <strong>create</strong> and <strong>update</strong>.</p>
  <p>So the folder structure looks like :</p>
  <pre><code>src/main/resources/xsd
  src/main/resources/xsd/create/create.xsd
  src/main/resources/xsd/update/update.xsd
  </code></pre>
  <p>What I am trying to figure out is how to generate the Java Objects in their own respective packages to organize the code using XJC and maven-jaxb2-plugin</p>
  <p>I want to generate the <strong>CREATE</strong> Java objects in <code>src/main/java/com/myapp/dto/create</code></p>
  <p>And <strong>UPDATE</strong> Java objects in <code>src/main/java/com/myapp/dto/update</code></p>
  <p><strong>pom.xml</strong></p>
  <pre><code>&lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;excludes&gt;
                      &lt;exclude&gt;
                          &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
                          &lt;artifactId&gt;lombok&lt;/artifactId&gt;
                      &lt;/exclude&gt;
                  &lt;/excludes&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;!-- user-added-plugin--&gt;
          &lt;plugin&gt;
              &lt;!-- https://mvnrepository.com/artifact/org.jvnet.jaxb2.maven2/maven-jaxb2-plugin --&gt;
              &lt;groupId&gt;org.jvnet.jaxb2.maven2&lt;/groupId&gt;
              &lt;artifactId&gt;maven-jaxb2-plugin&lt;/artifactId&gt;
              &lt;version&gt;0.15.1&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;generate&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
              &lt;configuration&gt;
                  &lt;!-- CREATE Schema--&gt;
                  &lt;schemaDirectory&gt;${project.basedir}/src/main/resources/xsd/create&lt;/schemaDirectory&gt;
                  &lt;schemaIncludes&gt;
                      &lt;include&gt;*.xsd&lt;/include&gt;
                  &lt;/schemaIncludes&gt;
                  &lt;generatePackage&gt;com.myapp.dto.create&lt;/generatePackage&gt;
                  &lt;generateDirectory&gt;${project.basedir}/src/main/java&lt;/generateDirectory&gt;
                  
                  &lt;!-- UPDATE Schema --&gt;
                  &lt;schemaDirectory&gt;${project.basedir}/src/main/resources/xsd/update&lt;/schemaDirectory&gt;
                  &lt;schemaIncludes&gt;
                      &lt;include&gt;*.xsd&lt;/include&gt;
                  &lt;/schemaIncludes&gt;
                  &lt;generatePackage&gt;com.myapp.dto.update&lt;/generatePackage&gt;
                  &lt;generateDirectory&gt;${project.basedir}/src/main/java&lt;/generateDirectory&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  <p>My current <strong>pom.xml</strong> <code>&lt;build&gt;</code> code only generates the <strong>UPDATE</strong> Java objects in <code>com.myapp.dto.update</code> but it never generates <strong>CREATE</strong> Java objects in <code>com.myapp.dto.create</code>. It does not even create the path: <code>com.myapp.dto.create</code></p>
  <p>I am not sure how to generate the <strong>CREATE</strong> on the desired path. Eventually I will need to generate Java objects for DELETE schema. That's why I'm hoping to generate the Java objects accordingly on their respective package/folders.</p>