1

我真的可以在这方面使用一些帮助!

gradle 文档说要使最新的逻辑起作用,只需执行以下操作:

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

我尝试了几件事,其中有两条注释掉的行。由于这些不起作用,我意识到我并没有真正的线索并且可以使用一些帮助!提前致谢!

4

1 回答 1

0

根据我的经验,Eclipse 任务不应该每次都重新运行。这让我觉得你正在做一些事情来改变输入或输出。如果您在 Gradle 生成之后修改 Eclipse 项目或更改依赖项等,您自然会触发 upToDate 检查。

如果您确实需要每次都强制它运行,那么您也许可以让它与它一起工作。我不确定在已经定义了其他输出的情况下是否尝试过使用它。

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
}
于 2012-08-23T22:37:02.967 回答