-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
257 lines (221 loc) · 8.38 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
def checkProperty(Project project, String propName) {
if (!project.hasProperty(propName)) return false
String prop = project.property(propName)
return prop != null && prop.length() > 0
}
def getPropertyOrElse(Project project, String propName, String alternative) {
if (!checkProperty(project, propName)) return alternative
return project.property(propName)
}
def isLibraryProject(String projectName) {
return !projectName.startsWith('skr-demo')
}
buildscript {
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/plugins-release' }
}
dependencies {
// classpath 'ch.raffael.markdown-doclet:markdown-doclet:1.4' // TODO this plugin is not worked since JDK 11
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
}
}
plugins {
id 'idea'
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.7'
}
//*************************************************************************
// Versioning
//*************************************************************************
task(release) {
doLast {
if (getPropertyOrElse(project, 'newVersion', '') == '') {
throw new IllegalArgumentException("Argument 'newVersion' is not specified. Please carry '-PnewVersion=x.x.x' as argument.")
}
def currentVersion = "${version}"
def newVersion = getPropertyOrElse(project, 'newVersion', '')
println "Setting version from $currentVersion to $newVersion"
ant.replaceregexp(match:currentVersion, replace:newVersion, flags:'g', byline:true, file:'README.md')
// fileset doesn't work as expected
ant.propertyfile(file: "gradle.properties") {
entry( key: "version", value: "$newVersion")
}
}
}
//*************************************************************************
// IDEA
//*************************************************************************
idea {
module {
inheritOutputDirs = true
downloadSources = true
}
project {
settings {
compiler {
javac {
javacAdditionalOptions "-parameters"
}
}
}
}
}
//*************************************************************************
// Sub Project Config
//*************************************************************************
subprojects {
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
maven { url "https://jitpack.io" }
}
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'io.spring.dependency-management'
// apply plugin: 'ch.raffael.markdown-doclet'
if (isLibraryProject(name)) {
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'signing'
}
//*************************************************************************
// Properties
//*************************************************************************
Properties localProp = new Properties()
try {
localProp.load(project.rootProject.file('local.properties').newDataInputStream())
} catch(Exception ignored) {}
for (String propKey in localProp.keys()) {
ext.set(propKey, localProp.get(propKey))
}
ext."signing.secretKeyRingFile" = rootProject.file('publish.gpg')
task setProperties {
doFirst {
project.ext.executable = "$project.name"
}
}
//*************************************************************************
// Compile & Assemble
//*************************************************************************
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
compileJava {
options.compilerArgs << '-parameters'
}
compileTestJava {
options.compilerArgs << '-parameters'
}
tasks.withType(AbstractCompile) {
options.encoding = 'UTF-8'
}
tasks.withType(Javadoc) {
options.encoding = 'UTF-8'
options.addStringOption('Xdoclint:none', '-quiet')
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
jar {
manifest.attributes provider: 'gradle'
enabled true
doFirst {
archiveFileName = "$project.name-${archiveVersion.get()}.${archiveExtension.get()}"
}
}
test {
testLogging.showStandardStreams = true
workingDir = project.rootDir
testLogging {
events "failed"
exceptionFormat "short"
}
}
dependencies {
implementation "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}"
}
dependencyManagement {
imports {
mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
//*************************************************************************
// Maven
//*************************************************************************
javadoc {
options.addStringOption('Xdoclint:none', '-quiet')
}
if (isLibraryProject(name)) {
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}
artifacts {
archives jar
archives sourcesJar
archives javadocJar
}
group = 'org.laxture'
publishing {
publications {
mavenJava(MavenPublication) {
groupId = project.getGroup()
from components.java
version project.version
artifact sourcesJar
artifact javadocJar
pom {
name = project.name
description = 'skr project is a Spring Boot/Cloud project skeleton that define abstraction of JWT based security configuration.'
url = 'https://github.com/hank-cp/skr'
organization {
name = 'org.laxture'
url = 'https://laxture.org'
}
issueManagement {
system = 'GitHub'
url = 'https://github.com/hank-cp/skr/issues'
}
license {
name = 'Apache License 3.0'
url = 'https://github.com/hank-cp/skr/blob/master/LICENSE'
distribution = 'repo'
}
scm {
url = 'https://github.com/hank-cp/skr'
connection = 'scm:git:git://github.com/hank-cp/skr.git'
developerConnection = 'scm:git:ssh://[email protected]:hank-cp/skr.git'
}
developers {
developer {
name = 'Hank CP'
email = '[email protected]'
}
}
}
repositories {
maven {
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
def stagingRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : stagingRepoUrl
credentials {
username getPropertyOrElse(project, 'sonatypeUsername', '')
password getPropertyOrElse(project, 'sonatypePassword', '')
}
}
}
}
}
}
signing {
sign publishing.publications.mavenJava
}
}
}