gradle安装到本地库以及上传至私服

gradle安装到本地库以及上传至私服

基于gradle 4.7

引入插件

plugins {
    id 'maven'
}

gradle配置文件

plugins {
    id 'java'
    id 'maven'
}

group ' cn.github.gradle'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

## 指定本地maven仓库位置
def lmr = 'file://' + new File("E:\\installed\\mavenRepository\\repo").absolutePath

repositories {
    # 先到本地仓库取,没有取到再到mavenCentral取
    maven {
        url lmr
    }
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile group: 'com.alibaba', name: 'fastjson', version: '1.2.54'
}



//默认install 到.m2,好像只能到.m2目录
install {
    repositories.mavenInstaller {
        pom.version =  project.version
        pom.artifactId = 'basic-demo'
        pom.groupId = project.group
    }
}


## 上传到本地,也可以上传至私服
uploadArchives {
    repositories {
        mavenDeployer {
            //如果上传至私服,修改url为私服地址
            repository(url: "http://192.168.10.189:8000/nexus/content/repositories/snapshots") {
	//          authentication(userName: "dev", password: "dev")
	//       }
            repository(url: lmr)
            pom.version = project.version
            pom.artifactId = 'basic-demo'
            pom.groupId = project.group
        }
    }
}

gradle插件地址介绍:Maven Plugin

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页