Skip to content
Open
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
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ val compileTask = tasks.register("compile")
allprojects {
group = "com.datadoghq"

apply(plugin = "dd-trace-java.dump-hanged-test")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not fan out plugin application through allprojects

With isolated projects enabled (-Dorg.gradle.unsafe.isolated-projects=true), this fan-out is still cross-project configuration: the root project calls Project.apply on every subproject through allprojects, which Gradle treats as an isolation violation (Gradle docs). This moves the old subprojects(::configure) violation into the build script and still blocks the mode this rework targets; apply the plugin from per-project convention/build logic instead.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true, but we're not there yet (isolated projects). And this shall probably be solved by moving to convention plugins.


normalization {
runtimeClasspath {
// Let's ignore only version files generated by dd-trace-java.version-file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,17 @@ class DumpHangedTestPlugin : Plugin<Project> {
}

override fun apply(project: Project) {
if (project.rootProject != project) {
return
}

val scheduler = project.gradle.sharedServices
.registerIfAbsent("dumpHangedTestScheduler", DumpSchedulerService::class.java)

// Create plugin properties.
val props = project.extensions.create("dumpHangedTest", DumpHangedTestProperties::class.java)
val rootProject = project.rootProject
val props = rootProject.extensions.findByType(DumpHangedTestProperties::class.java)
?: rootProject.extensions.create("dumpHangedTest", DumpHangedTestProperties::class.java)
Comment on lines +59 to +60

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not read the root extension from subprojects

When this plugin is applied to subprojects, those plugin instances read/create an extension on project.rootProject. With isolated projects enabled, Gradle forbids build logic for one project from directly accessing another project's mutable state (Gradle docs), so subproject configuration reports a Project.extensions access violation. Keep the dump offset in project-local providers/extensions or pass it via a shared service instead of reading the root extension from each subproject.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're not targeting isolated project yet, I believe the comment is grounded. And this is not a good practice to configure another project, especially the root project from a sub project.


fun configure(p: Project) {
p.tasks.withType<Test>().configureEach {
doFirst { schedule(this, scheduler, props) }
doLast { cleanup(this) }
}
project.tasks.withType<Test>().configureEach {
doFirst { schedule(this, scheduler, props) }
doLast { cleanup(this) }
}

configure(project)

project.subprojects(::configure)
}

private fun schedule(t: Task, scheduler: Provider<DumpSchedulerService>, props: DumpHangedTestProperties) {
Expand Down
Loading