Repository navigation
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
96 lines (84 loc) · 3.47 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
96 lines (84 loc) · 3.47 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
import java.net.URI
plugins {
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
id("com.datadoghq.native-root")
}
// Compute version from git tags at configuration time.
// See doc/Versioning/TagBasedVersioning.md for the version computation rules.
// Priority: -Pddprof_version > compute-version.sh > fallback.
// -Pddprof_version is always set by GitLab CI (publish builds).
// compute-version.sh is used for local builds and GHA CI with full history.
// The fallback handles environments with no git tags (CodeQL autobuild).
val ddprofVersion = findProperty("ddprof_version") as? String
version = ddprofVersion ?: run {
try {
providers.exec {
commandLine(rootProject.layout.projectDirectory.file("utils/compute-version.sh").asFile.absolutePath)
}.standardOutput.asText.get().trim()
} catch (e: Exception) {
logger.warn("compute-version.sh failed; falling back to 0.0.0-SNAPSHOT. Set -Pddprof_version to override.")
"0.0.0-SNAPSHOT"
}
}
allprojects {
repositories {
mavenCentral()
gradlePluginPortal()
}
}
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
maven {
content {
includeGroup("com.datadoghq")
}
mavenContent {
snapshotsOnly()
}
// see https://central.sonatype.org/publish/publish-portal-snapshots/#consuming-via-gradle
url = URI("https://central.sonatype.com/repository/maven-snapshots/")
}
}
allprojects {
group = "com.datadoghq"
// Apply spotless formatting convention to all projects
apply(plugin = "com.datadoghq.spotless-convention")
}
subprojects {
version = rootProject.version
}
val isCI = hasProperty("CI") || System.getenv("CI")?.toBoolean() ?: false
nexusPublishing {
repositories {
val forceLocal = hasProperty("forceLocal")
if (forceLocal && !isCI) {
create("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.set(URI("http://localhost:8081/nexus/content/repositories/releases/"))
snapshotRepositoryUrl.set(URI("http://localhost:8081/nexus/content/repositories/snapshots/"))
username.set("admin")
password.set("admin123")
}
} 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
create("sonatype") {
// see https://central.sonatype.org/publish/publish-portal-ossrh-staging-api/#configuration
// see https://github.com/gradle-nexus/publish-plugin#publishing-to-maven-central-via-sonatype-central
// Also for official doc
// 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
nexusUrl.set(URI("https://ossrh-staging-api.central.sonatype.com/service/local/"))
snapshotRepositoryUrl.set(URI("https://central.sonatype.com/repository/maven-snapshots/"))
username.set(System.getenv("SONATYPE_USERNAME"))
password.set(System.getenv("SONATYPE_PASSWORD"))
}
}
}
}