使用maven导出jar时包含源代码 [英] include source code while exporting a jar using maven

查看:95
本文介绍了使用maven导出jar时包含源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用maven导出一个jar文件,其中可以包含源文件.我尝试使用"maven-source-plugin",但它使用源创建了一个单独的jar文件.有什么方法可以像使用带有源的普通eclipse导出一样使用maven导出jar文件吗?

I want to export a jar file using maven which can have the source included in it. I tried using 'maven-source-plugin', but it creates a separate jar file with source. Is there any way that I can export a jar file using maven like a normal eclipse export with source?

推荐答案

您可以使用资源"部分进行操作,请参见示例:

You can do it with resource section, see example:

<build>
    <resources> 
        <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.java</include>
                    <include>**/*.gwt.xml</include>
                </includes>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <includes></includes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.3</version>
            <configuration>
              <includes>
                <include>**/*</include>
              </includes>
              <archive>
                <manifestFile>WebContent/META-INF/MANIFEST.MF</manifestFile>
              </archive>
            </configuration>
        </plugin>
    </plugins>
</build>

这篇关于使用maven导出jar时包含源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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