我正在尝试用ant构建以下内容,但老实说,不知道如何最好地继续:
到目前为止,我可以将正确的文件复制到临时目录,但我需要帮助比较文件名和文件夹名称的部分内容。
答案 0 :(得分:0)
使用它:
<project name="test1" basedir="." default="check_if_new_sdk_needed">
<property file="../local.properties" />
<target name="check_if_new_sdk_needed" depends="check_local_sdk, compute_remote_sdk_properties">
<echo message="Need to grab SDK: ${updateNeeded}" />
<antcall target="process_sdk" />
</target>
<target name="check_local_sdk" depends="local_sdk_found, local_sdk_not_found">
</target>
<target name="local_sdk_found" depends="compute_local_sdk_properties" if="local.sdk.found">
<echo message="Local SDK found" />
<script language="javascript"><![CDATA[
var localVersion = parseInt(project.getProperty('local.sdk.version.number'));
var remoteVersion = parseInt(project.getProperty('remote.sdk.version.number'));
project.setProperty('updateNeeded', remoteVersion > localVersion);
]]></script>
</target>
<target name="local_sdk_not_found" depends="compute_local_sdk_properties" unless="local.sdk.found">
<property name="updateNeeded" value="true" />
<echo message="Need to grab SDK" />
</target>
<target name="compute_local_sdk_properties">
<path id="local_sdk_folder_name">
<dirset dir="${local.sdk.dir}">
<include name="*"/>
</dirset>
</path>
<property name="local.sdk.folder.name" refid="local_sdk_folder_name"/>
<pathconvert property="local.sdk.version.number">
<path path="${local.sdk.folder.name}" />
<chainedmapper>
<flattenmapper />
<mapper type="regexp" from="(.*?)-.*" to="\1" />
</chainedmapper>
</pathconvert>
<condition property="local.sdk.found">
<length string="${local.sdk.version.number}" trim="true" when="greater"
length="0" />
</condition>
</target>
<target name="compute_remote_sdk_properties">
<echo message="renaming ${sdk_folder_name} to ${remote.sdk.file.name}"/>
<pathconvert property="remote.sdk.version.number">
<path path="${remote.sdk.file.name}" />
<chainedmapper>
<flattenmapper />
<mapper type="regexp" from="(.*?)-.*" to="\1" />
</chainedmapper>
</pathconvert>
</target>
</project>