-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.gradle
164 lines (141 loc) · 4.39 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
buildscript {
configurations.classpath {
resolutionStrategy {
//This is required by 'grgit' version '4.1.1':
force 'org.eclipse.jgit:org.eclipse.jgit:5.13.0.202109080827-r'
}
}
}
plugins {
id 'com.diffplug.spotless' version '5.1.1' apply false
id 'org.asciidoctor.jvm.convert' version '3.3.2'
id 'org.ajoberstar.git-publish' version '3.0.1'
id 'org.ajoberstar.grgit' version '4.1.1'
id 'de.marcphilipp.nexus-publish' version '0.4.0' apply false
id 'net.researchgate.release' version '2.6.0'
id 'io.codearte.nexus-staging' version '0.22.0'
}
wrapper {
gradleVersion = '7.3.3'
}
allprojects {
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'de.marcphilipp.nexus-publish'
group = 'org.openapitools.empoa'
}
subprojects {
apply plugin: 'com.diffplug.spotless'
spotless {
java {
importOrder 'java', 'javax', 'org', 'com', ''
removeUnusedImports()
// available versions are: https://github.com/diffplug/spotless/tree/master/lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_jdt_formatter
eclipse('4.13.0').configFile('.settings/org.eclipse.jdt.core.prefs')
}
}
repositories {
// mavenLocal()
mavenCentral()
jcenter()
// maven {
// url "http://dl.bintray.com/jmini/maven/"
// }
}
nexusPublishing {
repositories {
sonatype {
username = project.findProperty('sonatypeUser') ?: ''
password = project.findProperty('sonatypePassword') ?: ''
}
}
}
}
nexusStaging {
packageGroup = 'org.openapitools'
username = project.findProperty('sonatypeUser') ?: ''
password = project.findProperty('sonatypePassword') ?: ''
}
def buildDate() {
return new Date().format('yyyy-MM-dd')
}
configurations {
asciidoctorExtensions
}
asciidoctorj {
version = "$asciidoctorjVersion"
}
asciidoctor {
configurations 'asciidoctorExtensions'
sourceDir = file('docs')
baseDirFollowsSourceFile()
outputDir = file('build/docs/html5')
attributes = ['revdate' : "${buildDate()}",
'project-version' : "$version",
'artifacts-version' : "$lastVersion",
'mp-openapi-version': "$mpOpenAPIVersion",
'gh-repo-owner' : "$githubRepositoryOwner",
'gh-repo-name' : "$githubRepositoryName",
'source-highlighter': 'coderay',
'imagesdir' : '',
'toc' : 'left',
'toclevels' : '3',
'icons' : 'font',
'sectanchors' : 'true',
'idprefix' : '',
'idseparator' : '-',
'docinfo1' : 'true']
repositories {
mavenCentral()
}
dependencies {
asciidoctorExtensions 'fr.jmini.asciidoctorj:git-link:3.2.1'
}
}
gitPublish {
repoUri = '[email protected]:' + "$githubRepositoryOwner" + '/' + "$githubRepositoryName" + '.git'
branch = 'gh-pages'
contents {
from "${file('build/docs/html5')}"
}
preserve {
include '.nojekyll'
}
commitMessage = "Update the 'gh-pages' branch."
}
release {
buildTasks = ['releaseBuild']
}
task releaseBuild {
dependsOn(
'checkLastVersionValue',
'clean',
'build',
'publish',
'asciidoctor',
'gitPublishPush'
)
}
task 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
content = content.replaceAll("lastVersion=[0-9\\.]+", "lastVersion=" + version.replace('-SNAPSHOT', ''))
propertiesFile.text = content
}
}
model {
tasks.unSnapshotVersion {
dependsOn updateLastVersionValueTask
}
}