maven生成jar包和源码包并上传到maven仓库

1. pom文件新增生成jar或源码包

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.0.1</version>
                <!-- 绑定source插件到Maven的生命周期,并在生命周期后执行绑定的source的goal -->
                <executions>
                    <execution>
                        <!-- 绑定source插件到Maven的生命周期 -->
                        <phase>compile</phase>
                        <!--在生命周期后执行绑定的source插件的goals -->
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>false</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            
        </plugins>
    </build>
2. 增加上传到远程仓库的配置。

<distributionManagement>
        <repository>
            <id>nuxus</id>
            <name>deploy</name>
            <url>http://192.168.101.189:8081/repository/</url>
        </repository>
    </distributionManagement>
3. 在apache-maven客户端的setting.xml文件配置如下内容:

<servers>
    <server>
      <id>nuxus</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
  </servers>
支持全部配置完成。

评论 (0)