Skip to content

Commit 3b1a643

Browse files
Merge branch 'master' into alexeyk/debug-ci-timeout
2 parents bbe67ef + 6c07df1 commit 3b1a643

File tree

53 files changed

+1206
-815
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1206
-815
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ workflow:
6060
- "11"
6161
- "17"
6262
- "21"
63+
- "25"
6364
- "stable"
6465
- "semeru11"
6566
- "oracle8"

build.gradle

Lines changed: 0 additions & 132 deletions
This file was deleted.

build.gradle.kts

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
import com.diffplug.gradle.spotless.SpotlessExtension
2+
3+
plugins {
4+
id("datadog.gradle-debug")
5+
id("datadog.dependency-locking")
6+
7+
id("com.diffplug.spotless") version "6.13.0"
8+
id("com.github.spotbugs") version "5.0.14"
9+
id("de.thetaphi.forbiddenapis") version "3.8"
10+
11+
id("org.shipkit.shipkit-auto-version") version "2.1.2"
12+
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
13+
14+
id("com.gradleup.shadow") version "8.3.6" apply false
15+
id("me.champeau.jmh") version "0.7.0" apply false
16+
id("org.gradle.playframework") version "0.13" apply false
17+
id("info.solidsoft.pitest") version "1.9.11" apply false
18+
}
19+
20+
description = "dd-trace-java"
21+
22+
val isCI = providers.environmentVariable("CI")
23+
24+
apply(from = rootDir.resolve("gradle/repositories.gradle"))
25+
26+
spotless {
27+
// only resolve the spotless dependencies once in the build
28+
predeclareDeps()
29+
}
30+
31+
with(extensions["spotlessPredeclare"] as SpotlessExtension) {
32+
// these need to align with the types and versions in gradle/spotless.gradle
33+
java {
34+
removeUnusedImports()
35+
36+
// This is the last Google Java Format version that supports Java 8
37+
googleJavaFormat("1.7")
38+
}
39+
groovyGradle {
40+
greclipse()
41+
}
42+
groovy {
43+
greclipse()
44+
}
45+
kotlinGradle {
46+
ktlint("0.41.0")
47+
}
48+
kotlin {
49+
ktlint("0.41.0")
50+
}
51+
scala {
52+
scalafmt("2.7.5")
53+
}
54+
}
55+
apply(from = rootDir.resolve("gradle/spotless.gradle"))
56+
57+
val compileTask = tasks.register("compile")
58+
59+
val repoVersion = version
60+
61+
allprojects {
62+
group = "com.datadoghq"
63+
version = repoVersion
64+
65+
if (isCI.isPresent) {
66+
layout.buildDirectory = providers.provider {
67+
val newProjectCIPath = projectDir.path.replace(
68+
rootDir.path,
69+
""
70+
)
71+
rootDir.resolve("workspace/$newProjectCIPath/build/")
72+
}
73+
}
74+
75+
apply(from = rootDir.resolve("gradle/dependencies.gradle"))
76+
apply(from = rootDir.resolve("gradle/util.gradle"))
77+
78+
compileTask.configure {
79+
dependsOn(tasks.withType<AbstractCompile>())
80+
}
81+
82+
tasks.configureEach {
83+
if (this is JavaForkOptions) {
84+
maxHeapSize = System.getProperty("datadog.forkedMaxHeapSize")
85+
minHeapSize = System.getProperty("datadog.forkedMinHeapSize")
86+
jvmArgs(
87+
"-XX:ErrorFile=/tmp/hs_err_pid%p.log",
88+
"-XX:+HeapDumpOnOutOfMemoryError",
89+
"-XX:HeapDumpPath=/tmp"
90+
)
91+
}
92+
}
93+
}
94+
95+
tasks.register("latestDepTest")
96+
97+
nexusPublishing {
98+
repositories {
99+
val forceLocal = providers.gradleProperty("forceLocal").getOrElse("false").toBoolean()
100+
if (forceLocal && !isCI.isPresent) {
101+
// For testing, use with https://hub.docker.com/r/sonatype/nexus
102+
// $ docker run --rm -d -p 8081:8081 --name nexus sonatype/nexus:oss
103+
// $ ./gradlew publishToLocal -PforceLocal=true
104+
// Doesn't work for testing releases though... (due to staging),
105+
// however, it's possible to explore http://localhost:8081/nexus/
106+
register("local") {
107+
nexusUrl = uri("http://localhost:8081/nexus/content/repositories/releases/")
108+
snapshotRepositoryUrl = uri("http://localhost:8081/nexus/content/repositories/snapshots/")
109+
username = "admin"
110+
password = "admin123"
111+
allowInsecureProtocol = true
112+
}
113+
} else {
114+
// see https://github.com/gradle-nexus/publish-plugin#publishing-to-maven-central-via-sonatype-central
115+
// For official documentation:
116+
// staging repo publishing https://central.sonatype.org/publish/publish-portal-ossrh-staging-api/#configuration
117+
// snapshot publishing https://central.sonatype.org/publish/publish-portal-snapshots/#publishing-via-other-methods
118+
sonatype {
119+
nexusUrl = uri("https://ossrh-staging-api.central.sonatype.com/service/local/")
120+
snapshotRepositoryUrl = uri("https://central.sonatype.com/repository/maven-snapshots/")
121+
username = providers.environmentVariable("MAVEN_CENTRAL_USERNAME")
122+
password = providers.environmentVariable("MAVEN_CENTRAL_PASSWORD")
123+
}
124+
}
125+
}
126+
}
127+
128+
val writeMainVersionFileTask = tasks.register("writeMainVersionFile") {
129+
val versionFile = rootProject.layout.buildDirectory.file("main.version")
130+
inputs.property("version", project.version)
131+
outputs.file(versionFile)
132+
doFirst {
133+
require(versionFile.get().asFile.parentFile.mkdirs() || versionFile.get().asFile.parentFile.isDirectory)
134+
versionFile.get().asFile.writeText(project.version.toString())
135+
}
136+
}
137+
138+
allprojects {
139+
tasks.withType<PublishToMavenLocal>().configureEach {
140+
finalizedBy(writeMainVersionFileTask)
141+
}
142+
}
143+
144+
apply(from = "$rootDir/gradle/ci_jobs.gradle")

buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ dependencies {
4747
implementation("org.ow2.asm", "asm-tree", "9.8")
4848

4949
testImplementation(libs.spock.core)
50-
testImplementation("org.codehaus.groovy", "groovy-all", "3.0.17")
50+
testImplementation(libs.groovy)
5151
}
5252

5353
tasks.compileKotlin {

buildSrc/call-site-instrumentation-plugin/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ dependencies {
3939
testImplementation("net.bytebuddy", "byte-buddy", "1.17.5")
4040
testImplementation(libs.spock.core)
4141
testImplementation("org.objenesis", "objenesis", "3.0.1")
42-
testImplementation("org.codehaus.groovy", "groovy-all", "3.0.17")
42+
testImplementation(libs.groovy)
4343
testImplementation("javax.servlet", "javax.servlet-api", "3.0.1")
4444
testImplementation("com.github.spotbugs", "spotbugs-annotations", "4.2.0")
4545
}

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/CiVisibilityRepoServices.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,15 @@ static PullRequestInfo buildPullRequestInfo(
125125
}
126126

127127
// complete with CI vars if user didn't provide all information
128-
PullRequestInfo ciInfo = PullRequestInfo.merge(userInfo, ciProviderInfo.buildPullRequestInfo());
128+
PullRequestInfo ciInfo =
129+
PullRequestInfo.coalesce(userInfo, ciProviderInfo.buildPullRequestInfo());
129130
String headSha = ciInfo.getHeadCommit().getSha();
130131
if (Strings.isNotBlank(headSha)) {
131132
// if head sha present try to populate author, committer and message info through git client
132133
try {
133134
CommitInfo commitInfo = gitClient.getCommitInfo(headSha, true);
134-
return PullRequestInfo.merge(ciInfo, new PullRequestInfo(null, null, commitInfo, null));
135+
return PullRequestInfo.coalesce(
136+
ciInfo, new PullRequestInfo(null, null, null, commitInfo, null));
135137
} catch (Exception ignored) {
136138
}
137139
}
@@ -145,6 +147,7 @@ private static PullRequestInfo buildUserPullRequestInfo(
145147
new PullRequestInfo(
146148
config.getGitPullRequestBaseBranch(),
147149
config.getGitPullRequestBaseBranchSha(),
150+
null,
148151
new CommitInfo(config.getGitCommitHeadSha()),
149152
null);
150153

@@ -164,10 +167,11 @@ private static PullRequestInfo buildUserPullRequestInfo(
164167
new PullRequestInfo(
165168
null,
166169
mergeBase,
170+
null,
167171
new CommitInfo(environment.get(Constants.DDCI_PULL_REQUEST_SOURCE_SHA)),
168172
null);
169173

170-
return PullRequestInfo.merge(userInfo, ddCiInfo);
174+
return PullRequestInfo.coalesce(userInfo, ddCiInfo);
171175
}
172176

173177
private static String getRepoRoot(CIInfo ciInfo, GitClient.Factory gitClientFactory) {

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/ci/AppVeyorInfo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public PullRequestInfo buildPullRequestInfo() {
9191
return new PullRequestInfo(
9292
normalizeBranch(environment.get(APPVEYOR_REPO_BRANCH)),
9393
null,
94+
null,
9495
new CommitInfo(environment.get(APPVEYOR_PR_HEAD_COMMIT)),
9596
environment.get(APPVEYOR_PR_NUMBER));
9697
} else {

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/ci/AzurePipelinesInfo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public PullRequestInfo buildPullRequestInfo() {
9191
return new PullRequestInfo(
9292
normalizeBranch(environment.get(AZURE_PR_TARGET_BRANCH)),
9393
null,
94+
null,
9495
CommitInfo.NOOP,
9596
environment.get(AZURE_PR_NUMBER));
9697
}

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/ci/BitBucketInfo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public PullRequestInfo buildPullRequestInfo() {
7979
return new PullRequestInfo(
8080
normalizeBranch(environment.get(BITBUCKET_PR_DESTINATION_BRANCH)),
8181
null,
82+
null,
8283
CommitInfo.NOOP,
8384
environment.get(BITBUCKET_PR_NUMBER));
8485
}

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/ci/BitriseInfo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public PullRequestInfo buildPullRequestInfo() {
7676
return new PullRequestInfo(
7777
normalizeBranch(environment.get(BITRISE_GIT_BRANCH_DEST)),
7878
null,
79+
null,
7980
CommitInfo.NOOP,
8081
environment.get(BITRISE_PR_NUMBER));
8182
}

0 commit comments

Comments
 (0)