-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
172 lines (145 loc) · 4.37 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
165
166
167
168
169
170
171
172
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 'java'
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 'com.diffplug.spotless' version '5.1.1'
id 'net.researchgate.release' version '2.6.0'
}
wrapper {
gradleVersion = '7.3.3'
}
group = 'fr.jmini.utils'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}
repositories {
mavenCentral()
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar) {
from javadoc
classifier = 'javadoc'
}
dependencies {
implementation "fr.jmini.utils:mvn-utils:$mvnUtils"
implementation "biz.aQute.bnd:biz.aQute.bnd:$bndVersion"
implementation "com.google.code.gson:gson:$gsonVersion"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testImplementation "org.assertj:assertj-core:$assertjVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
}
test {
testLogging {
events = ["passed", "failed", "skipped"]
}
doFirst {
convertProjectPropertyToSystemProperty(delegate, 'ignoreExistingData')
}
useJUnitPlatform()
}
def buildDate() {
return new Date().format('yyyy-MM-dd')
}
configurations {
asciidoctorExtensions
}
asciidoctorj {
version = "$asciidoctorjVersion"
}
asciidoctor {
configurations 'asciidoctorExtensions'
sourceDir = file('src/docs/asciidoc')
baseDirFollowsSourceFile()
outputDir = file('build/docs/html5')
attributes = ['revdate' : "${buildDate()}",
'project-version' : "$version",
'last-stable-version' : "$lastVersion",
'attribute-missing' : 'warn',
'source-highlighter' : 'coderay',
'imagesdir' : '',
'toc' : 'left',
'icons' : 'font',
'toclevels' : '3',
'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'
exclude '.DS_Store'
}
commitMessage = "Update the 'gh-pages' branch."
}
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')
}
}
release {
buildTasks = ['doRelease']
}
task doRelease {
dependsOn(
'checkLastVersionValue',
'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 convertProjectPropertyToSystemProperty(Object delegate, String key) {
if(project.hasProperty(key)) {
delegate.systemProperty(key, project.getProperty(key))
}
}
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
}
}