【问题标题】:Add explicit source directory in jaxb2-maven-plugin for schemagen在 jaxb2-maven-plugin 中为 schemagen 添加显式源目录
【发布时间】:2014-01-23 03:49:10
【问题描述】:

我想从带有 JAXB 注释的类中生成模式。为此,我正在使用 jaxb2-maven-plugin。该插件默认扫描 src/main/java 文件夹以查找包含的源。我想指定一个额外的文件夹来扫描不是 maven 源路径的 java 类。

有人可以帮忙吗?

  <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> 

【问题讨论】:

  • ${basedir}/whatever/**/*.java ?
  • 不,这不起作用。该插件默认位于 src/main/java 文件夹中。一种方法是在我不想要的 maven 源路径中添加文件夹。

标签: maven jaxb jaxb2 maven-jaxb2-plugin jaxb2-maven-plugin


【解决方案1】:

includes 应该是目录的绝对路径:

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

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

【讨论】:

    【解决方案2】:

    你需要使用 sources 而不是 includes

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

    这样它只会扫描你在sources标签之间写的路径。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多