Copy task doesn't copy files starting with a dot


(BrainStone) #1

Hi. I’m trying to copy some git files that start with a dot (like .gitignore) with a copy task.
But they get simply ignored. I’m trying like this:

task copyTemplateFiles(type: Copy, dependsOn: initGradle) {
    from (projectDir) {
        include ".gitattributes"
        include ".gitignore"
    }
    
    from "template"
    
    into destiontionDir
}

And also like this:

task copyTemplateFiles(type: Copy, dependsOn: initGradle) {
    from (projectDir) {
        include "**/*.gitattributes"
        include "**/*.gitignore"
    }
    
    from "template"
    
    into destiontionDir
}

But nothing works


(James Justinic) #2

The underlying Ant class that the Gradle Copy task delegates to has default excludes. It’s not every hidden file, but the ones that Ant expected were probably present incidentally, not part of the source of your project that you actually want to work with. See this Gradle issue for some comments on working around it: https://issues.gradle.org/plugins/servlet/mobile#issue/GRADLE-1883


(BrainStone) #3

Thank you a lot! The first comment as a decent solution.