Subversion Repositories DevTools

Rev

Rev 1974 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<project>

    <!--
            = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
                macrodef: initivy
                ~~~~~~~~~~~~~~~~~~~~~
                This macrodef takes an ivy dependency template file, and creates 
                a new ivy.xml file that has all the revisions updated with the version 
                numbers from the depends.xml file.         
                = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
         -->
        <macrodef name="initivy">
                <sequential>
                        <available property="ivy.xml.exists" filepath="${basedir}" file="${basedir}/ivy-template.xml" />
                        <available property="depends.xml.exists" filepath="${basedir}" file="${basedir}/${ant.project.name}depends.xml" />
                        <available property="auto.xml.exists" filepath="${basedir}" file="${basedir}/auto.xml" />
                        <if>
                                <and>
                                        <isset property="ivy.xml.exists"/>
                                        <isset property="depends.xml.exists"/>
                                </and>
                                <then>
                                        <if>
                                                <isset property="auto.xml.exists"/>
                                                <then>
                                                        <property name="dependencies.xml" location="${basedir}/auto.xml"/>
                                                </then>
                                                <else>
                                                        <property name="dependencies.xml" location="${basedir}/${ant.project.name}depends.xml"/>
                                                </else>
                                        </if>
                                        
                                        <loadproperties srcFile="${dependencies.xml}">
                                                <filterchain>
                                                        <tokenfilter>
                                                                        <replaceregex 
                                                                                pattern='&lt;project.*&gt;'
                                                            replace=''
                                                            flags="gi" />
                                                        <replaceregex 
                                                            pattern='&lt;property\s+name="packagename"\s+value="(.*)"\s*/&gt;'
                                                    replace=''
                                                    flags="true" />
                                                <replaceregex 
                                                   pattern='&lt;property\s+name="(.*)"\s+value="(.*)"\s*/&gt;'
                                                   replace='\1.rev=\2${line.separator}\1.branch=\2'
                                                   flags="gi" />
                                                                </tokenfilter>
                                                        <expandproperties/>
                                                        <tokenfilter>
                                        <replaceregex 
                                                pattern='(.*).rev=(.*?)\.?+[a-zA-Z]*$'
                                                replace='\1.rev=\2'
                                                flags="gi" />
                                        <replaceregex 
                                                pattern='(.*).branch=.*?([a-zA-Z]*$)'
                                                replace='\1.branch=\2'
                                                flags="gi" />
                                                        </tokenfilter>
                                                </filterchain>
                                        </loadproperties>
                                        
                                        <loadfile property="ivy-template-file" srcFile="${basedir}/ivy-template.xml">
                                                <filterchain>
                                                        <expandproperties />
                                                </filterchain>
                                        </loadfile>
                                        <echo file="${basedir}/ivy.xml">${ivy-template-file}</echo>
                                </then>
                        </if>
                </sequential>
        </macrodef>

</project>