purring pigeon
purring pigeon

Reputation: 4209

Gradle copy task not working

I am attempting to convert my JavaFX build from Maven to Gradle. One thing that I need to do is copy my files from a non standard location to one that my javafx-gradle-plugin can use.

For some reason, gradle isn't copying the files, but I am not getting any errors.

This is my task:

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
    }
}

The output I am getting is:

***************************************************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

For some reason the copy is never occurring and the folder isn't being created. I have tried creating the directory first (which created the structure) but the copy into that location didn't work either.

I am really new to gradle, so this might be really easy - I just can't seem to determine the issue. However I can see the listing of the source destination.

Upvotes: 1

Views: 3523

Answers (1)

Johan Duke
Johan Duke

Reputation: 209

I think your only problem is a syntax one, just replace the curly braces and the single quotes in your script, with a dollar sign and double quotes so your script will look like this.

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
 }
}

It will work!

Upvotes: 2

Related Questions