-
Notifications
You must be signed in to change notification settings - Fork 16
/
build.gradle
384 lines (334 loc) · 14.8 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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
buildscript {
apply from: "$rootDir/gradle-scripts/repositories.gradle"
}
plugins {
// Here we define all plugins that are used by subprojects and specify the version for external ones
id 'idea'
id 'maven-publish'
id 'signing'
id 'java'
id 'java-library' // needed to make sure that transitive deps have 'compile' scope
id "com.diffplug.spotless" version "6.25.0"
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
id 'com.github.jk1.dependency-license-report' version '2.0'
id "me.champeau.jmh" version "0.6.8"
id "jacoco"
id "versioning"
id "srcinfo"
}
import java.text.SimpleDateFormat
apply plugin: 'versioning'
def globalVersion = new Version(version)
class Version {
String originalVersion
String thisVersion
String status
Date buildTime
Version(String versionValue) {
buildTime = new Date()
originalVersion = versionValue
thisVersion = versionValue
if (originalVersion.endsWith('-SNAPSHOT')) {
status = 'integration'
} else {
status = 'release'
thisVersion = versionValue
}
}
String getTimestamp() {
// Convert local file timestamp to UTC
def format = new SimpleDateFormat('yyyyMMddHHmmss')
format.setCalendar(Calendar.getInstance(TimeZone.getTimeZone('UTC')))
return format.format(buildTime)
}
String toString() {
thisVersion
}
}
allprojects {
apply from: "$rootDir/gradle-scripts/repositories.gradle"
description = "The e-commerce SDK from commercetools Composable Commerce for Java"
configurations {
taglet {
resolutionStrategy.force("net.sourceforge.plantuml:plantuml:1.2024.5")
}
}
dependencies {
taglet 'com.commercetools.build.taglets:commercetools-taglets:3.6.3'
taglet 'com.google.guava:guava:33.2.1-jre'
taglet 'org.jdrupes.taglets:plantuml-taglet:3.1.0'
}
}
apply from: "$rootDir/gradle-scripts/repositories.gradle"
apply from: "$rootDir/gradle-scripts/extensions.gradle"
apply from: "$rootDir/gradle-scripts/jacoco.gradle"
apply from: "$rootDir/gradle-scripts/spotless.gradle"
group='com.commercetools.sdk'
subprojects { project ->
apply from: "$rootDir/gradle-scripts/subproject-plugins.gradle"
apply from: "$rootDir/gradle-scripts/subproject-dependencies.gradle"
apply from: "$rootDir/gradle-scripts/subproject-config.gradle"
if (project.file("build.gradle").exists()) {
apply from: "$rootDir/gradle-scripts/subproject-srcinfo-plugin.gradle"
}
group='com.commercetools.sdk'
version = globalVersion
check.dependsOn(integrationTest)
java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}
tasks.withType(JavaCompile).configureEach {
// pass a custom VM option to java compiler.
it.options.forkOptions.jvmArgs += [
'-Xmx2048m'
]
}
tasks.withType(Javadoc).configureEach {
javadocTool = javaToolchains.javadocToolFor {
languageVersion = JavaLanguageVersion.of(17)
}
}
compileIntegrationTestJava {
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(17)
}
}
compileTestJava {
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(17)
}
}
tasks.withType(Test).configureEach {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}
}
}
apply from: "$rootDir/gradle-scripts/publishing.gradle"
import com.github.jk1.license.filter.LicenseBundleNormalizer
import com.github.jk1.license.render.*
apply plugin: 'com.github.jk1.dependency-license-report'
licenseReport {
// Set output directory for the report data.
// Defaults to ${project.buildDir}/reports/dependency-license.
outputDir = "$projectDir/licenses"
// Adjust the configurations to fetch dependencies, e.g. for Android projects. Default is 'runtimeClasspath'
configurations = ['runtimeClasspath']
// Use 'ALL' to dynamically resolve all configurations:
// configurations = ALL
// Don't exclude bom dependencies.
// If set to true, then all boms will be excluded from the report
excludeBoms = true
// This is for the allowed-licenses-file in checkLicense Task
// Accepts File, URL or String path to local or remote file
allowedLicensesFile = new File("$projectDir/allowed-licenses.json")
renderers = [new JsonReportRenderer("index.json", false)]
filters = [new LicenseBundleNormalizer(bundlePath: "$projectDir/normalizer-bundle.json")]
}
generateLicenseReport {
outputs.upToDateWhen { false }
}
def excludeProjects = [
'internal-docs'
]
subprojects { project ->
if (project.file("build.gradle").exists() && !excludeProjects.contains(project.name)) {
apply plugin: 'com.github.jk1.dependency-license-report'
licenseReport {
// Set output directory for the report data.
// Defaults to ${project.buildDir}/reports/dependency-license.
outputDir = "$rootDir/licenses/${project.name}"
projects = [project]
// Adjust the configurations to fetch dependencies, e.g. for Android projects. Default is 'runtimeClasspath'
configurations = ['runtimeClasspath']
// Use 'ALL' to dynamically resolve all configurations:
// configurations = ALL
// Don't exclude bom dependencies.
// If set to true, then all boms will be excluded from the report
excludeBoms = true
// This is for the allowed-licenses-file in checkLicense Task
// Accepts File, URL or String path to local or remote file
allowedLicensesFile = new File("$rootDir/allowed-licenses.json")
renderers = [new JsonReportRenderer("index.json", false)]
filters = [new LicenseBundleNormalizer(bundlePath: "$rootDir/normalizer-bundle.json")]
}
checkLicense.dependsOn(':generateLicenseReport')
generateLicenseReport {
outputs.upToDateWhen { false }
}
}
tasks.register("allDeps", DependencyReportTask) {}
}
def documentationProjects= [
":commercetools:commercetools-apachehttp-client",
":commercetools:commercetools-async-http-client",
":commercetools:commercetools-graphql-api",
":commercetools:commercetools-http-client",
":commercetools:commercetools-javanet-client",
":commercetools:commercetools-money",
":commercetools:commercetools-monitoring-newrelic",
":commercetools:commercetools-monitoring-opentelemetry",
":commercetools:commercetools-monitoring-datadog",
":commercetools:commercetools-okhttp-client3",
":commercetools:commercetools-okhttp-client4",
":commercetools:commercetools-reactornetty-client",
":commercetools:commercetools-sdk-compat-v1",
":commercetools:commercetools-sdk-java-api",
":commercetools:commercetools-sdk-java-history",
":commercetools:commercetools-sdk-java-importapi",
":commercetools:internal-docs",
":rmf:rmf-java-base"
]
allprojects {
project -> {
if (project.file('src/jmh').exists())
tasks.register("benchmark") {
dependsOn 'jmh'
}
}
}
tasks.register('alljavadoc', Javadoc) {
group = "documentation"
source documentationProjects.collect { project(it).sourceSets.main.allJava }
classpath = files(documentationProjects.collect { project(it).sourceSets.test.compileClasspath })
destinationDir = file("${buildDir}/docs/javadoc")
excludes = [
'**/*Test.java',
'**/test/*.java'
]
options {
setMemberLevel JavadocMemberLevel.PUBLIC
setAuthor false
noTimestamp = true
splitIndex = true
noTree = true
title = "commercetools Java SDK"
links 'https://docs.oracle.com/javase/8/docs/api/', "https://fasterxml.github.io/jackson-databind/javadoc/2.14/", 'https://commercetools.github.io/commercetools-jvm-sdk/apidocs/', 'https://newrelic.github.io/java-agent-api/javadoc/'
overview = "src/main/javadoc/overview.html"
bottom = """
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.8.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.8.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<span id="custom-javascripts"></span>
<script src="{@docRoot}/resources/javascripts/main.js"></script>
<link rel="stylesheet" href="{@docRoot}/resources/stylesheets/main.css">
"""
taglets = ['com.commercetools.taglets.CodeTaglet', 'com.commercetools.taglets.ToCTaglet', 'com.commercetools.taglets.FileIncludeTaglet', 'org.jdrupes.taglets.plantUml.StartUml', 'org.jdrupes.taglets.plantUml.EndUml', 'org.jdrupes.taglets.plantUml.PlantUml']
tagletPath = configurations.taglet.files as List
maxMemory = '2g'
excludes = ['com/commercetools/graphql/api/client/**', 'com/commercetools/graphql/api/Dgs**','com/commercetools/graphql/api/types/**', 'com/commercetools/api/predicates/query/**/*Dsl.java', 'com/commercetools/**/*Impl.java']
addBooleanOption('-allow-script-in-comments', true)
addStringOption('Xdoclint:missing,accessibility,reference', '-quiet')
// addBooleanOption('linksource', true)
encoding = 'utf-8'
groups = [
"API" : ["com.commercetools.api.*"],
"History" : ["com.commercetools.history.*"],
"Import" : ["com.commercetools.importapi.*"],
"ML" : ["com.commercetools.ml.*"],
"Base Packages": ["io.vrap.rmf.base.*"],
"HTTP Clients" : [
"com.commercetools.http.*",
"io.vrap.rmf.okhttp.*"
],
"Monitoring" : ["com.commercetools.monitoring.*"]
]
addStringOption('source', '8')
}
doLast {
copy {
from "src/main/javadoc/resources"
into "${buildDir}/docs/javadoc/resources"
}
}
}
def internalDocProjects= [
":commercetools:internal-docs",
]
tasks.register('internaldocs', Javadoc) {
group = "documentation"
source internalDocProjects.collect { project(it).sourceSets.main.allJava }
classpath = files(internalDocProjects.collect { project(it).sourceSets.test.compileClasspath })
destinationDir = file("${buildDir}/docs/javadoc")
excludes = [
'**/*Test.java',
'**/test/*.java'
]
options {
setMemberLevel JavadocMemberLevel.PUBLIC
setAuthor false
noTimestamp = true
splitIndex = true
noTree = true
title = "commercetools Java SDK"
links 'https://docs.oracle.com/javase/8/docs/api/', "https://fasterxml.github.io/jackson-databind/javadoc/2.14/", 'https://commercetools.github.io/commercetools-jvm-sdk/apidocs/', 'https://newrelic.github.io/java-agent-api/javadoc/'
overview = "src/main/javadoc/overview.html"
bottom = """
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.8.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.8.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<span id="custom-javascripts"></span>
<script src="{@docRoot}/resources/javascripts/main.js"></script>
<link rel="stylesheet" href="{@docRoot}/resources/stylesheets/main.css">
"""
taglets = ['com.commercetools.taglets.CodeTaglet', 'com.commercetools.taglets.ToCTaglet', 'com.commercetools.taglets.FileIncludeTaglet', 'org.jdrupes.taglets.plantUml.StartUml', 'org.jdrupes.taglets.plantUml.EndUml', 'org.jdrupes.taglets.plantUml.PlantUml']
tagletPath = configurations.taglet.files as List
maxMemory = '2g'
excludes = ['com/commercetools/graphql/api/client/**', 'com/commercetools/graphql/api/Dgs**','com/commercetools/graphql/api/types/**', 'com/commercetools/api/predicates/query/**/*Dsl.java', 'com/commercetools/**/*Impl.java']
addBooleanOption('-allow-script-in-comments', true)
addStringOption('Xdoclint:missing,accessibility,reference', '-quiet')
// addBooleanOption('linksource', true)
encoding = 'utf-8'
groups = [
"API" : ["com.commercetools.api.*"],
"History" : ["com.commercetools.history.*"],
"Import" : ["com.commercetools.importapi.*"],
"ML" : ["com.commercetools.ml.*"],
"Base Packages": ["io.vrap.rmf.base.*"],
"HTTP Clients" : [
"com.commercetools.http.*",
"io.vrap.rmf.okhttp.*"
],
"Monitoring" : ["com.commercetools.monitoring.*"]
]
addStringOption('source', '8')
}
doLast {
copy {
from "src/main/javadoc/resources"
into "${buildDir}/docs/javadoc/resources"
}
}
}
tasks.register("writeVersionToReadme") {
doLast {
ant.replaceregexp(match: 'commercetools: \"[^\\s]+\"', replace: "commercetools: \"${globalVersion}\"", flags:'g', byline:true) {
fileset(dir: projectDir, includes: 'README.md')
}
ant.replaceregexp(match: '<commercetools.version>.+</commercetools.version>', replace: "<commercetools.version>${globalVersion}</commercetools.version>", flags:'g', byline:true) {
fileset(dir: projectDir, includes: 'README.md')
}
}
}
tasks.register("writeVersionToExamples") {
doLast {
ant.replaceregexp(match: 'commercetools: \"[^\\s]+\"', replace: "commercetools: \"${globalVersion}\"", flags:'g', byline:true) {
fileset(dir: projectDir) {
include(name: 'examples/spring/build.gradle')
include(name: 'examples/spring-newrelic/build.gradle')
include(name: 'examples/spring-otel/build.gradle')
include(name: 'examples/spring-datadog/build.gradle')
include(name: 'examples/spring-datadog-statsd/build.gradle')
include(name: 'examples/spring-dynatrace-oneagent/build.gradle')
}
}
ant.replaceregexp(match: '<commercetools.version>.+</commercetools.version>', replace: "<commercetools.version>${globalVersion}</commercetools.version>", flags:'g', byline:true) {
fileset(dir: projectDir) {
include(name: 'examples/maven-okhttp3/pom.xml')
include(name: 'examples/maven-okhttp4/pom.xml')
}
}
}
}