子模块配置
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