jaxb アノテーション付きクラスから XSD を生成するために jaxb2-maven-plugin を使用しています。
構成はこんな感じ
<execution>
<id>rest-api-execution-schemagen</id>
<goals>
<goal>schemagen</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<sources>
<source>src/java/foo/rest/execution/model</source>
</sources>
<outputDirectory>${project.build.directory}/execution-api-xml-schema</outputDirectory>
</configuration>
</execution>
<source>
パッケージ foo/rest/execution/model には多くのクラスが含まれているため、それらすべてを個別の要素にリストすることは避けたいと考えています。代わりに、1 つの要素src/java/foo/rest/execution/model
を使用して、ディレクトリ全体を含めることを指定しました。<source>
問題は、サブパッケージがあることです:
foo/rest/execution/model/builder
... jaxb アノテーションが付けられておらず、スキーマの一部であってはならない他のクラスが含まれています。残念ながら、schemagen ゴールは foo/rest/execution/model ディレクトリを再帰的にトラバースしようとするため、サブディレクトリ内のクラスのスキーマを生成しようとします。
それを回避する方法はありますか?