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

Break a dependency between detekt-gradle-plugin and detekt-utils #4748

Merged
merged 1 commit into from Apr 23, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion detekt-gradle-plugin/build.gradle.kts
Expand Up @@ -66,7 +66,6 @@ configurations.compileOnly { extendsFrom(pluginCompileOnly) }
dependencies {
compileOnly(libs.kotlin.gradlePluginApi)
implementation(libs.sarif4k)
implementation(projects.detektUtils)

// Migrate to `implementation(testFixtures(project))` in test suite configuration when Gradle 7.5 released
// (https://github.com/gradle/gradle/pull/19472)
Expand Down
@@ -1,6 +1,5 @@
package io.gitlab.arturbosch.detekt.extensions

import io.github.detekt.utils.openSafeStream
import org.gradle.api.Action
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.model.ObjectFactory
Expand Down Expand Up @@ -109,6 +108,16 @@ open class DetektExtension @Inject constructor(objects: ObjectFactory) : CodeQua
}

internal fun loadDetektVersion(classLoader: ClassLoader): String = Properties().run {
load(classLoader.getResource("versions.properties")!!.openSafeStream())
val inputStream = classLoader.getResource("versions.properties")!!.openConnection()
/*
* Due to https://bugs.openjdk.java.net/browse/JDK-6947916 and https://bugs.openjdk.java.net/browse/JDK-8155607,
* it is necessary to disallow caches to maintain stability on JDK 8 and 11 (and possibly more).
* Otherwise, simultaneous invocations of Detekt in the same VM can fail spuriously. A similar bug is referenced in
* https://github.com/detekt/detekt/issues/3396. The performance regression is likely unnoticeable.
* Due to https://github.com/detekt/detekt/issues/4332 it is included for all JDKs.
*/
.apply { useCaches = false }
.getInputStream()
load(inputStream)
getProperty("detektVersion")
}