Using Maven is too convenient for project deployment, especially dependencies. I recently learned to use Maven, and for the sake of memo and technology sharing, I specially registered an account and recorded it on the blog. How to package source code *-sources.jar in maven.
Method 1 : command line method
Enter the cmd command line, enter the path directory where the project project pom.xml is located, and run mvn source:jar
Method 2: Use IDE, such as eclipse
Right-click on the pom.xml file in the project, " Run as ", and select " Run Configurations... ", as shown in the following figure :
Publish to the local Maven repository and add the following in pom.xml:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>2.1.2</version> <executions> <execution> <id>attach-sources</id> <phase>verify</phase> <goals> <goal>jar-no-fork</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
Right click on the pom.xml file in the project, " Run as ", select " Maven install "