在jar中包含其他资源

Nar*_*mar 3 maven-2

我编译了一些类文件和一个jar文件.现在我想在jar文件中包含一些wsdl.

你能告诉我如何修改maven中的pom.xml来实现同样的目标.

关心Gnash - 85

Adr*_*hum 10

这些WSDL文件来自哪里?它们是您的来源吗?

假设你有

project
  + src
    + main
      + java
      + wsdl
      + resources
Run Code Online (Sandbox Code Playgroud)

请加入POM,

<project>
  ...
  <build>
    <resources>
      ...
      <resource>
        <directory>${basedir}/src/main/wsdl</directory>
      <resource>
    </resources>
   </build>
</project>
Run Code Online (Sandbox Code Playgroud)

然后它应该添加您的wsdl作为额外资源


编辑:

有一种替代方法,我们不需要更新project.build.resources来包含所有资源目录.

这是通过使用Build Helper插件

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.8</version>
        <executions>
          <execution>
            <id>add-wsdl-resource</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>add-resource</goal>
            </goals>
            <configuration>
              <resources>
                <resource>
                  <directory>${basedir}/src/main/wsdl</directory>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
Run Code Online (Sandbox Code Playgroud)