美文网首页技术专区-Maven系列
maven上传源码到私服

maven上传源码到私服

作者: 逗逼程序员 | 来源:发表于2020-05-08 20:28 被阅读0次

    项目中经常碰到查看别人源码而没有,只能反编译的情况,是不是很痛苦?

    所以 从自身做起,上传jar 给别人引用的时候 ,同时 deploy 源码上去,那么

    如何上传源码到私服呢?分两种情况:

    第一种:项目为非多module

    直接引入如下 插件:

    <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>
    

    版本可以根据自己需要做修改。

    第二种:项目为多module(需要自行进行实验~~哈啊哈哈哈)

    在父pom 中添加如下

    <pluginManagement>
       <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>
    </pluginManagement>
    

    子module中添加如下:

    <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    

    OK ,搞定 执行 命令 mvn deploy 或者走你公司二方库发布流程项目包含源码就部署上去了。

    相关文章

      网友评论

        本文标题:maven上传源码到私服

        本文链接:https://www.haomeiwen.com/subject/qnvqnhtx.html