zoukankan      html  css  js  c++  java
  • Gradle上传依赖到私服(nexus)

    子模块配置

    buildscript {
        repositories {
            mavenLocal()
            maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
          maven {
             url "${nexusUrl}"
             credentials {
                username "${username}"
                password "${password}"
             }
          }
        }
        dependencies {
            classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        }
    }
    
    repositories {
       mavenLocal()
       maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
       maven {
          url "${nexusUrl}"
          credentials {
             username "${username}"
             password "${password}"
          }
       }
    }
    
    apply plugin: 'maven'
    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'
    
    bootJar.enabled = false
    jar.enabled = true
    
    dependencyManagement {
       imports {
          mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
       }
    }
    
    task sourceJar(type: Jar) {
       from sourceSets.main.allJava
    }
    
    uploadArchives {
       repositories {
          mavenDeployer {
             pom.groupId = "com.hcg"
             pom.version = "1.0"
             pom.artifactId = "common-util"
             repository(url: "${nexusUrl}") {
                authentication(userName: "${username}", password: "${password}")
             }
          }
       }
    }
    
    dependencies {
       compile group: 'com.alibaba', name: 'fastjson', version: '1.2.58'
    }
    
    

    父模块build.gradle

    project.ext {
        springBootVersion = '2.0.3.RELEASE'
        springCloudVersion = 'Finchley.RELEASE'
        nexusUrl = 'http://39.98.129.242:8081/repository/hcg-releases/'
        username = 'admin'
        password = '密码'
    }
    
    allprojects {
        group 'com.hcg'
    }
    
    subprojects {
        apply plugin: 'java'
        apply plugin: 'idea'
        sourceCompatibility = 11
        targetCompatibility = 11
    
        repositories {
            mavenLocal()
        }
    
        dependencies {
    
        }
    
    }
    

    说明

    如果只是子模块只要将变量替换即可

    ${nexusUrl}:仓库地址
    ${username}:用户
    ${password}:密码
    

    上传命令

    gradle uploadArchives
    
  • 相关阅读:
    幂等性-接口安全性
    spring 事务
    Disruptor 并发框架
    java中锁的应用
    线程池原理
    并发队列阻塞式与非阻塞式的区别
    Swagger UI教程 API 文档神器 搭配Node使用
    linux ssh_config和sshd_config配置文件
    Linux中iptables设置详细
    Linux(Centos)之安装Redis及注意事项
  • 原文地址:https://www.cnblogs.com/pigmen/p/14088659.html
Copyright © 2011-2022 走看看