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
    
  • 相关阅读:
    IDEA 删除java类的3种提示
    IDEA类和方法注释模板设置(非常详细)
    IntelliJ IDEA 2019,从入门到疯狂,图文教程
    intellij idea 如何将普通项目转换为maven项目
    使用idea误点 Add as Ant Build File选项后
    idea使用"svn"到项目报错Error:Cannot run program "svn" (in directory "E:XXXXXX"):CreateProcess error=2,
    Alertmanager 部署配置
    Prometheus PromQL 简单用法
    Prometheus PromQL 基础
    Prometheus 自动发现
  • 原文地址:https://www.cnblogs.com/pigmen/p/14088659.html
Copyright © 2011-2022 走看看