ANT read existing MANIFEST version & append to it
ANT read existing MANIFEST version & append to it
银月光海 发表于2年前
ANT read existing MANIFEST version & append to it
  • 发表于 2年前
  • 阅读 18
  • 收藏 1
  • 点赞 1
  • 评论 0

腾讯云 技术升级10大核心产品年终让利>>>   

Thanks All,

FYI this is my final code, tested working

This appends a revision number (4th element) to a version without a revision or replaces the revision for a version that already has one.

<available file="META-INF/MANIFEST.MF" property="has.manifest" />

<target name="loadBundleVersion" if="has.manifest">
    <!-- load version, if no current build number -->
    <loadproperties srcfile="META-INF/MANIFEST.MF">
        <filterchain>
            <linecontainsregexp>
                <regexp pattern="^Bundle-Version: \d*.\d*.\d*\s*$" />
            </linecontainsregexp>
        </filterchain>
    </loadproperties>
</target>

<target name="loadBundleVersionRemoveBuild" unless="Bundle-Version" depends="loadBundleVersion">
    <!-- if version not set here we have a current build number so needs to be stripped -->
    <loadproperties srcfile="META-INF/MANIFEST.MF">
        <filterchain>
            <linecontains>
                <contains value="Bundle-Version" />
            </linecontains>
            <tokenfilter>
                <replaceregex pattern=".\d*$" replace="" />
            </tokenfilter>
        </filterchain>
    </loadproperties>
</target>

<target name="loadBundleDetails" depends="loadBundleVersionRemoveBuild">
    <loadproperties srcfile="META-INF/MANIFEST.MF">
        <filterchain>
            <linecontains>
                <contains value="Bundle-SymbolicName" />
            </linecontains>
        </filterchain>
    </loadproperties>
</target>

<target name="updateManifestVersion" if="has.manifest" depends="loadBundleDetails">
    <manifest file="META-INF/MANIFEST.MF" mode="update">
        <attribute name="Bundle-Version" value="${Bundle-Version}.${build.number}" />
    </manifest>
</target>




共有 人打赏支持
银月光海
粉丝 33
博文 339
码字总数 46223
×
银月光海
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: