How can I tell jaxb / Maven to generate multiple schema packages?

前端 未结 9 1806
旧时难觅i
旧时难觅i 2020-11-28 03:16

Example:

       
       
           org.jvnet.jaxb2.maven2

        
相关标签:
9条回答
  • 2020-11-28 03:43

    you should change that to define the plugin only once and do twice execution areas...like the following...and the generateDirectory should be set (based on the docs)..

    <plugin>
      <groupId>org.jvnet.jaxb2.maven2</groupId>
      <artifactId>maven-jaxb2-plugin</artifactId>
      <version>0.7.1</version>
      <executions>
        <execution>
          <id>firstrun</id>
          <goals>
            <goal>generate</goal>
          </goals>
          <configuration>
            <generateDirectory>target/gen1</generateDirectory>
            <schemaDirectory>src/main/resources/dir1</schemaDirectory>
            <schemaIncludes>
              <include>schema1.xsd</include>
            </schemaIncludes>
            <generatePackage>schema1.package</generatePackage>
          </configuration>
        </execution>
        <execution>
          <id>secondrun</id>
          <goals>
            <goal>generate</goal>
          </goals>
          <configuration>
            <generateDirectory>target/gen2</generateDirectory>
            <schemaDirectory>src/main/resources/dir2</schemaDirectory>
            <schemaIncludes>
              <include>schema2.xsd</include>
            </schemaIncludes>
            <generatePackage>schema2.package</generatePackage>
          </configuration>
        </execution>
      </executions>
    </plugin>
    

    It seemed to me that you are fighting against single artifact rule of maven...may be you should think about this.

    0 讨论(0)
  • 2020-11-28 03:46

    The following works for me, after much trial

    <plugin>
             <groupId>org.codehaus.mojo</groupId>
             <artifactId>jaxb2-maven-plugin</artifactId>
             <version>2.1</version>
             <executions>
                <execution>
                  <id>xjc1</id>
                  <goals>
                      <goal>xjc</goal>
                  </goals>
                 <configuration>
                    <packageName>com.mycompany.clientSummary</packageName>
                   <sourceType>wsdl</sourceType>
                    <sources>
                    <source>src/main/resources/wsdl/GetClientSummary.wsdl</source>
                    </sources>
                    <outputDirectory>target/generated-sources/xjb</outputDirectory>
                     <clearOutputDir>false</clearOutputDir>
                </configuration>
              </execution>
    
              <execution>
                 <id>xjc2</id>
                 <goals>
                     <goal>xjc</goal>
                 </goals>
                 <configuration>
                    <packageName>com.mycompany.wsclient.employerProfile</packageName>
                    <sourceType>wsdl</sourceType>
                    <sources>
                    <source>src/main/resources/wsdl/GetEmployerProfile.wsdl</source>
                    </sources>
                    <outputDirectory>target/generated-sources/xjb</outputDirectory>
                    <clearOutputDir>false</clearOutputDir>
             </configuration>
             </execution>
    
             <execution>
                <id>xjc3</id>
                <goals>
                    <goal>xjc</goal>
                </goals>
                <configuration>
                    <packageName>com.mycompany.wsclient.producersLicenseData</packageName>
                    <sourceType>wsdl</sourceType>
                    <sources>
                    <source>src/main/resources/wsdl/GetProducersLicenseData.wsdl</source>
                    </sources>
                    <outputDirectory>target/generated-sources/xjb</outputDirectory>
                    <clearOutputDir>false</clearOutputDir>
                </configuration>
            </execution>
    
    
         </executions>
      </plugin>
    
    0 讨论(0)
  • 2020-11-28 03:50

    There is another, a clear one (IMO) solution to this There is a parameter called "staleFile" that uses as a flag to not generate stuff again. Simply alter it in each execution.

    0 讨论(0)
提交回复
热议问题