-
Notifications
You must be signed in to change notification settings - Fork 462
/
Copy pathbuild.gradle
124 lines (105 loc) · 3.09 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
plugins {
id 'com.diffplug.spotless' version '6.25.0' apply false
id 'org.kordamp.gradle.jandex' version '2.1.0' apply false
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
id 'net.researchgate.release' version '3.0.2'
}
wrapper {
gradleVersion = '8.10.1'
}
String groupId = 'org.gitlab4j'
subprojects {
apply plugin: 'java-library'
apply plugin: 'signing'
apply plugin: 'com.diffplug.spotless'
apply plugin: 'maven-publish'
apply plugin: 'org.kordamp.gradle.jandex'
group = groupId
signing {
useGpgCmd()
sign(publishing.publications)
}
tasks.withType(Sign) {
onlyIf {
project.hasProperty('signing.gnupg.keyName')
}
}
java {
withJavadocJar()
withSourcesJar()
compileJava.options.encoding = "UTF-8"
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}
spotless {
java {
palantirJavaFormat()
importOrder 'java', 'javax', 'jakarta', 'org', 'com', ''
removeUnusedImports()
}
}
repositories {
// mavenLocal()
mavenCentral()
}
tasks.named('test') {
useJUnitPlatform()
}
tasks.named("javadoc") {
inputs.files(tasks.getByPath("jandex").outputs.files)
}
}
nexusPublishing {
packageGroup = 'org.gitlab4j'
repositories {
sonatype {
nexusUrl.set(uri("https://oss.sonatype.org/service/local/"))
username = project.findProperty('ossSonatypeUsername') ?: ''
password = project.findProperty('ossSonatypePassword') ?: ''
}
}
}
release {
buildTasks = ['doRelease']
git {
requireBranch.set('main')
}
}
def checkLastVersionValueTask = tasks.register('checkLastVersionValue') {
doLast {
if(version.endsWith('SNAPSHOT')) {
throw new GradleException("version '$version' ends with SNAPSHOT, this is not a release build!")
}
if(lastVersion != version) {
throw new GradleException("lastVersion '$lastVersion' does not match version '$version', fix it in the 'gradle.properties' file.")
}
}
}
def updateLastVersionValueTask = tasks.register('updateLastVersionValue') {
doLast {
def propertiesFile = file('gradle.properties')
def content = propertiesFile.text
def newVersion = project.findProperty('release.releaseVersion') ?: version.replace('-SNAPSHOT', '')
content = content.replaceAll("lastVersion=[0-9a-z\\.\\-]+", "lastVersion=" + newVersion)
propertiesFile.text = content
def readmeFile = file('README.md')
def readme = readmeFile.text
readme = readme.replace(lastVersion, newVersion)
readmeFile.text = readme
}
}
task doRelease {
dependsOn(
checkLastVersionValueTask,
'initializeSonatypeStagingRepository',
'clean',
'build',
project.getTasksByName('publishToSonatype', true)
)
}
model {
tasks.unSnapshotVersion {
dependsOn updateLastVersionValueTask
}
}