使用Maven对项目部署太方便了,特别是依赖关系,最近学习使用Maven,为了备忘和技术的分享特意注册个账号记录到博客,maven中如何打包源代码 *-sources.jar。
方式一: 命令行方式
进入cmd命令行,进入项目工程pom.xml所在路径目录,运行 mvn source:jar
方式二:使用IDE,如eclipse
右键点击项目中的pom.xml文件,“Run as”,选择“Run Configurations...”,如下图
结果:
发布到本地Maven仓库中,在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>
右键点击项目中的pom.xml文件,“Run as”,选择“Maven install”