作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想创建gradle插件,它将添加类型为 JavaExec 的其他任务
我有插件:
class CustomPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.task('generate', type: JavaExec) {
main = 'some.package.ClassWithMainInTestScope'
args = ['some', 'arguments']
classpath project.sourceSets.test.runtimeClasspath
}
}
}
FAILURE: Build failed with an exception.
* Where:
Build file '/home/pompei/IdeaProjects/greetgo.depinject/greetgo.depinject.gradle/build/test_projects/pr-20180720-164840-381-109260619/test/build.gradle' line: 3
* What went wrong:
An exception occurred applying plugin request [id: 'kz.greetgo.depinject.plugin']
> Failed to apply plugin [id 'kz.greetgo.depinject.plugin']
> Could not get unknown property 'sourceSets' for root project 'test' of type org.gradle.api.Project.
最佳答案
尝试一下:
final JavaPluginConvention javaPlugin = getProject().getConvention().getPlugin(JavaPluginConvention.class);
final SourceSetContainer sourceSets = javaPlugin.getSourceSets();
final SourceSet smoketest = sourceSets.findByName("smoketest");
this.testClasspath = smoketest.getRuntimeClasspath();
关于gradle - 如何在自定义gradle插件中获取project.sourceSets.test.runtimeClasspath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51441115/
我是一名优秀的程序员,十分优秀!