Unable to use regex in copy task

When I try to execute a copy task using regex, the task fails with the below mentioned exception. When ever I use ‘*’ in my file paths in from / include / into statements, the script fails with the same exception.

Is there any import statement or dependency that I need to use ?

task copyPropertiesFile ( type : Copy )



into(‘build/resources/main/org/hello/’) }

  • Exception is: org.gradle.api.UncheckedIOException: Could not normalize path for file ‘D:\tools\gradle-.6\samples\java\qucikstart_regex\src\main\java\org\hello*.properties’.

at org.gradle.api.internal.file.AbstractFileResolver.normalise(AbstractF ileResolver.java:134)

at org.gradle.api.internal.file.AbstractFileResolver.resolve(AbstractFil eResolver.java:75)

at org.gradle.api.internal.file.AbstractFileResolver.resolve(AbstractFil eResolver.java:56)

You can’t use wildcards in ‘from’, but only in ‘include’ or ‘exclude’. For example:

from('src/main/java/org/hello') {
    include '*.properties'

About your question:

A regex expression in the from statement is not supported by gradle.

Instead you can use includes/excludes for that

task copyPropertiesFile (type: Copy ){
  include '**/*.properties'