$ svn info Revision: 32
$ svn info ./src/ru/bsrgin/myproject/MyActivity.java Revision: 45 $ svn -r 32 -v log Changed paths: D /some-folder $ svn -r 45 -v log Changed paths: M /src/ru/bsrgin/myproject/MyActivity.java
4123:4168 mixed revision working copy 4168M modified working copy 4123S switched working copy 4123P partial working copy, from a sparse checkout 4123:4168MS mixed revision, modified, switched working copy
$ svnversion 32:46
$ svnversion 32:46M
<project default="svn-revision"> <target name="svn-revision"> <!-- `svnversion -n` , . : 4123:4168 mixed revision working copy 4168M modified working copy 4123S switched working copy 4123P partial working copy, from a sparse checkout 4123:4168MS mixed revision, modified, switched working copy --> <exec executable="svnversion" output="svnversion.output"> <arg line="-n"/> </exec> <loadresource property="svnversion.Revision"> <file file="svnversion.output"/> </loadresource> <echo>Revision: ${svnversion.Revision}</echo> <!-- Manifest VersionName --> <replaceregexp file="AndroidManifest.xml" match='android:versionName="([^".]+\.[^".]+)(\.[^"]*)?"' replace='android:versionName="\1.${svnversion.Revision}"' /> <!-- --> <delete file="svnversion.output"/> </target> </project>
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType"> <booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/> <booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/> <booleanAttribute key="org.eclipse.debug.core.ATTR_REFRESH_RECURSIVE" value="false"/> <stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> <listEntry value="${project_loc}/svn-revision.build.xml"/> </listAttribute> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> <listEntry value="1"/> </listAttribute> <booleanAttribute key="org.eclipse.debug.core.capture_output" value="false"/> <booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="false"/> <booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/> <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/> <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="ANDROID-APP"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${project_loc}/svn-revision.build.xml"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/> <booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> </launchConfiguration>
<buildCommand> <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> <triggers>full,incremental,</triggers> <arguments> <dictionary> <key>LaunchConfigHandle</key> <value><project>/.externalToolBuilders/AddSvnRevisionToVersion.launch</value> </dictionary> </arguments> </buildCommand>
<project default="git-revision"> <target name="git-revision"> <!-- 'git describe' , . . http://habrahabr.ru/blogs/android_development/132017/#comment_4385225 --> <exec executable="git" output="gitdescribe.output"> <arg line="describe --always --dirty=+ --abbrev=5"/> </exec> <loadresource property="git.Revision"> <file file="gitdescribe.output"/> </loadresource> <echo>Revision: ${git.Revision}</echo> <!-- Manifest VersionName --> <replaceregexp file="AndroidManifest.xml" match='android:versionName="([^".]+\.[^".]+)(\.[^"]*)?"' replace='android:versionName="\1.${git.Revision}"' /> <!-- --> <delete file="gitdescribe.output"/> </target> </project>
public static getApplicationVersion() { try { return getInstance().getApplicationContext().getPackageManager() .getPackageInfo(getPackageName(), 0).versionName; } catch (NameNotFoundException e) { return "App not installed!"; } }
Source: https://habr.com/ru/post/132017/
All Articles