我正在尝试在 gradle 函数中使用 ant.uptodate 函数,以检查某些文件是否已更改。
task generateXMLBeans {
ant.uptodate(property: "xsdFileChanges", targetfile: "lib/xmlBeans.jar") {
srcfiles(dir: 'protocol') {
include(name: '*.xsd')
}
}
if(ant.properties.xsdFileChanges == "false") {
ant.taskdef(name: 'xmlbean', classname: 'org.apache.xmlbeans.impl.tool.XMLBean',
classpath: configurations.xmlbeans.asPath)
ant.xmlbean(
javasource: "1.5",
failonerror: "true",
fork: "yes",
memoryMaximumSize: "512M",
memoryInitialSize: "64M",
destfile: "lib/xmlBeans.jar",
classpath: configurations.xmlbeans.asPath){
fileset(dir: 'protocol') {
include(name: '*.xsdconfig')
include(name: 'hmiprotocol.xsd')
}
}
}
}
但变量ant.properties.xsdFileChanges是null。
我试图将该ant.uptodate函数放在一个单独的函数中,结果相同。
当我用--debug函数调用任务时,我可以看到 ant.uptodate 函数正常工作。
14:40:50.947 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:uptodate] hmiprotocol_systemlog.xsd omitted as D:\workspace_201912\ProjectX\lib\xmlBeans.jar is up to date.
14:40:50.948 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:uptodate] hmiprotocol_testdetails.xsd omitted as D:\workspace_201912\ProjectX\lib\xmlBeans.jar is up to date.
有谁知道,我如何才能正确访问 ant 属性?