Maven 打包源码

2021-06-21 799点热度 0人点赞 0条评论

准备

使用maven打包源码需要用到maven-source-plugin插件,这个只需要在POM中引入即可。

<profiles>
    <profile>
        <id>develop</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.0.1</version>
                    <configuration>
                        <attach>true</attach>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>compile</phase>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

打包

# 清理maven项目
mvn clean

# 安装项目到本地仓库
mvn install

# 发布项目到远程仓库
mvn deploy

# 生成源码jar包
mvn source:jar

# 显示maven依赖树
mvn dependency:tree

# 清理项目、打包源码、安装到本地
mvn clean source:jar install

Jalena

原创内容,转载请注明出处! 部分内容来自网络,请遵守法律适用!

文章评论