5

I am using gradle Java plugin. I see that gradle does not copy hidden (starting with .) files from test/resources directory to build/resources/test directory. Ant has an option to use defaultExcludes = 'no' to force copy of all files. How do I do that with gradle?

codefx
  • 9,872
  • 16
  • 53
  • 81
  • Can't reproduce it. Here: https://github.com/Opalo/stackoverflow/tree/master/29504250, `.lol` is copied. – Opal Apr 08 '15 at 06:06
  • I put the file inside src/test/resources/testdata/.lol . Does that work for you? – codefx Apr 09 '15 at 08:02
  • Will try in a moment. – Opal Apr 09 '15 at 08:06
  • Yes, it works. I've updated it on GH. – Opal Apr 09 '15 at 08:09
  • Thanks a lot for replying so quickly. I see that you have a Copy task. I am sing `gradle build` with java plugin. Is the `processResources` also a Copy task? – codefx Apr 09 '15 at 08:13
  • Yes, it extends copy: https://github.com/gradle/gradle/blob/eb4d045f12dab4fa12a7da7ee99b6a70fe024a66/subprojects/language-jvm/src/main/java/org/gradle/language/jvm/tasks/ProcessResources.java – Opal Apr 09 '15 at 09:33
  • One file the Copy task seems to always ignore is a ".gitignore" file. In your test @Opal, if you throw a ".gitignore" file in your src, it doesn't get copied while the ".lol" file does – Veaviticus Sep 16 '15 at 19:23
  • Actually, any recognized ".git*" files get ignored. I wonder if this has to do with Windows recognizing them due to having Git installed. Windows sees them as "text" files instead of "no type" files – Veaviticus Sep 16 '15 at 19:29
  • 1
    This is due to gradle using Ant's default Exclude patterns. This can be disabled on a per-task basis: https://issues.gradle.org/browse/GRADLE-1883 – Veaviticus Sep 17 '15 at 13:42
  • Sorry @Veaviticus, I've just returned from holidays. Have you worked it out? – Opal Sep 21 '15 at 09:25
  • @Opal, yes I have. See my above comment. It was due to Gradle using Ant's default exclude patterns for copying files – Veaviticus Sep 21 '15 at 21:02

1 Answers1

5

It is not an issue with every hidden resource file but only the ones present here are excluded by default.

You can do the following:

org.apache.tools.ant.DirectoryScanner.removeDefaultExclude("**/.gitignore")

For more details, refer this Gradle issue

Paras Narang
  • 621
  • 1
  • 8
  • 20