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

Cannot get property 'absolutePath' on null object #303

Open
fcc10267091 opened this issue Nov 22, 2022 · 1 comment
Open

Cannot get property 'absolutePath' on null object #303

fcc10267091 opened this issue Nov 22, 2022 · 1 comment

Comments

@fcc10267091
Copy link

fcc10267091 commented Nov 22, 2022

jvmArgs "-javaagent:${classpath.find { it.name.contains("testable-agent") }.absolutePath}"

gradle 引包,编译提示
Cannot get property 'absolutePath' on null object

@linfan
Copy link
Collaborator

linfan commented Nov 24, 2022

和操作系统关系不大,但可能和Gradle版本以及使用的依赖声明方式有关。

这个报错的直接原因是在当前编译上下文的Classpath里找不到Testable的依赖包,首先请确保在依赖声明的地方已经通过testImplementation()声明添加了Testable的依赖,如果依然不行,最好能提供一个最小可复现问题的完整Demo,便于再进一步排查原因。

另外,我在StackOverflow上找到了一个可以参考的帖子:
https://stackoverflow.com/questions/63044549/gradle-switching-to-implementation-testimplementation-causing-errors-when-acces

具体方法是将 "-javaagent:${classpath.find { it.name.contains("testable-agent") }.absolutePath}" 替换为 "-javaagent:${configurations.testCompileClasspath.get().files.filter { it.name.contains("jmockit") }[0].absolutePath}",不妨一试。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants