Gradle构建后发布到私有仓库

buildscript {
    ext {
        springBootVersion = '2.0.0.RELEASE'
    }
    repositories {
          maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
    }
    dependencies {
        classpath("com.bmuschko:gradle-nexus-plugin:2.3.1")
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'com.bmuschko.nexus'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

def repo = 'http://nexus/repository'
group = 'com.company.package'
version = '1.0.0-SNAPSHOT'
description = "company-package"

sourceCompatibility = 1.8
targetCompatibility = 1.8

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

tasks.withType(Jar) {
    destinationDir = file("$rootDir/build")
}

repositories {
     maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
}

ext {
    springCloudVersion = 'Finchley.RELEASE'
}

dependencies {
    ...
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}

test {
    exclude '**/*'
}

jar {
    enabled = true
}

bootJar {
    enabled = false
}

extraArchive {
    sources = false
    tests = false
    javadoc = false
}

nexus {
    sign = true
    repositoryUrl = "${repo}/maven-releases/"
    snapshotRepositoryUrl = "${repo}/maven-snapshots/"
}

nexus登录信息需要在~/.gradle/gradle.properties中配置好
nexusUsername = admin
nexusPassword = admin123

你可能感兴趣的:(Gradle构建后发布到私有仓库)