Maven 使用 .class 和 .java 文件创建 jar 文件 [英] Maven create jar file with both .class and .java files

查看:33
本文介绍了Maven 使用 .class 和 .java 文件创建 jar 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来为 GWT 模块创建包含 .class 和 .java 文件的 jar 文件.有人知道如何实现吗?

I'm looking for a way to create jar files containing both .class and .java files for GWT modules. Anyone knows how that could be achieved?

推荐答案

编辑 pom.xml 中的资源部分.

Edit your resources section in your pom.xml.

<build>
  ...
  <resources>
    <resource>
      <directory>src/main/resources</directory>
    </resource>
    <resource>
      <directory>src/main/java</directory>
      <includes>
        <include>**/*.java</include>
        <include>**/*.gwt.xml</include>
      </includes>
    </resource>
  </resources>
  ...
</build>

您还可以编辑 maven-jar-plugin 以将它们从最终 JAR 中排除.

You can also edit the maven-jar-plugin to exclude them from the final JAR.

<plugin>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
      <!-- but be sure to exclude the source from the final jar file -->
      <excludes>
        <exclude>**/*.java</exclude>
        <exclude>**/*.gwt.xml</exclude>
      </excludes>
    </configuration>
</plugin>

这篇关于Maven 使用 .class 和 .java 文件创建 jar 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆