How to include automatically xmlbeans generated code into maven jar?

孤街醉人 提交于 2019-12-04 00:45:30

If you configure the plugin under pluginManagement, you still need to declare it under plugins. To simplify, I'm not using the pluginManagement in the pom.xml below:

<project>
  ...
  <dependencies>
    ...
    <dependency>
      <groupId>org.apache.xmlbeans</groupId>
      <artifactId>xmlbeans</artifactId>
      <version>2.4.0</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      ...
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>xmlbeans-maven-plugin</artifactId>
        <version>2.3.3</version>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>xmlbeans</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

With this POM (and some XSD in src/main/xsd which is the default location), running mvn clean package just works (i.e. sources are generated from the XSD, compiled and packaged as part of the build).

jani

Try this.

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>xmlbeans-maven-plugin</artifactId>
    <version>2.3.2</version>
    <executions>
        <execution>
            <id />
            <phase>generate-sources</phase>
            <goals>
                <goal>xmlbeans</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <schemaDirectory>src/main/xsd</schemaDirectory>
        <staleFile>${project.build.directory}/generated-sources/xmlbeans/.staleFlag</staleFile>
        <verbose>false</verbose>
        <quiet>false</quiet>
        <javaSource>1.6</javaSource>                    
    </configuration>
</plugin>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!