java - 如何提供一些从 maven 到 Google Compile-Testing 的库
问题描述
我正在使用 Google Compile-Testing 和 JUnit 为我的注释处理器编写测试。
如何提供一些存在于 maven 的库(例如,"somegroup:somelib:1.0"
)来编译?
Compilation compilation = Compiler.javac().withProcessors(new MyProcessor())
.withClasspath(???) //What's there to use?
.compile(
JavaFileObjects.forResource("path/to/SomeClass.java")
...
);
解决方案
它可以通过使用withClasspathFrom
for provide 来测试编译测试本身可用的所有类来实现:
Compilation compilation = Compiler.javac().withProcessors(new MyProcessor())
.withClasspathFrom(this.getClass().getClassLoader())
.compile(
JavaFileObjects.forResource("path/to/SomeClass.java")
推荐阅读
- javascript - Atom 获取光标下的文本
- spring-boot - 避免向 InfluxDB 发送零值
- c# - 删除了设计器脚本中的重要行
- ruby - gem 'autoprefixer-rails' 不会将 -ms- 前缀添加到 css
- r - 应用于列表中的 unionSpatialPolygons
- azure-cosmosdb - cosmosdb sql api vs mongodb api 哪一个用于我的场景。
- vue.js - 将 html 添加到 Vue 组件模板会破坏它
- python - 在 Pandas 中读取 CSV 文件,中间有空行
- amazon-web-services - ansible ec2_instance_facts 按“tag:Name”过滤不按实例名称过滤
- android - 如何从 Android 应用打开推文页面?