plugins {
id 'org.springframework.boot' version '2.1.5.RELEASE'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'maven'
id 'maven-publish'
id 'java-library'
}
group = 'com.xxx.xxx'
version = '1.0.1'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
maven {
credentials {
username 'xx'
password 'xx'
}
url {
"http://xxxx/repository/releases-group/"
}
}
mavenCentral()
jcenter()
}
test {
useJUnitPlatform()
}
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
classifier = 'sources'
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId = "$project.group"
artifactId = "$project.name"
version = "$project.version"
from components.java
artifact sourcesJar
}
}
repositories {
maven {
def snapshotsRepoUrl = "http://xxx/repository/releases/"
url "$snapshotsRepoUrl"
credentials {
username = 'xx'
password = 'xxx'
}
}
}
}
bootJar {
enabled = false
}
jar {
enabled = true
}
install {
repositories.mavenInstaller {
pom.version = "$project.version"
pom.groupId = "$project.group"
}
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.hibernate:hibernate-validator:7.0.1.Final'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
然后执行gradle publish 即可