위해 나는 ANT 멍청한 놈은 내가 내 안드로이드 프로젝트를 위해이 작은 수수께끼를 해결할 수있는 온라인 찾기 위해 애 쓰고 있어요. 내가하고 싶은 무엇실행 관세 규칙은 특정 대상
내가 실행 어떤 개미 명령에 따라 몇 가지 규칙을 실행됩니다. 기본적으로 ANT DEBUG를 실행하면 사용자 지정 규칙을 실행하고 싶지 않습니다. ANT RELEASE를 실행하면 사용자 정의 규칙을 실행하고 싶습니다. 순간
내 사용자 정의 규칙은 사전 빌드 단계에 상관없이 실행할 수 없습니다.여기에 여기에 내가 그것을 해결했습니다 좋아 내 custom_rules.xml
<project>
<macrodef name="git" description="run a git command">
<attribute name="command" />
<attribute name="dir" default="" />
<element name="args" optional="true" />
<element name="gitOutputRedirector" optional="true"/>
<sequential>
<echo message="git @{command}" />
<exec executable="git" dir="@{dir}">
<arg value="@{command}" />
<args/>
<gitOutputRedirector/>
</exec>
</sequential>
</macrodef>
<target name="-pre-build" depends="set-version-using-file,git-last-commit-hash-rev-parse" >
</target>
<target name="set-version-using-file">
<!-- Load properties from "version.properties" file -->
<property file="version.properties" />
<replaceregexp file="AndroidManifest.xml" match="android:versionCode(.*)"
replace='android:versionCode="${Version.Code}"'/>
<replaceregexp file="AndroidManifest.xml" match='android:versionName="\d+\.+\d+\.+\d+\.+\d"'
replace='android:versionName="${Version.Name}"'/>
<echo message="Set android:versionCode as ${Version.Code}" />
<echo message="Set android:versionName as ${Version.Name}" />
</target>
<!-- Get the last commit -->
<target name="git-last-commit-hash-rev-parse" description="Commits all changes to version git" >
<property file="version.properties" />
<git command="rev-parse" >
<args>
<arg value="HEAD" />
</args>
<gitOutputRedirector>
<redirector outputproperty="git.last.commit"/>
</gitOutputRedirector>
</git>
<echo message="Last commit found was ${git.last.commit}" />
<echo message="Will now tag ${git.last.commit} with ${Version.Name}" />
<git command="tag">
<args>
<!-- This tags the last commit with the full version name -->
<arg value="${Version.Name}" />
<!-- For some reason why it doesn't like this command through ant.-->
<!-- <arg value="${Version.Name} ${git.last.commit} -m 'Tagged for build'" /> -->
</args>
</git>
</target>
</project>