Change lines of code within files with Apache Ant

Asked

Viewed 93 times

4

I’m studying Apache Ant to try to change some existing lines of code within files, but so far I haven’t found anything about it in the official documentation the most I can do is rename files like this example

<move todir="my/src/dir" includeemptydirs="false">
<fileset dir="my/src/dir"/>
<mapper type="glob" from="*.default.properties" to="*.local.properties"/>

I wanted to know if you’ve been through it and how can I fix it.

1 answer

4


You can use other OS executable resources and generate one task.

In your case, you could create a ant task using sed.

Another option is the replaceregexp

Example:

<replaceregexp byline="true">
  <regexp pattern="OldProperty=(.*)"/>
  <substitution expression="NewProperty=\1"/>
  <fileset dir=".">
    <include name="*.properties"/>
  </fileset>
</replaceregexp>
  • was just what I needed, using oldproperty and new Property to perfectly reslver my problem.

  • Great. I think this question needs better tags, so I started another question on Meta, at http://meta.pt.stackoverflow.com/questions/1784/qual-a-tag-appropriatedpara-uma-related questions-a-tasks-ants

  • I tried to put it to you but I don’t have a reputation for it yet.

  • 1

    Now it looks good. D

Browser other questions tagged

You are not signed in. Login or sign up in order to post.