3

I would like to generate schema from JAXB annotated classes. For this, I am using jaxb2-maven-plugin. The plugin by default scans src/main/java folder for included sources. I would like to specify an extra folder to scan for java classes which is not maven source path.

Can anyone please help?

  <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxb2-maven-plugin</artifactId>
        <version>${maven.plugin.jaxb2}</version>
        <executions>
           <execution>
              <id>schemagen</id>
              <goals>
                 <goal>schemagen</goal>
              </goals>
              <phase>process-classes</phase>
              <configuration>

                 <includes>
                    <include>SomeFolderWhichIsNotInMavenSourcePath/*.java</include>
                 </includes>
                 <outputDirectory>${project.build.directory}/schemas</outputDirectory>
              </configuration>
           </execution>
        </executions>
     </plugin> 
4

2 回答 2

0

包含应该是目录的绝对路径:

<includes>
    <include>${basedir}/src/main/java</include>
</includes>

您可以在调试模式下运行 maven 以查看正在使用哪些源目录。

于 2014-01-27T13:51:49.977 回答
0

您需要使用而不是包含

<sources>
   <source>${basedir}/src/main/java/<YourPath></source>
</sources>

这样,它只会扫描您在源标签之间写入的路径。

于 2018-09-13T15:29:52.467 回答