forked from DataDog/dd-trace-java
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
185 lines (158 loc) · 5.56 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
buildscript {
dependencies {
classpath "pl.allegro.tech.build:axion-release-plugin:1.14.4"
}
configurations.all {
resolutionStrategy.dependencySubstitution {
substitute module("com.jcraft:jsch") using module("com.github.mwiede:jsch:0.2.6") because "jcraft jsch has been unmaintained for years."
}
}
}
plugins {
id "com.diffplug.spotless" version "6.11.0"
id 'com.github.spotbugs' version '5.0.14'
id "de.thetaphi.forbiddenapis" version "3.5.1"
id 'pl.allegro.tech.build.axion-release' version '1.14.4'
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
id "com.github.johnrengelman.shadow" version "7.1.2" apply false
id "me.champeau.jmh" version "0.7.0" apply false
id 'org.gradle.playframework' version '0.13' apply false
id 'info.solidsoft.pitest' version '1.9.11' apply false
}
description = 'dd-trace-java'
def isCI = System.getenv("CI") != null
apply from: "$rootDir/gradle/scm.gradle"
spotless {
// only resolve the spotless dependencies once in the build
predeclareDeps()
}
spotlessPredeclare {
// these need to align with the types and versions in gradle/spotless.gradle
java {
// This is the last Google Java Format version that supports Java 8
googleJavaFormat('1.7')
}
groovyGradle {
greclipse()
}
groovy {
greclipse()
}
kotlinGradle {
ktlint('0.41.0')
}
kotlin {
ktlint('0.41.0')
}
scala {
scalafmt('2.7.5')
}
}
apply from: "$rootDir/gradle/spotless.gradle"
def compileTask = tasks.register("compile")
allprojects {
group = 'com.datadoghq'
version = scmVersion.version
if (isCI) {
buildDir = "$rootDir/workspace/${projectDir.path.replace(rootDir.path, '')}/build/"
}
apply from: "$rootDir/gradle/dependencies.gradle"
apply from: "$rootDir/gradle/util.gradle"
compileTask.configure {
dependsOn tasks.withType(AbstractCompile)
}
}
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
}
tasks.register("latestDepTest")
nexusPublishing {
repositories {
def forceLocal = project.hasProperty('forceLocal') && forceLocal
if (forceLocal && !isCI) {
local {
// For testing use with https://hub.docker.com/r/sonatype/nexus
// docker run --rm -d -p 8081:8081 --name nexus sonatype/nexus
// Doesn't work for testing releases though... (due to staging)
nexusUrl = uri("http://localhost:8081/nexus/content/repositories/releases/")
snapshotRepositoryUrl = uri("http://localhost:8081/nexus/content/repositories/snapshots/")
username = "admin"
password = "admin123"
}
} else {
sonatype {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
}
}
wrapper {
distributionType = Wrapper.DistributionType.ALL
}
tasks.register('writeMuzzleTasksToFile') {
doLast {
def muzzleFile = file("${buildDir}/muzzleTasks")
assert muzzleFile.parentFile.mkdirs() || muzzleFile.parentFile.directory
muzzleFile.text = subprojects.findAll { subproject -> subproject.plugins.hasPlugin('muzzle') }
.collect { it.path + ":muzzle" }
.join('\n')
}
}
def writeMainVersionFileTask = tasks.register('writeMainVersionFile') {
def versionFile = file("${rootProject.buildDir}/main.version")
inputs.property "version", scmVersion.version
outputs.file versionFile
doFirst {
assert versionFile.parentFile.mkdirs() || versionFile.parentFile.directory
versionFile.text = "${inputs.properties.version}"
}
}
allprojects {
tasks.withType(JavaForkOptions).configureEach {
maxHeapSize = System.properties["datadog.forkedMaxHeapSize"]
minHeapSize = System.properties["datadog.forkedMinHeapSize"]
jvmArgs "-XX:ErrorFile=/tmp/hs_err_pid%p.log"
jvmArgs "-XX:+HeapDumpOnOutOfMemoryError"
jvmArgs "-XX:HeapDumpPath=/tmp"
}
tasks.withType(PublishToMavenLocal).configureEach {
it.finalizedBy(writeMainVersionFileTask)
}
}
allprojects { project ->
project.ext {
activePartition = true
}
final boolean shouldUseTaskPartitions = project.rootProject.hasProperty("taskPartitionCount") && project.rootProject.hasProperty("taskPartition")
if (shouldUseTaskPartitions) {
final int taskPartitionCount = project.rootProject.property("taskPartitionCount") as int
final int taskPartition = project.rootProject.property("taskPartition") as int
final currentTaskPartition = Math.abs(project.path.hashCode() % taskPartitionCount)
project.setProperty("activePartition", currentTaskPartition == taskPartition)
}
}
def testAggregate(String baseTaskName, includePrefixes, excludePrefixes) {
def createRootTask = { rootTaskName, subProjTaskName ->
tasks.register(rootTaskName) { aggTest ->
subprojects { subproject ->
if (subproject.property("activePartition") && includePrefixes.any { subproject.path.startsWith(it) } && !excludePrefixes.any { subproject.path.startsWith(it) }) {
def testTask = subproject.tasks.findByName(subProjTaskName)
if (testTask != null) {
aggTest.dependsOn(testTask)
}
}
}
}
}
createRootTask "${baseTaskName}Test", 'allTests'
createRootTask "${baseTaskName}LatestDepTest", 'allLatestDepTests'
createRootTask "${baseTaskName}Check", 'check'
}
testAggregate("smoke", [":dd-smoke-tests"], [])
testAggregate("instrumentation", [":dd-java-agent:instrumentation"], [])
testAggregate("profiling", [":dd-java-agent:agent-profiling"], [])
testAggregate("debugger", [":dd-java-agent:agent-debugger"], [])
testAggregate("base", [":"], [":dd-java-agent:instrumentation", ":dd-smoke-tests", ":dd-java-agent:agent-profiling"])