ant regex for android package names

放肆的年华 提交于 2019-12-05 16:43:02

You need to group old package name chars before .R

if you know package name

    match="import com\.mysite\.myapp\.R;"

if you do now know package name, but be prepared to be failed for wrong imports if you import R from different packages

    match="import (.*).R;"

replace to

replace="import ${current.package}.R;"

and the

    <fileset dir="src">
        <include name="**/*.java"/>
    </fileset>
<replaceregexp
   match="import .+?\.R;"
   replace="import ${current.package}.R;"
   flags="g"
> 
...

where +? is needed so that it works if you have two imports in a line, and g needed so not only one import per file is replaced. Although currently you only have one per file since you replace all of them with the same string, this is the universally correct regexp...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!