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
    
  • 相关阅读:
    To Do List
    Linux 替换文本中对空格为下划线
    Jumpserver开源堡垒机
    用jmeter编写脚本做实时线上监控
    Supervisor使用详解
    Python模块之pysnooper
    Java读取json文件并进行处理
    IOS APP自动化测试 真机测试 遇到的坑
    测试人员入职必须了解的东西包括下面一些内容
    linux 和MacBook下的批替换
  • 原文地址:https://www.cnblogs.com/pigmen/p/14088659.html
Copyright © 2011-2022 走看看