How to generate a JAR with the source code in Maven

删除回忆录丶 提交于 2019-12-05 15:44:24

问题


How can I use Maven 2.2 to generate a JAR with the source code inside it?


回答1:


Use the <resources> element; nutshell:

<build>
<...>
<resources>
 <resource>
    <directory>${basedir}/src/main/resources</directory>
 </resource>
 <resource>
    <directory>${basedir}/src/main/java</directory>
 </resource>
</resources>
<...>
</build>

Edit: Oh, I thought you meant you wanted a single jar with both normal jar contents and the source.




回答2:


mvn source:jar

This is using the source:jar plugin documentation

Usage documentation



来源:https://stackoverflow.com/questions/8993004/how-to-generate-a-jar-with-the-source-code-in-maven

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