Eshan
Eshan

Reputation: 133

include source code while exporting a jar using maven

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?

Upvotes: 12

Views: 15710

Answers (1)

Pavlo Butenko
Pavlo Butenko

Reputation: 594

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>

Upvotes: 19

Related Questions