I wanted to bundle a jar file along with the source using Maven for the Vaadin addon. I knew about the maven source plugin. The maven-source-plugin could be used to generate a source code jar file for a project. Deploying this source jar to a remote repository could be useful to the developers as they could 'attach source' and debug the project source code. Maven does a great job of automating this process.
But, the above written approach did not help me, thats the reason why I tried another solution which finally worked for me. Hereby, I am writing the same solution hoping that it might help community members.
Pom.xml
<project ...>
<modelVersion>4.0.0</modelVersion>
<groupId>YOUR_PROJECT_GROUP</groupId>
<version>YOUR_PROJECT_VERSION</version>
<artifactId>YOUR_PROJECT_ARTIFACT</artifactId>
<name>YOUR_PROJECT_NAME</name>
...
...
<build>
<resources>
...
...
<resource>
<directory>src/main/java</directory>
<includes>
....
.....
<include>**/*.java</include>
</includes>
</resource>
...
...
</resources>
<plugins>
...
...
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>
true
</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>
true
</addDefaultSpecificationEntries>
</manifest>
<manifestEntries>
<License-Title>Apache License 2.0</License-Title>
</manifestEntries>
</archive>
</configuration>
</plugin>
...
...
</plugins>
</build>
...
...
</project>
view raw pom.xml hosted with ❤ by GitHub

Final jar File