Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

include source code while exporting a jar using maven

Tags:

java

maven-2

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?

like image 725
Eshan Avatar asked May 29 '14 12:05

Eshan


1 Answers

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>
like image 162
Pavlo Butenko Avatar answered Oct 05 '22 13:10

Pavlo Butenko