【maven】maven项目打包jar 打包源码,mvn命令打包源码

如题:maven项目打包jar 打包源码,mvn命令打包源码

 

需要:

1.pom.xml文件配置如下:核心红色显示

<build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>2.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.5.1</version>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

 

 

2.正常打包命令如下:

mvn clean deploy

 

3.正常打包完,打包源码的命令:

mvn clean source:jar deploy

 

posted @ 2020-05-05 15:50  Angel挤一挤  阅读(2238)  评论(0编辑  收藏  举报