简体   繁体   English

Maven 使用 .class 和 .java 文件创建 jar 文件

[英]Maven create jar file with both .class and .java files

I'm looking for a way to create jar files containing both .class and .java files for GWT modules.我正在寻找一种方法来为 GWT 模块创建包含 .class 和 .java 文件的 jar 文件。 Anyone knows how that could be achieved?任何人都知道如何实现?

Edit your resources section in your pom.xml.编辑 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>

You can also edit the maven-jar-plugin to exclude them from the final JAR.您还可以编辑 maven-jar-plugin 以将它们从最终 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>

使用 pom.xml 中的资源标签来包含 src/main/java。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM