Skip to content

Commit

Permalink
Remove ClassLoaderCache
Browse files Browse the repository at this point in the history
  • Loading branch information
3flex committed Oct 4, 2021
1 parent da743dd commit 194abe3
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 183 deletions.

This file was deleted.

@@ -1,7 +1,5 @@
package io.gitlab.arturbosch.detekt.invoke

import io.gitlab.arturbosch.detekt.internal.ClassLoaderCache
import io.gitlab.arturbosch.detekt.internal.GlobalClassLoaderCache
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.file.ConfigurableFileCollection
Expand All @@ -10,8 +8,6 @@ import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.Property
import org.gradle.workers.WorkAction
import org.gradle.workers.WorkParameters
import java.io.PrintStream
import java.lang.reflect.InvocationTargetException

internal interface DetektInvoker {

Expand All @@ -21,16 +17,6 @@ internal interface DetektInvoker {
taskName: String,
ignoreFailures: Boolean = false
)

companion object {

fun create(isDryRun: Boolean): DetektInvoker =
if (isDryRun) {
DryRunInvoker()
} else {
DefaultCliInvoker()
}
}
}

private const val DRY_RUN_PROPERTY = "detekt-dry-run"
Expand Down Expand Up @@ -80,39 +66,6 @@ abstract class DetektWorkAction : WorkAction<DetektWorkParameters> {
msg != null && "Build failed with" in msg && "issues" in msg
}

internal class DefaultCliInvoker(
private val classLoaderCache: ClassLoaderCache = GlobalClassLoaderCache
) : DetektInvoker {

override fun invokeCli(
arguments: List<String>,
classpath: FileCollection,
taskName: String,
ignoreFailures: Boolean
) {
try {
val loader = classLoaderCache.getOrCreate(classpath)
val clazz = loader.loadClass("io.gitlab.arturbosch.detekt.cli.Main")
val runner = clazz.getMethod(
"buildRunner",
Array<String>::class.java,
PrintStream::class.java,
PrintStream::class.java
).invoke(null, arguments.toTypedArray(), System.out, System.err)
runner::class.java.getMethod("execute").invoke(runner)
} catch (reflectionWrapper: InvocationTargetException) {
val message = reflectionWrapper.targetException.message
if (message != null && isBuildFailure(message) && ignoreFailures) {
return
}
throw GradleException(message ?: "There was a problem running detekt.", reflectionWrapper)
}
}

private fun isBuildFailure(msg: String?) =
msg != null && "Build failed with" in msg && "issues" in msg
}

private class DryRunInvoker : DetektInvoker {

override fun invokeCli(
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 194abe3

Please sign in to comment.