Skip to content

Commit

Permalink
Revert looking for a specific file that's in the correct folder, beca…
Browse files Browse the repository at this point in the history
…use it's not scalable. Satisfy the assumption that the the `/` resource on the classpath points to the current module's test sourceSet.
  • Loading branch information
TWiStErRob committed Nov 19, 2023
1 parent ba150db commit 68352ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 7 additions & 1 deletion detekt-formatting/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ plugins {

val extraDepsToPackage: Configuration by configurations.creating
val testRuntimeOnlyPriority: Configuration = configurations.resolvable("testRuntimeOnlyPriority").get()
sourceSets.test.configure { runtimeClasspath = testRuntimeOnlyPriority + runtimeClasspath }
sourceSets.test.configure {
val moduleSources = runtimeClasspath.filter { it.isDirectory }
val moduleDependencies = runtimeClasspath.filter { !it.isDirectory }
// Inject the priority dependencies between the compiled classes and the dependencies,
// so that KtTestCompiler.root resolves correctly.
runtimeClasspath = moduleSources + testRuntimeOnlyPriority + moduleDependencies
}

dependencies {
compileOnly(projects.detektApi)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ internal object KtTestCompiler : KtCompiler() {
* are JAR files, which leads to crashes. By initializing the root on demand, it's at least possible to
* use String based input from Bazel.
*/
private val root: Path by lazy {
// STOPSHIP TestClass::class.java.protectionDomain.codeSource.location.toPath()
resourceAsPath("/META-INF/detekt-formatting_test.kotlin_module").parent.parent
}
private val root: Path by lazy { resourceAsPath("/") }

fun compile(path: Path) = compile(root, path)

Expand Down

0 comments on commit 68352ce

Please sign in to comment.