MissingPropertyException using expand on processResources

while trying to use

configure(tasks.processResources) {
    include '**/*.properties'
    expand(basedir: projectDir)   

to replace occurences of ${basedir} in my property files I get a

Caused by: org.gradle.api.GradleException: Could not copy file ‘/Users/markus/src/sample/src/main/resources/logging.properties’ to ‘/Users/markus/src/sample/build/resources/main/logging.properties’.
Caused by: groovy.lang.MissingPropertyException: No such property: tb for class: SimpleTemplateScript2

Both running Gradle 2.3 with Java 7 and Java 8.

Any hints how to get around this? :slight_smile:


1 Like

What else is in your logging.properties file? It looks like there’s something that looks like a variable reference (maybe $tb).

1 Like

wow, thanks a lot, that’s the reason for the exeption.

using exclude '**/logging.properties' brings it to work, unfortunately it also excludes logging.properties from being copied to the build dir.
do you have a hint for me how I can just exclude it from the “expand” ?

thanks a lot for the fast reply!

You could do something like this with filesNotMatching http://gradle.org/docs/current/javadoc/org/gradle/api/file/CopySpec.html

processResources {
   include "**/*.properties"

   filesNotMatching("**/logging.properties") { fcd ->
      fcd.expand(baseDir: projectDir)

filesMatching might be easier if you have something other than properties that you’re copying too. You could then check for fcd.name != ‘logging.properties’ instead.

thanks a lot, that worked like a charm! :grinning: :thumbsup: :clap: