Skip to content

Commit

Permalink
Disable Gradle Doctor task monitoring by default
Browse files Browse the repository at this point in the history
  • Loading branch information
osipxd committed Nov 21, 2024
1 parent dcb48b5 commit c8e582d
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ ktlint_standard_comment-wrapping = disabled
[*.kts]
# Always use wildcard imports in scripts
ij_kotlin_name_count_to_use_star_import = 2

[*.properties]
ij_properties_keep_blank_lines = true
14 changes: 5 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

import org.jetbrains.dokka.gradle.*
import org.jetbrains.kotlin.gradle.dsl.*
import org.jetbrains.kotlin.gradle.tasks.*
import org.jetbrains.kotlin.konan.target.*
import org.jetbrains.dokka.gradle.DokkaMultiModuleTask
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
import org.jetbrains.kotlin.konan.target.HostManager

val releaseVersion: String? by extra
val eapVersion: String? by extra
Expand Down Expand Up @@ -56,11 +56,7 @@ apply(from = "gradle/compatibility.gradle")
plugins {
alias(libs.plugins.dokka) apply false
alias(libs.plugins.binaryCompatibilityValidator)
alias(libs.plugins.doctor)
}

doctor {
enableTestCaching = false
conventions.gradleDoctor
}

subprojects {
Expand Down
1 change: 1 addition & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies {

implementation(libs.kotlinter)
implementation(libs.develocity)
implementation(libs.gradleDoctor)

implementation(libs.ktor.server.default.headers)
implementation(libs.ktor.server.netty)
Expand Down
29 changes: 29 additions & 0 deletions buildSrc/src/main/kotlin/conventions.gradleDoctor.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

import org.gradle.api.services.internal.RegisteredBuildServiceProvider

plugins {
id("com.osacky.doctor")
}

doctor {
enableTestCaching = false
}

// Always monitor tasks on CI, but disable it locally by default with providing an option to opt-in.
// See 'doctor.enableTaskMonitoring' in gradle.properties for details.
val enableTasksMonitoring = CI ||
properties.getOrDefault("doctor.enableTaskMonitoring", "false").toString().toBoolean()

if (!enableTasksMonitoring) {
logger.info("Gradle Doctor task monitoring is disabled.")
gradle.sharedServices.unregister("listener-service")
}

fun BuildServiceRegistry.unregister(name: String) {
val registration = registrations.getByName(name)
registrations.remove(registration)
(registration.service as RegisteredBuildServiceProvider<*, *>).maybeStop()
}
11 changes: 8 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ kotlin.code.style=official
# config
version=3.0.2-SNAPSHOT

## JVM arguments
#
## Performance

# JVM arguments used to run Gradle Daemon.
# Notes:
# * You can reduce '-Xmx' downto '6g' or even '4g', but this could lead to OOM on project sync in an IDE
# while it might be enough for other tasks.
Expand All @@ -29,9 +30,13 @@ version=3.0.2-SNAPSHOT
# * '-Dkotlin.daemon.options=autoshutdownIdleSeconds=30'
# To save some memory, shutting down Kotlin Daemon used for buildSrc compilation after 30 seconds of idle.
# See: https://github.com/gradle/gradle/issues/29331
#
org.gradle.jvmargs=-Xms2g -Xmx8g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options=-Xmx512m,Xms256m,-XX:MaxMetaspaceSize=256m,XX:+HeapDumpOnOutOfMemoryError
kotlin.daemon.jvmargs=-Xms512m -Xmx2g -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError
# Gradle Doctor might increase memory consumption when task monitoring is enabled, so it is disabled by default.
# Some features can't work without task monitoring:
# doctor-negative-savings, doctor-slow-build-cache-connection, doctor-slow-maven-connection
# Issue: https://github.com/runningcode/gradle-doctor/issues/348
doctor.enableTaskMonitoring=false

# gradle
org.gradle.daemon=true
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ kotlinx-io-core = { module = "org.jetbrains.kotlinx:kotlinx-io-core", version.re

kotlinx-browser = { module = "org.jetbrains.kotlinx:kotlinx-browser", version.ref = "kotlinx-browser" }

kotlinter = { module = "org.jmailen.gradle:kotlinter-gradle", version.ref = "ktlint" }

dokka-plugin-versioning = { module = "org.jetbrains.dokka:versioning-plugin", version.ref = "dokka" }

netty-handler = { module = "io.netty:netty-handler", version.ref = "netty" }
Expand Down Expand Up @@ -229,6 +227,8 @@ tomlj = { module = "org.tomlj:tomlj", version.ref = "tomlj" }

develocity = { module = "com.gradle:develocity-gradle-plugin", version.ref = "develocity" }
develocity-commonCustomUserData = { module = "com.gradle:common-custom-user-data-gradle-plugin", version.ref = "develocity-commonCustomUserData" }
kotlinter = { module = "org.jmailen.gradle:kotlinter-gradle", version.ref = "ktlint" }
gradleDoctor = { module = "com.osacky.doctor:doctor-plugin", version.ref = "gradleDoctor" }

[plugins]

Expand Down

0 comments on commit c8e582d

Please sign in to comment.