问题
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