I have the following problem. I have project A where I have common.xsd file, and project B which have dependency to project A and have main.xsd file. I use episode files and my pom in B looks like this
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<args>
<arg>-Xannotate</arg>
<arg>-Xnamespace-prefix</arg>
<arg>-nv</arg>
</args>
<extension>true</extension>
<forceRegenerate>true</forceRegenerate>
<bindingDirectory>${basedir}/src/main/resources/xjb</bindingDirectory>
<bindingIncludes>
<include>*.xjb</include>
</bindingIncludes>
<schemas>
<schema>
<fileset>
<directory>${basedir}/src/main/resources/xsd/</directory>
<includes>
<include>B.xsd</include>
</includes>
</fileset>
</schema>
<schema>
<dependencyResource>
<groupId>AgroupID</groupId>
<artifactId>AartifactID</artifactId>
<resource>xsd/A.xsd</resource>
</dependencyResource>
</schema>
</schemas>
<episodes>
<episode>
<groupId>AgroupID</groupId>
<artifactId>AartifactID</artifactId>
</episode>
</episodes>
<debug>true</debug>
<verbose>true</verbose>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.2</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
<version>0.6.2</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-namespace-prefix</artifactId>
<version>1.1</version>
</plugin>
</plugins>
</configuration>
</plugin>
but I have also wsdl file where I have this import
<xsd:import namespace="SOME_NAMASPACE" schemaLocation="main.xsd" />
and when I change
<include>B.xsd</include>
to
<include>main.wsdl</include>
and turn wsdl by
<wsdl>true</wsdl>
classes are generated properly, but these common classes from project A are duplicated. When I have xsd instead of wsdl it works good
-- update --
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<excludes>
<exclude>classpath:xsd/common.xsd</exclude>
</excludes>
<sourceRoot>${generated_src}</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${project.basedir}PATH_TO_WSDL/main.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
-- update --
snippet of wsdl file
<wsdl:types>
<xsd:schema
xmlns=...
targetNamespace=...
xmlns:carlic="NAMESPACE_OF_MAIN_XSD">
<xsd:import namespace="NAMESPACE_OF_MAIN_XSD" schemaLocation="main.xsd" />
<xsd:element name="carData" type="carlic:CarData" />
</xsd:schema>
</wsdl:types>