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

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

问题描述

我正在寻找一种创建包含GWT模块的.class和.java文件的jar文件的方法。任何人都知道如何实现这一目标?



Superthanks!

// Niclas

解决方案

在您的pom.xml中编辑资源部分。

 <建立> 
...
<资源>
< resource>
<目录> src / main / resources< /目录>
< / resource>
< resource>
<目录> src / main / java< / directory>
<包括>
< include> ** / *。java< / include>
< include> ** / *。gwt.xml< / include>
< / includes>
< / resource>
< /资源>
...
< / build>

您也可以编辑maven-jar-plugin,将它们从最终的JAR中排除。

 < plugin> 
< artifactId> maven-jar-plugin< / artifactId>
<配置>
<! - - 但一定要将源文件从最终的jar文件中排除 - >
<排除>
< exclude> ** / *。java< / exclude>
< exclude> ** / *。gwt.xml< / exclude>
< /不包括>
< / configuration>
< / plugin>


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?

Superthanks!

// Niclas

解决方案

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>

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天全站免登陆