Gradle-如何在预定义任务上设置最新参数?
我真的需要一些帮助 gradle文档说,要使最新逻辑发挥作用,只需执行以下操作:Gradle-如何在预定义任务上设置最新参数?,gradle,Gradle,我真的需要一些帮助 gradle文档说,要使最新逻辑发挥作用,只需执行以下操作: task transform { ext.srcFile = file('mountains.xml') ext.destDir = new File(buildDir, 'generated') inputs.file srcFile outputs.dir destDir 对于您定义的任务来说,这一切都很好。但是,我正在使用eclipse插件对.classpath文件进行一些修
task transform {
ext.srcFile = file('mountains.xml')
ext.destDir = new File(buildDir, 'generated')
inputs.file srcFile
outputs.dir destDir
对于您定义的任务来说,这一切都很好。但是,我正在使用eclipse插件对.classpath文件进行一些修改。最新版本不起作用。也就是说,它一次又一次地开箱即用地运行任务(至少对我来说是这样)。以下是我所拥有的:
eclipse {
classpath {
//eclipseClasspath.inputs.file // something like this??? but what to set it to?
//eclipseClasspath.outputs.file // here too
file {
withXml {
def node = it.asNode()
// rest of my stuff here
我尝试了两种方法,其中两行被注释掉了。由于这些都不起作用,我意识到我真的没有线索,需要一些帮助!提前谢谢 根据我的经验,Eclipse任务不应该每次都重新运行。这让我觉得你在做一些事情,导致输入或输出发生变化。如果您在Gradle生成Eclipse项目或更改依赖项之后修改它,那么您自然会触发最新的检查 如果您真的需要每次都强制它运行,那么您可能可以让它使用此功能。我不确定我是否曾经尝试过在其他输出已经定义的情况下使用它
eclipseClasspath {
outputs.upToDateWhen { true } //there isn't an equivalent for inputs
}
一个重要的注意事项是,您使用的是描述项目的Eclipse模型,而不是实际任务本身:
eclipse { //this is the eclipse model
classpath {
}
}
eclipseClasspath {
//this is a task
}
eclipseProject {
//this is a task
}
当我说它在上面一遍又一遍地运行时,这可能是误导。我的意思是,如果我直接从命令行反复运行“EclipsPath”任务,通过:gradle EclipsPath,我永远不会得到“最新的”。相反,它会重新运行任务。我所要做的只是确保'src/main/generated'被添加为classpathentry,但我希望它是自动的,而不是用户需要做和/或知道的事情。