1

In my Android project I have the following property set in my project.properties file

proguard.config=proguard.cfg

and I need a custom macro that will somehow set and unset this property.

How do I set unset this property using macro and regular expression? two things I am not clear on is how to set this to an empty property value. Would that be just proguard.config= or proguard.config=''

What would be the Macro for doing this?

 <macrodef name="turn-on-proguard">
    <sequential>    
       <replaceregexp file="./project.properties"
                            match='proguard.config="(.*)"'
                            replace='proguard.config=proguard.cfg'
                            byline="false">         
        </replaceregexp>
    </sequential>
</macrodef>



 <macrodef name="turn-off-proguard">
    <sequential>    
       <replaceregexp file="./project.properties"
                            match='proguard.config="(.*)"'
                            replace='proguard.config='
                            byline="false">         
        </replaceregexp>
    </sequential>
</macrodef>

Would this work? Update. turn-proguard-off does nothing.

4

1 回答 1

0

您的解决方案对我来说非常不清楚。你为什么不转义点字符?为什么在正则表达式中使用引号和分组?这是工作脚本:

<macrodef name="turnonproguard">
    <sequential>    
       <replaceregexp file="project.properties"
                match='proguard\.config=.*'
                replace='proguard.config=proguard.cfg'
                byline="false"/>
    </sequential>
</macrodef>

<macrodef name="turnoffproguard">
    <sequential>    
       <replaceregexp file="project.properties"
                match='proguard\.config=.*'
                replace='proguard.config='
                byline="false"/>
    </sequential>
</macrodef>

<target name="on">
    <turnonproguard/>
</target>

<target name="off">
    <turnoffproguard/>
</target>
于 2012-06-09T15:13:27.433 回答