How can I get ant behavior when extending properties with gradle?

I have an ant project that I am converting to gradle. There is something like this in the ant project:

<copy todir="dest_dir">
  <fileset>
     ...
  </fileset>
  <filterchain>
    <expandproperties/>
  </filterchain>
</copy>

A filter chain extends properties such as ${property}, but ignores dollar signs without braces. I am trying to reproduce this behavior in gradle.

If I expand, as shown below, gradle extends the files like a groovy template that tries to expand dollar signs with curly braces.

copy {
   from 'source_dir'
   into 'dest_dir'
   expand(project.properties)
}

If I am filterwith an ant filter class ExpandProperties, I get a NullPointerException. Is there an easy way to do this I missed?

+5
source share
1 answer

, . ExpandProperties Ant. :

copy {
    from 'source_dir'
    to 'dest_dir'
    filter(org.apache.tools.ant.filters.ExpandProperties, project: ant.antProject)
}

, ${property}, , Ant, .

+6

All Articles