我有一个接受字符串和闭包的方法,我将它们包含在我的插件约定中:
def someMethod( String obj, Closure closure) {
println('HERE I AM')
confFileTree = project.fileTree( obj, closure )
}在Junit测试中,我是这样命名的:
project.convention.plugins.license.licenseFiles( 'src') {
include "main/java/**"
include "main/resources/*.properties"
exclude "**/Licensed.java"
}我知道这个方法之所以被调用,是因为打印了'HERE i AM‘。但是随后我得到了一个错误,它说:
org.gradle.api.internal.MissingMethodException:
Could not find method fileTree() for arguments
[src, nl.javadude.gradle.plugins.license.tasks.LicenseTaskTest$_shouldScanFilesForLicenseWithExclude_closure1@3cbdb6ae]
on root project 'test'.我应该说明的是,这段代码最初只是调用了fileTree的闭包形式,在闭包中使用了"from 'src'“,它工作得很好,但是Gradle Milestal8告诉我它是一个被弃用的方法。
发布于 2012-02-21 10:28:08
您确定测试是针对m8运行的吗?无论如何,这里有一些改进的建议(因为我已经知道你想要实现什么了):
FileTree.matching(Closure)方法将其应用于源目录集(例如sourceSets.main.java)。您将得到一个应用了过滤器的新文件树。project.licenseFiles(...) {...}.https://stackoverflow.com/questions/9371082
复制相似问题