Skip to content

Commit 6329249

Browse files
authored
Merge branch 'master' into alejandro.gonzalez/endpoint-discovery-update
2 parents 7ff0bee + 3a35f77 commit 6329249

File tree

34 files changed

+1157
-947
lines changed

34 files changed

+1157
-947
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ build:
255255
CACHE_TYPE: lib
256256
DEPENDENCY_CACHE_POLICY: pull
257257
script:
258-
- if [ $CI_PIPELINE_SOURCE == "schedule" ] ; then ./gradlew resolveAndLockAll --write-locks; fi
258+
- if [ $CI_PIPELINE_SOURCE == "schedule" ] ; then ./gradlew resolveAndLockAll --write-locks $GRADLE_ARGS; fi
259259
- ./gradlew clean :dd-java-agent:shadowJar :dd-trace-api:jar :dd-trace-ot:shadowJar -PskipTests $GRADLE_ARGS
260260
- echo UPSTREAM_TRACER_VERSION=$(java -jar workspace/dd-java-agent/build/libs/*.jar) >> upstream.env
261261
- echo "BUILD_JOB_NAME=$CI_JOB_NAME" >> build.env

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.3" 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-bootstrap/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ idea {
6363
}
6464

6565
jmh {
66-
jmhVersion = '1.32'
66+
jmhVersion = libs.versions.jmh.get()
6767
duplicateClassesStrategy = DuplicatesStrategy.EXCLUDE
6868
}
6969

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ class GitLabInfo implements CIProviderInfo {
4141
public static final String GITLAB_CI_RUNNER_TAGS = "CI_RUNNER_TAGS";
4242
public static final String GITLAB_PULL_REQUEST_BASE_BRANCH =
4343
"CI_MERGE_REQUEST_TARGET_BRANCH_NAME";
44+
public static final String GITLAB_PULL_REQUEST_BASE_SHA = "CI_MERGE_REQUEST_DIFF_BASE_SHA";
45+
public static final String GITLAB_PULL_REQUEST_BASE_HEAD_SHA =
46+
"CI_MERGE_REQUEST_TARGET_BRANCH_SHA";
4447
public static final String GITLAB_PULL_REQUEST_COMMIT_HEAD_SHA =
4548
"CI_MERGE_REQUEST_SOURCE_BRANCH_SHA";
4649
public static final String GITLAB_PULL_REQUEST_NUMBER = "CI_MERGE_REQUEST_IID";
@@ -88,8 +91,8 @@ public CIInfo buildCIInfo() {
8891
public PullRequestInfo buildPullRequestInfo() {
8992
return new PullRequestInfo(
9093
normalizeBranch(environment.get(GITLAB_PULL_REQUEST_BASE_BRANCH)),
91-
null,
92-
null,
94+
environment.get(GITLAB_PULL_REQUEST_BASE_SHA),
95+
environment.get(GITLAB_PULL_REQUEST_BASE_HEAD_SHA),
9396
new CommitInfo(environment.get(GITLAB_PULL_REQUEST_COMMIT_HEAD_SHA)),
9497
environment.get(GITLAB_PULL_REQUEST_NUMBER));
9598
}

dd-java-agent/agent-ci-visibility/src/test/resources/ci/gitlab.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,8 +1080,10 @@
10801080
"CI_JOB_NAME": "gitlab-job-name",
10811081
"CI_JOB_STAGE": "gitlab-stage-name",
10821082
"CI_JOB_URL": "https://gitlab.com/job",
1083+
"CI_MERGE_REQUEST_DIFF_BASE_SHA": "bf6c156e8c1ec9cf43239162bca38cad22a3f4d2",
10831084
"CI_MERGE_REQUEST_IID": 42,
10841085
"CI_MERGE_REQUEST_TARGET_BRANCH_NAME": "target-branch",
1086+
"CI_MERGE_REQUEST_TARGET_BRANCH_SHA": "eb6dda23983998409db832ad675ec18ec32a8205",
10851087
"CI_PIPELINE_ID": "gitlab-pipeline-id",
10861088
"CI_PIPELINE_IID": "gitlab-pipeline-number",
10871089
"CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234",
@@ -1110,6 +1112,8 @@
11101112
"git.commit.message": "gitlab-git-commit-message",
11111113
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
11121114
"git.pull_request.base_branch": "target-branch",
1115+
"git.pull_request.base_branch_head_sha": "eb6dda23983998409db832ad675ec18ec32a8205",
1116+
"git.pull_request.base_branch_sha": "bf6c156e8c1ec9cf43239162bca38cad22a3f4d2",
11131117
"git.repository_url": "https://gitlab.com/repo/myrepo.git",
11141118
"pr.number": "42"
11151119
}

0 commit comments

Comments
 (0)