Search code examples
javamavenmaven-2

How to generate a JAR with the source code in Maven


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


Solution

  • 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.