1. The source plugin can be used to create a jar file of the project sources from the command line or by binding the goal to the project's build lifecycle. to generate the jar from the command line, use the following command:
MVN Source: jar <br/>A jar file of the test sources can also be generated by executing: MVN Source: Test-jar <br/>After running, the generated source file jar package is found in the target directory. 2. Add the following in POM. xml: <Build> <br/> <plugins> <br/> <plugin> <br/> <artifactid> Maven-source-plugin </artifactid> <br/> <version> 2.1 </version> <br/> <configuration> <br/> <attach> true </Attach> <br/> </configuration> <br/> <executions> <br/> <execution> <br/> <phase> compile </phase> <br/> <goals> <br/> <goal> jar </goal> <br/> </goals> <br/> </execution> <br/> </executions> <br/> </plugin> <br/> </plugins> <br/> </build>If phase is specified as compile in the configuration, the source file is packaged during the lifecycle compile, that is, the source code is packaged as long as the MVN Command executed includes the compile stage. Similarly, phase can also be specified as package, install, and so on.