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

Provide the current classpath inside KotlinEnvironmentResolver #5275

Merged
merged 1 commit into from Sep 4, 2022
Merged
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
Expand Up @@ -12,6 +12,7 @@ import org.spekframework.spek2.dsl.Root
import org.spekframework.spek2.lifecycle.CachingMode
import java.io.File
import java.nio.file.Path
import kotlin.script.experimental.jvm.util.classpathFromClassloader

@Deprecated(
"This is specific to Spek and will be removed in a future release. Documentation has been updated to " +
Expand Down Expand Up @@ -48,7 +49,12 @@ internal class KotlinEnvironmentResolver : ParameterResolver {
override fun resolveParameter(parameterContext: ParameterContext, extensionContext: ExtensionContext): Any {
val closeableWrapper = extensionContext.wrapper
?: CloseableWrapper(
createEnvironment(additionalJavaSourceRootPaths = extensionContext.additionalJavaSourcePaths())
createEnvironment(
additionalRootPaths = checkNotNull(
classpathFromClassloader(Thread.currentThread().contextClassLoader)
) { "We should always have a classpath" },
additionalJavaSourceRootPaths = extensionContext.additionalJavaSourcePaths(),
)
).also { extensionContext.wrapper = it }
return closeableWrapper.wrapper.env
}
Expand Down