在pom.xml
添加maven-source-plugin
插件
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
此时发包的时候将会把源码包(-source.jar
)发布到仓库
依赖方下载源码包
mvn dependency:resolve -Dclassifier=sources