10

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?

Eshan
  • 113
  • 1
  • 2
  • 8
  • refer this link http://stackoverflow.com/questions/2059431/get-source-jars-from-maven-repository – Ashok_Pradhan May 29 '14 at 13:06
  • 2
    Possible duplicate of [Maven create jar file with both .class and .java files](https://stackoverflow.com/questions/4264359/maven-create-jar-file-with-both-class-and-java-files) – Vadzim Apr 05 '18 at 09:38

1 Answers1

15

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>
Pavlo Butenko
  • 554
  • 5
  • 12