Gradle 渐变复制任务不工作

Gradle 渐变复制任务不工作,gradle,Gradle,我正在尝试将我的JavaFX构建从Maven转换为Gradle。我需要做的一件事是将我的文件从非标准位置复制到我的javafx gradle插件可以使用的位置 出于某种原因,gradle没有复制文件,但我没有收到任何错误 这是我的任务: task copyRequiredRuntimeConfiguration(type: Copy) { logger.error('***************************************************Source Fol

我正在尝试将我的JavaFX构建从Maven转换为Gradle。我需要做的一件事是将我的文件从非标准位置复制到我的javafx gradle插件可以使用的位置

出于某种原因,gradle没有复制文件,但我没有收到任何错误

这是我的任务:

task copyRequiredRuntimeConfiguration(type: Copy) {
    logger.error('***************************************************Source Folder is')
    FileTree tree = fileTree(dir: 'properties')
    tree.each {File file ->
        println file
    }

    from 'properties'
    into '{project.buildDir}/additionalResources/properties'
    include '**/*.*'

    logger.error('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Destination Folder is')
    FileTree tree2 = fileTree(dir: '{project.buildDir}/additionalResources/properties')
    tree2.each {File file ->
        println file
    }
}
我得到的结果是:

***************************************************Source Folder is
C:\workspace\GRADLE-POC\master-module\app\properties\log4j.xml
C:\workspace\GRADLE-POC\master-module\app\properties\server.properties
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Destination Folder is
:javafx-framework:compileJava
由于某些原因,复制从未发生,文件夹也未创建。我已经尝试先创建目录(创建了结构),但是复制到该位置也不起作用


我对gradle真的很陌生,所以这可能真的很容易——我似乎无法确定问题所在。但是,我可以看到源目标的列表。

我认为您唯一的问题是语法问题,只需将脚本中的大括号和单引号替换为美元符号和双引号,使脚本看起来像这样

task copyRequiredRuntimeConfiguration(type: Copy) {
logger.error('***************************************************Source Folder is')
FileTree tree = fileTree(dir: 'properties')
tree.each {File file ->
    println file
}

from 'properties'
into "$projectDir/additionalResources/properties"
include '**/*.*'

logger.error('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Destination Folder is')
FileTree tree2 = fileTree(dir: "$projectDir/additionalResources/properties")
tree2.each {File file ->
    println file
 }
}

它会成功的

感谢您的建议,但不幸的是,这没有帮助。通过导航到应该复制文件的文件夹,您是否检查过该文件夹不存在,也不存在文件?我已检查过-结果表明,我没有正确定义依赖项。我现在可以用了。谢谢。我需要添加一个依赖项来运行我的任务,但是我不能像上面那样使用动态路径。我只需要使用build/否则gradle会创建$buildDir这样的文件夹/