forked from DataDog/dd-trace-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
139 lines (120 loc) · 4.3 KB
/
build.gradle.kts
File metadata and controls
139 lines (120 loc) · 4.3 KB
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
import com.diffplug.gradle.spotless.SpotlessExtension
plugins {
id("datadog.gradle-debug")
id("datadog.dependency-locking")
id("datadog.tracer-version")
id("datadog.dump-hanged-test")
id("com.diffplug.spotless") version "6.13.0"
id("com.github.spotbugs") version "5.0.14"
id("de.thetaphi.forbiddenapis") version "3.8"
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
id("com.gradleup.shadow") version "8.3.6" apply false
id("me.champeau.jmh") version "0.7.3" apply false
id("org.gradle.playframework") version "0.13" apply false
}
description = "dd-trace-java"
val isCI = providers.environmentVariable("CI")
apply(from = rootDir.resolve("gradle/repositories.gradle"))
spotless {
// only resolve the spotless dependencies once in the build
predeclareDeps()
}
with(extensions["spotlessPredeclare"] as SpotlessExtension) {
// these need to align with the types and versions in gradle/spotless.gradle
java {
removeUnusedImports()
// 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.resolve("gradle/spotless.gradle"))
val compileTask = tasks.register("compile")
allprojects {
group = "com.datadoghq"
if (isCI.isPresent) {
layout.buildDirectory = providers.provider {
val newProjectCIPath = projectDir.path.replace(
rootDir.path,
""
)
rootDir.resolve("workspace/$newProjectCIPath/build/")
}
}
apply(from = rootDir.resolve("gradle/dependencies.gradle"))
apply(from = rootDir.resolve("gradle/util.gradle"))
compileTask.configure {
dependsOn(tasks.withType<AbstractCompile>())
}
tasks.configureEach {
if (this is JavaForkOptions) {
maxHeapSize = System.getProperty("datadog.forkedMaxHeapSize")
minHeapSize = System.getProperty("datadog.forkedMinHeapSize")
jvmArgs(
"-XX:ErrorFile=/tmp/hs_err_pid%p.log",
"-XX:+HeapDumpOnOutOfMemoryError",
"-XX:HeapDumpPath=/tmp"
)
}
}
}
tasks.register("latestDepTest")
nexusPublishing {
repositories {
val forceLocal = providers.gradleProperty("forceLocal").getOrElse("false").toBoolean()
if (forceLocal && !isCI.isPresent) {
// For testing, use with https://hub.docker.com/r/sonatype/nexus
// $ docker run --rm -d -p 8081:8081 --name nexus sonatype/nexus:oss
// $ ./gradlew publishToLocal -PforceLocal=true
// Doesn't work for testing releases though... (due to staging),
// however, it's possible to explore http://localhost:8081/nexus/
register("local") {
nexusUrl = uri("http://localhost:8081/nexus/content/repositories/releases/")
snapshotRepositoryUrl = uri("http://localhost:8081/nexus/content/repositories/snapshots/")
username = "admin"
password = "admin123"
allowInsecureProtocol = true
}
} else {
// see https://github.com/gradle-nexus/publish-plugin#publishing-to-maven-central-via-sonatype-central
// For official documentation:
// staging repo publishing https://central.sonatype.org/publish/publish-portal-ossrh-staging-api/#configuration
// snapshot publishing https://central.sonatype.org/publish/publish-portal-snapshots/#publishing-via-other-methods
sonatype {
nexusUrl = uri("https://ossrh-staging-api.central.sonatype.com/service/local/")
snapshotRepositoryUrl = uri("https://central.sonatype.com/repository/maven-snapshots/")
username = providers.environmentVariable("MAVEN_CENTRAL_USERNAME")
password = providers.environmentVariable("MAVEN_CENTRAL_PASSWORD")
}
}
}
}
val writeMainVersionFileTask = tasks.register("writeMainVersionFile") {
val versionFile = rootProject.layout.buildDirectory.file("main.version")
inputs.property("version", project.version)
outputs.file(versionFile)
doFirst {
require(versionFile.get().asFile.parentFile.mkdirs() || versionFile.get().asFile.parentFile.isDirectory)
versionFile.get().asFile.writeText(project.version.toString())
}
}
allprojects {
tasks.withType<PublishToMavenLocal>().configureEach {
finalizedBy(writeMainVersionFileTask)
}
}
apply(from = "$rootDir/gradle/ci_jobs.gradle")