Stop JaxB from generating files in an episode using maven

时间:2016-04-15 14:58:25

标签: java maven xsd jaxb

I have 4 modules in this service I'm creating. There's upload, association, read, and common. The first 3 modules each have their own wsdls that import a common xsd in the common module. I have the common generate an episode for the common xsd, but each of those modules still generate the same files, so I end up with 4 of each file that is defined in the common xsd.

Here is what I have in the common pom

        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <executions>
                <execution>
                    <id>efolder-model</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <episode>true</episode>
                        <schemaDirectory>src/main/resources/schemas/efolder</schemaDirectory>
                        <schemaIncludes>
                            <include>**/*.xsd</include>
                        </schemaIncludes>
                        <args>

                        </args>
                        <extension>true</extension>
                        <strict>false</strict>
                        <!-- breaks with schema imports -->
                    </configuration>
                </execution>
            </executions>
        </plugin>

And here's a pom from one of the other modules (they are basically the same, just referring to different wsdls)

        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <executions>
                <execution>
                    <id>cdm-model</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <schemaDirectory>${project.build.directory}/classes/schemas</schemaDirectory>
                        <schemaIncludes>
                            <include>schemas/cdm/claim/*.xsd,/cdm/common/*.xsd,/cdm/document/*.xsd,/cdm/participant/*.xsd</include>
                        </schemaIncludes>

                        <bindingDirectory>${project.build.directory}/classes/schemas</bindingDirectory>
                        <bindingIncludes>
                            <bindingInclude>/cdm/mappings.xjb,/cdm/mappings-participant-v4.xsd</bindingInclude>
                        </bindingIncludes>
                        <bindings>
                            <binding>
                            <dependencyResource>
                                <groupId>${project.groupId}</groupId>
                                <artifactId>efolder-svc-web-common</artifactId>
                            </dependencyResource>
                            </binding>
                        </bindings>

                        <extension>true</extension>
                        <strict>false</strict>
                    </configuration>
                </execution>
            </executions>
        </plugin>

I also tried

                        <configuration>
                        <episodes>
                            <episode>
                                <groupId>${project.groupId}</groupId>
                                <artifactId>efolder-svc-web-common</artifactId>
                            </episode>
                        </episodes>
                        <schemaDirectory>${project.build.directory}/classes/schemas</schemaDirectory>
                        <schemaIncludes>
                            <include>schemas/cdm/claim/*.xsd,/cdm/common/*.xsd,/cdm/document/*.xsd,/cdm/participant/*.xsd</include>
                        </schemaIncludes>

                        <bindingDirectory>${project.build.directory}/classes/schemas</bindingDirectory>
                        <bindingIncludes>
                            <bindingInclude>/cdm/mappings.xjb,/cdm/mappings-participant-v4.xsd</bindingInclude>
                        </bindingIncludes>

                        <extension>true</extension>
                        <strict>false</strict>
                    </configuration>

But either way, I still end up with the files generated in the generated-sources/xjc/.../efolder/service/common in each module. And in the common I also have xjc/META-INF/sun-jaxb.episode which is:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<bindings xmlns="http://java.sun.com/xml/ns/jaxb" if-exists="true" version="2.1">
  <!--

This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11 
See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
Any modifications to this file will be lost upon recompilation of the source schema. 
Generated on: 2016.04.15 at 09:56:57 AM EDT 

  -->
  <bindings xmlns:tns="http://service.efolder.url/common" if-exists="true" scd="x-schema::tns">
    <schemaBindings map="false">
      <package name="url.efolder.service.common"/>
    </schemaBindings>
    <bindings if-exists="true" scd="~tns:EFolderFault">
      <class ref="url.efolder.service.common.EFolderFault"/>
    </bindings>
    <bindings if-exists="true" scd="tns:VersionNotFoundFault">
      <class ref="url.efolder.service.common.VersionNotFoundFault"/>
    </bindings>
    <bindings if-exists="true" scd="tns:InvalidDocTypeFault">
      <class ref="url.efolder.service.common.InvalidDocTypeFault"/>
    </bindings>
    <bindings if-exists="true" scd="tns:ClaimNotFoundFault">
      <class ref="url.efolder.service.common.ClaimNotFoundFault"/>
    </bindings>
    <bindings if-exists="true" scd="tns:InvalidClaimFault">
      <class ref="url.efolder.service.common.InvalidClaimFault"/>
    </bindings>
    <bindings if-exists="true" scd="tns:InvalidDocCategoryFault">
      <class ref="url.efolder.service.common.InvalidDocCategoryFault"/>
    </bindings>
    <bindings if-exists="true" scd="tns:SeriesNotFoundFault">
      <class ref="url.efolder.service.common.SeriesNotFoundFault"/>
    </bindings>
    <bindings if-exists="true" scd="~tns:eFolderFaultCategory">
      <typesafeEnumClass ref="url.efolder.service.common.EFolderFaultCategory"/>
    </bindings>
  </bindings>
</bindings>

Any ideas on why it's still generating? Thanks

1 个答案:

答案 0 :(得分:0)

如果你想避免默认(剧集文件),只需在你的插件配置中添加一个名为 episodeFile 的空元素。这对我有用,与maven-jaxb2-plugin(0.12.1.0):

有关
                <configuration>
                     ...
                    <episodeFile/>
                    ...
                </configuration>