Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Gradle version locking #7239

Merged
merged 2 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .circleci/config.continue.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ jobs:
- run:
name: Build Project
command: >-
{% if is_nightly %}
./gradlew resolveAndLockAll --write-locks
{% endif %}
MAVEN_OPTS="-Xms64M -Xmx256M"
GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx2560M -Xms2560M -XX:ErrorFile=/tmp/hs_err_pid%p.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'"
./gradlew clean
Expand Down
28 changes: 2 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ buildscript {
}

plugins {
id "datadog.dependency-locking"

id "com.diffplug.spotless" version "6.13.0"
id 'com.github.spotbugs' version '5.0.14'
id "de.thetaphi.forbiddenapis" version "3.5.1"
Expand Down Expand Up @@ -192,32 +194,6 @@ def testAggregate(String baseTaskName, includePrefixes, excludePrefixes, boolean
createRootTask "${baseTaskName}Check", 'check'
}

// To lock dependency versions, run `./gradlew resolveAndLockAll --write-locks`
tasks.register('resolveAndLockAll') {
notCompatibleWithConfigurationCache("Filters configurations at execution time")
doFirst {
assert gradle.startParameter.writeDependencyLocks
}
doLast {
allprojects { project ->
project.configurations.findAll {
it.canBeResolved && !it.name.startsWith('incrementalScalaAnalysis')
}.each { it.resolve() }
}
}
}

allprojects { project ->
project.dependencyLocking {
lockAllConfigurations()
//lockmode set to LENIENT because there are resolution
//errors in the build with an apiguardian dependency.
//See: https://docs.gradle.org/current/userguide/dependency_locking.html for more info
lockMode = LockMode.LENIENT

}
}

testAggregate("smoke", [":dd-smoke-tests"], [])
testAggregate("instrumentation", [":dd-java-agent:instrumentation"], [])
testAggregate("profiling", [":dd-java-agent:agent-profiling"], [])
Expand Down
32 changes: 32 additions & 0 deletions buildSrc/src/main/kotlin/datadog.dependency-locking.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* This plugin enables dependency locking.
*
* The goal is to be able to later rebuild any version, by pinning floating versions.
* It will also help IDEs not having to re-index any latest library release.
* Pinned versions will be updated by the CI on a weekly basis.
*
* Pinned version can be updated using: ./gradlew resolveAndLockAll --write-locks
*
* See https://docs.gradle.org/current/userguide/dependency_locking.html
*/

project.dependencyLocking {
lockAllConfigurations()
//lockmode set to LENIENT because there are resolution
//errors in the build with an apiguardian dependency.
//See: https://docs.gradle.org/current/userguide/dependency_locking.html for more info
lockMode = LockMode.LENIENT
}

tasks.register("resolveAndLockAll") {
notCompatibleWithConfigurationCache("Filters configurations at execution time")
doFirst {
require(gradle.startParameter.isWriteDependencyLocks)
}
doLast {
configurations.filter {
// Add any custom filtering on the configurations to be resolved
it.isCanBeResolved
}.forEach { it.resolve() }
}
}
2 changes: 2 additions & 0 deletions gradle/java.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
apply plugin: 'datadog.dependency-locking'

apply from: "$rootDir/gradle/java_deps.gradle"
apply from: "$rootDir/gradle/java_no_deps.gradle"
Loading