include source code while exporting a jar using maven

百般思念 提交于 2019-12-22 04:04:46

问题


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?


回答1:


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>


来源:https://stackoverflow.com/questions/23933911/include-source-code-while-exporting-a-jar-using-maven

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!