• maven上传源码到私服


    上传源码

    项目中采用了分模块的方式构建,直接将maven-source-plugin写到父pom中,尝试了很多次发现源码一直不能上传到私服中,纠结了很长时间才发现原来多模块项目和普通一个项目的配置是有区别的,需要在每个需要上传源码的子模块中都配置maven-source-plugin才可以上传,于是乎有了一下的代码

    1,非多模块项目

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

    2,多模块项目

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

    子项目中增加

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

    然后使用:mvn deploy 既可将源码上传到私服中

    打包问题

    封装过公共组件的同志们都知道,工具组件需要不断的维护升级,还好现在有maven来帮助我们管理各个版本的jar包,但是如何正确的使用maven来让团队使用我们jar呢,这就是我们接下来介绍的。

    首先我们开发的版本都是 SNAPSHOT ,但是当被项目组使用的时候需要发布RELEASE版本来使用,这样不至于我们更改的代码影响团队的使用。因此在deploy项目的时候我们可以分为三部来操作

    mvn versions:set -DnewVersion=1.0.0.RELEASE
    mvn deploy
    mvn versions:set -DnewVersion=0.0.1-SNAPSHOT

    第一步:我们设置当前项目的版本号为 1.0.0Release,这是maven会自动将多模块中所有模块的版本号都更改为当前我们设置的

    第二步:继续使用deploy上传代码

    第三步:我们要继续开发自己的功能,所以需要将项目中的版本号更改为SNAPSHOT

    上面的1.0.0 和 0.0.1 需要根据项目来定,没有固定的要求

     pom中配置配置Nexus

    <distributionManagement>
    <snapshotRepository>
    <id>snapshots</id>
    <name>Nexus Snapshot Repository</name>
    <url>http://x.x.x.x:port/nexus/content/repositories/snapshots/</url>
    </snapshotRepository>
    <repository>
    <id>releases</id>
    <name>Nexus Release Repository</name>
    <url>http://x.x.x.x:port/nexus/content/repositories/releases/</url>
    </repository>
    </distributionManagement>
  • 相关阅读:
    PHP is_float()、 is_double()、is_real()函数
    自动驾驶关键技术分解和流程
    自动驾驶行业内时间表和技术解析
    自动驾驶架构与实现路径
    ADAS单目摄像头行驶区域环境光检测图片标注
    多目标检测整合算法
    道路场景语义分割算法
    TTC测距算法
    TSR交通标志检测与识别
    Mobileye_EyeQ4功能和性能
  • 原文地址:https://www.cnblogs.com/blueskyli/p/9924678.html
Copyright © 2020-2023  润新知