Revert expand configuration

I am applying a plugin to the java project.

Basically the plugin has following configuration.

  processResources {
    // Do not process banner.txt
    filesMatching('*.yml') {
      expand(project.properties)
    }
  }

There is no easy way to skip this part of processResources configuration. There is no extension in the plugin.

Now I am wondering is there a way that I could overwrite processResources expansion part in my project?
I’m defining following in the project

processResources {
  filesMatching('*.yml') {
    expand([foo:"bar"])
  }
}

While placeholders still get expanded from project.properties, so the expand didn’t overwrite existing expand. And values from the map aren’t even added to the existing properties map. If I have $foo placeholder it will complain that there is missing property for Groovy template expansion.

How can I replace previous expand or overwrite it?
Thanks

Sounds like a very opinionated plugin that you shouldn’t use if you do not agree with its strong opinions.
I don’t think you can remove or overwrite the expansion the plugin is doing.
Each call to filesMatching is added to a queue that are done in order.
So if you escape your $foo using \$foo so that it does not disturb the first expansion pass and comes out as $foo, then your second expansion pass will be done and finally fill in the value for $foo.

Alternatively you would need to add your foo = bar mapping to the project properties so that the plugins expansion pass already has it, for example by setting is as extra property on the project, or by setting it in gradle.properties.

1 Like

Thank you for your insight on this matter :100:

Yes indeed plugin seems to be strongly opinionated regarding those extensions. It’s forcing property expansion in all the yml (suppose Spring configuration files), while this causes a conflict in a my specific use-case.

Will do a PR or a fork of the module and make this part configurable through the plugin extensions.

1 Like