Advertisement
Guest User

Untitled

a guest
Aug 7th, 2015
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 16.16 KB | None | 0 0
  1. <!--
  2.     Crashlytics ant targets for Android
  3.  
  4.     *****
  5.  
  6.     If you use the build targets supplied by Android, see crashlytics_build.xml.
  7.  
  8.     *****
  9.     Features:
  10.     - Adds required Crashlytics Build ID in a string resource file res/values/
  11.  
  12.     - Automatically uploads ProGuard deobfuscation (aka mapping) files to Crashlytics servers, which
  13.       enables viewing of deobfuscated stack traces on crashlytics.com with no manual action required.
  14.  
  15.  
  16.     How to use:
  17.     - Add the following line to your ant build script, replacing CRASHLYTICS_HOME with the
  18.       absolute or relative path to this build file:
  19.  
  20.         <import file="CRASHLYTICS_HOME/crashlytics_build_base.xml"/>
  21.  
  22.     - Add the "crashlytics-pre-build" target to the depends list of your build task to ensure cached
  23.       deobfuscation files that failed to upload on previous attempts are uploaded to Crashlytics.
  24.  
  25.     - Add the "crashlytics-code-gen" target to the start of the depends list for your Android resource
  26.          generation task to autogenerate Crashlytics-required resources for your app.
  27.  
  28.     - Add the "crashlytics-post-package" target to the depends list for your post-package task to
  29.       upload your ProGuard mappings file and clean up the Crashlytics-generated resources.
  30.  
  31.     - The project root directory is assumed to be colocated with build.xml. You can optionally specify
  32.       an alternate paths to the project root, AndroidManifest.xml, and res directories by declaring:
  33.  
  34.         <property name="crashlytics.project.path" location="PROJECT.ROOT"/>
  35.         <property name="crashlytics.manifest.path" location="MANIFEST.PARENT/AndroidManifest.xml"/>
  36.         <property name="crashlytics.res.path" location="RES.PARENT/res"/>
  37.  
  38.     - If the ProGuard mapping file is NOT written the standard location (proguard/mapping.txt),
  39.       this line is also required:
  40.  
  41.         <property name="crashlytics.obfuscate.mapping.file" location="YOUR_MAPPING_FILE"/>
  42.  
  43.     - If you are using an obfuscator other than ProGuard, please contact support@crashlytics.com
  44.  
  45. -->
  46.  
  47. <project name="crashlytics_targets_base">
  48.     <dirname property="crashlytics.home" file="${ant.file.crashlytics_targets_base}"/>
  49.     <property name="crashlytics.devtools.jar" location="${crashlytics.home}/crashlytics-devtools.jar" />
  50.     <property name="tool.name" value="com.crashlytics.tools.ant" />
  51.     <property name="tool.version" value="1.20.0" />
  52.    
  53.     <target name="crashlytics-pre-build" depends="crashlytics-cleanup-resources"
  54.         description="Crashlytics target to be invoked prior to building any Android artifacts. Cleans up stale Crashlytics resource files and attempts to upload any cached deobfuscation files" >
  55.         <!-- always attempt to upload any cached files. -->
  56.         <antcall target="crashlytics-upload-deobs" />
  57.     </target>
  58.  
  59.     <target name="crashlytics-code-gen" depends="crashlytics-generate-resources"
  60.         description="Crashlytics target to be invoked prior to compiling Android artifacts. Generates Crashlytics-required resources." />
  61.  
  62.     <target name="crashlytics-post-package" depends="crashlytics-store-deobs, crashlytics-upload-deobs"
  63.         description="Crashlytics target to be invoked after the packaging task is complete. Cleans up Crashlytics-generated resource files. Caches and uploads deobfuscation files to Crashlytics servers." >
  64.         <!-- must be invoked via antcall rather than as a dependency because it was already called once. -->
  65.         <antcall target="crashlytics-cleanup-resources" />
  66.     </target>
  67.  
  68.     <target name="crashlytics-upload-distribution" depends="crashlytics-init" description="Uploads the newly-built package as a new beta distribution.">
  69.         <property file="${fabric.properties.path}"/>
  70.  
  71.         <if>
  72.             <condition>
  73.                 <not><isset property="apiSecret" /></not>
  74.             </condition>
  75.             <then>
  76.                 <fail message="API Secret is not set. Make sure fabric.properties file exists." />
  77.             </then>
  78.         </if>
  79.  
  80.         <if>
  81.             <condition>
  82.                 <not><isset property="out.final.file" /></not>
  83.             </condition>
  84.             <then>
  85.                 <echo>Distribution file not specified.</echo>
  86.                 <echo></echo>
  87.                 <echo>'ant crashlytics-upload-distribution' requires the build target to be specified as well.</echo>
  88.                 <echo></echo>
  89.                 <echo></echo>
  90.                 <echo>    ant debug crashlytics-upload-distribution</echo>
  91.                 <echo>    ant release crashlytics-upload-distribution</echo>
  92.                 <echo>This will build the given package and upload it.</echo>
  93.                 <fail />
  94.             </then>
  95.         </if>
  96.  
  97.         <if>
  98.             <condition>
  99.                 <not><resourceexists><file file="${out.final.file}"/></resourceexists></not>
  100.             </condition>
  101.             <then>
  102.                 <fail message="File ${out.final.file} does not exist." />
  103.             </then>
  104.         </if>
  105.  
  106.         <echo level="info">Uploading ${out.final.file} to Crashlytics...</echo>
  107.         <java jar="${crashlytics.devtools.jar}" fork="true" failonerror="true" spawn="false">
  108.             <arg value="-projectPath"/>
  109.             <arg path="${crashlytics.project.path}"/>
  110.             <arg value="-androidManifest"/>
  111.             <arg path="${crashlytics.manifest.path}"/>
  112.             <arg value="-androidRes"/>
  113.             <arg path="${crashlytics.res.path}"/>
  114.             <arg value="-androidAssets"/>
  115.             <arg path="${crashlytics.assets.path}"/>
  116.             <arg value="-uploadDist" />
  117.             <arg path="${out.final.file}" />
  118.             <arg value="-betaDistributionEmails" />
  119.             <arg value="${betaDistributionEmails}" />
  120.             <arg value="-betaDistributionGroupAliases" />
  121.             <arg value="${betaDistributionGroupAliases}" />
  122.             <arg value="-betaDistributionReleaseNotes" />
  123.             <arg value="${betaDistributionReleaseNotes}" />
  124.             <arg value="-betaDistributionEmailsFilePath" />
  125.             <arg value="${betaDistributionEmailsFilePath}" />
  126.             <arg value="-betaDistributionGroupAliasesFilePath" />
  127.             <arg value="${betaDistributionGroupAliasesFilePath}" />
  128.             <arg value="-betaDistributionReleaseNotesFilePath" />
  129.             <arg value="${betaDistributionReleaseNotesFilePath}" />
  130.             <arg value="-betaDistributionNotifications" />
  131.             <arg value="${betaDistributionNotifications}" />
  132.             <arg value="${crashlytics.verbose}"/>
  133.             <arg value="-properties" />
  134.             <arg value="${fabric.properties.path}" />
  135.         </java>
  136.     </target>
  137.  
  138. <!-- You should not need to explicitly invoke tasks below this comment! -->
  139.  
  140.     <target name="crashlytics-generate-resources" depends="crashlytics-init">
  141.         <java jar="${crashlytics.devtools.jar}" fork="true" failonerror="true">
  142.  
  143.             <arg value="-projectPath"/>
  144.             <arg path="${crashlytics.project.path}"/>
  145.             <arg value="-androidManifest"/>
  146.             <arg path="${crashlytics.manifest.path}"/>
  147.             <arg value="-androidRes"/>
  148.             <arg path="${crashlytics.res.path}"/>
  149.             <arg value="-androidAssets"/>
  150.             <arg path="${crashlytics.assets.path}"/>
  151.             <arg value="-generateResourceFile"/>
  152.             <arg value="${crashlytics.verbose}"/>
  153.             <arg value="-properties" />
  154.             <arg value="${fabric.properties.path}" />
  155.             <arg value="-buildEvent"/>
  156.             <arg value="-tool"/>
  157.             <arg value="${tool.name}"/>
  158.             <arg value="-version"/>
  159.             <arg value="${tool.version}"/>
  160.         </java>
  161.     </target>
  162.  
  163.     <target name="crashlytics-cleanup-resources" depends="crashlytics-init">
  164.         <java jar="${crashlytics.devtools.jar}" fork="true" failonerror="true">
  165.  
  166.             <arg value="-projectPath"/>
  167.             <arg path="${crashlytics.project.path}"/>
  168.             <arg value="-androidManifest"/>
  169.             <arg path="${crashlytics.manifest.path}"/>
  170.             <arg value="-androidRes"/>
  171.             <arg path="${crashlytics.res.path}"/>
  172.             <arg value="-androidAssets"/>
  173.             <arg path="${crashlytics.assets.path}"/>
  174.             <arg value="-cleanupResourceFile"/>
  175.             <arg value="${crashlytics.verbose}"/>
  176.             <arg value="-properties" />
  177.             <arg value="${fabric.properties.path}" />
  178.         </java>
  179.     </target>
  180.  
  181.     <target name="crashlytics-store-deobs" depends="crashlytics-init">
  182.         <property name="mapping.absolute" location="${crashlytics.obfuscate.mapping.file}"/>
  183.         <property name="crashlytics.obfuscator.id" value="proguard" />
  184.         <property name="crashlytics.obfuscator.version" value="4.7" />
  185.         <if condition="${proguard.enabled}">
  186.             <then>
  187.                 <java jar="${crashlytics.devtools.jar}" fork="true" failonerror="true" spawn="false">
  188.                     <arg value="-projectPath"/>
  189.                     <arg path="${crashlytics.project.path}"/>
  190.                     <arg value="-androidManifest"/>
  191.                     <arg path="${crashlytics.manifest.path}"/>
  192.                     <arg value="-androidRes"/>
  193.                     <arg path="${crashlytics.res.path}"/>
  194.                     <arg value="-androidAssets"/>
  195.                     <arg path="${crashlytics.assets.path}"/>
  196.                     <arg value="-storeDeobs" />
  197.                     <arg file="${mapping.absolute}" />
  198.                     <arg value="-obfuscating" />
  199.                     <arg value="-obfuscator" />
  200.                     <arg value="${crashlytics.obfuscator.id}" />
  201.                     <arg value="-obVer" />
  202.                     <arg value="${crashlytics.obfuscator.version}" />
  203.                     <arg value="${crashlytics.verbose}"/>
  204.                     <arg value="-properties" />
  205.                     <arg value="${fabric.properties.path}" />
  206.                 </java>
  207.             </then>
  208.         </if>
  209.     </target>
  210.  
  211.     <target name="crashlytics-upload-deobs" depends="crashlytics-init" description="Uploads stored deobfuscation files to Crashlytics.">
  212.         <java jar="${crashlytics.devtools.jar}" fork="true" failonerror="true" spawn="false">
  213.             <arg value="-projectPath"/>
  214.             <arg path="${crashlytics.project.path}"/>
  215.             <arg value="-androidManifest"/>
  216.             <arg path="${crashlytics.manifest.path}"/>
  217.             <arg value="-androidRes"/>
  218.             <arg path="${crashlytics.res.path}"/>
  219.             <arg value="-androidAssets"/>
  220.             <arg path="${crashlytics.assets.path}"/>
  221.             <arg value="-uploadDeobs" />
  222.             <arg value="${crashlytics.verbose}"/>
  223.             <arg value="-properties" />
  224.             <arg value="${fabric.properties.path}" />
  225.         </java>
  226.     </target>
  227.  
  228.     <target name="crashlytics-symbols" depends="crashlytics-generate-symbols,crashlytics-upload-symbols" description="Generate and upload NDK symbol files to Crashlytics. Interested in this feature? Contact support@crashlytics.com">
  229.     </target>
  230.  
  231.     <target name="crashlytics-update-dependencies" depends="crashlytics-init" description="Retrieve necessary artifacts from a remote repository">
  232.             <java jar="${crashlytics.devtools.jar}" fork="true" failonerror="true" spawn="false">
  233.                 <arg value="-properties"/>
  234.             <arg value="${fabric.properties.path}"/>
  235.             <arg value="-resolveDependencies"/>
  236.         </java>
  237.     </target>
  238.  
  239.     <target name="crashlytics-updates" depends="crashlytics-init" description="Check whether new versions of the specified artifacts exist">
  240.             <java jar="${crashlytics.devtools.jar}" fork="true" failonerror="true" spawn="false">
  241.                 <arg value="-properties"/>
  242.             <arg value="${fabric.properties.path}"/>
  243.             <arg value="-checkForUpdates"/>
  244.         </java>
  245.     </target>
  246.  
  247.     <target name="crashlytics-generate-symbols" depends="crashlytics-init" description="Generates Crashlytics symbol files from NDK shared libraries. Interested in this feature? Contact support@crashlytics.com">
  248.         <java jar="${crashlytics.devtools.jar}" fork="true" failonerror="true" spawn="false">
  249.             <arg value="-projectPath"/>
  250.             <arg path="${crashlytics.project.path}"/>
  251.             <arg value="-androidManifest"/>
  252.             <arg path="${crashlytics.manifest.path}"/>
  253.             <arg value="-androidRes"/>
  254.             <arg path="${crashlytics.res.path}/.."/>
  255.             <arg value="-androidAssets"/>
  256.             <arg path="${crashlytics.assets.path}"/>
  257.             <arg value="${crashlytics.verbose}"/>
  258.             <arg value="-properties" />
  259.             <arg value="${fabric.properties.path}" />
  260.             <arg value="-generateCSyms"/>
  261.             <arg value="-cSymGen"/>
  262.             <arg value="${fabric.build.output.path}/csyms"/>
  263.         </java>
  264.     </target>
  265.  
  266.     <target name="crashlytics-cache-symbols" depends="crashlytics-init" description="Caches generated Crashlytics symbol files for upload. Interested in this feature? Contact support@crashlytics.com">
  267.         <java jar="${crashlytics.devtools.jar}" fork="true" failonerror="true" spawn="false">
  268.             <arg value="-projectPath"/>
  269.             <arg path="${crashlytics.project.path}"/>
  270.             <arg value="-androidManifest"/>
  271.             <arg path="${crashlytics.manifest.path}"/>
  272.             <arg value="-androidRes"/>
  273.             <arg path="${crashlytics.res.path}/.."/>
  274.             <arg value="-androidAssets"/>
  275.             <arg path="${crashlytics.assets.path}"/>
  276.             <arg value="${crashlytics.verbose}"/>
  277.             <arg value="-properties" />
  278.             <arg value="${fabric.properties.path}" />
  279.             <arg value="-cacheCSyms"/>
  280.             <arg value="-cSymGen"/>
  281.             <arg value="${fabric.build.output.path}/csyms"/>
  282.         </java>
  283.     </target>
  284.  
  285.     <target name="crashlytics-upload-symbols" depends="crashlytics-init,crashlytics-cache-symbols" description="Uploads cached Crashlytics symbol files to Crashlytics. Interested in this feature? Contact support@crashlytics.com">
  286.         <java jar="${crashlytics.devtools.jar}" fork="true" failonerror="true" spawn="false">
  287.             <arg value="-projectPath"/>
  288.             <arg path="${crashlytics.project.path}"/>
  289.             <arg value="-androidManifest"/>
  290.             <arg path="${crashlytics.manifest.path}"/>
  291.             <arg value="-androidRes"/>
  292.             <arg path="${crashlytics.res.path}/.."/>
  293.             <arg value="-androidAssets"/>
  294.             <arg path="${crashlytics.assets.path}"/>
  295.             <arg value="${crashlytics.verbose}"/>
  296.             <arg value="-properties" />
  297.             <arg value="${fabric.properties.path}" />
  298.             <arg value="-uploadCSyms"/>
  299.         </java>
  300.     </target>
  301.  
  302.     <target name="crashlytics-init" description="Set up internal properties used by Crashlytics ant tasks.">
  303.         <!-- Stock android build scripts assume the PWD is the project location. -->
  304.         <property name="crashlytics.project.path" location="."/>
  305.  
  306.         <!-- Use fabric.properties unless crashlytics.properties is the only properties file available -->
  307.         <if>
  308.             <condition>
  309.                 <or>
  310.                     <available file="${crashlytics.project.path}/fabric.properties"/>
  311.                     <not>
  312.                         <available file="${crashlytics.project.path}/crashlytics.properties"/>
  313.                     </not>
  314.                 </or>
  315.             </condition>
  316.             <then>
  317.                 <property name="fabric.properties.path" location="${crashlytics.project.path}/fabric.properties"/>
  318.             </then>
  319.             <else>
  320.                 <property name="fabric.properties.path" location="${crashlytics.project.path}/crashlytics.properties"/>
  321.             </else>
  322.         </if>
  323.  
  324.         <property name="crashlytics.manifest.path" location="${crashlytics.project.path}/AndroidManifest.xml"/>
  325.         <property name="crashlytics.res.path" location="${crashlytics.project.path}/res"/>
  326.         <property name="crashlytics.assets.path" location="${crashlytics.project.path}/assets"/>
  327.         <!-- This does nothing if the property is already set, because Ant props are immutable: -->
  328.         <!-- out.absolute.dir is defined by standard Android build script. -->
  329.         <property name="crashlytics.obfuscate.mapping.file" location="${out.absolute.dir}/proguard/mapping.txt"/>
  330.         <property name="fabric.build.output.path" location="${out.absolute.dir}/fabric"/>
  331.         <!-- Uncomment for verbose output to STDOUT by the Crashlytics Tools
  332.              or set value to "-quiet" for no STDOUT logging. -->
  333.         <!-- <property name="crashlytics.verbose" value="-verbose"/> -->
  334.         <property name="betaDistributionEmails" value=""/>
  335.         <property name="betaDistributionGroupAliases" value=""/>
  336.         <property name="betaDistributionReleaseNotes" value=""/>
  337.         <property name="betaDistributionEmailsFilePath" value=""/>
  338.         <property name="betaDistributionGroupAliasesFilePath" value=""/>
  339.         <property name="betaDistributionReleaseNotesFilePath" value=""/>
  340.         <property name="betaDistributionNotifications" value=""/>
  341.     </target>
  342.  
  343.     <target name="ant-version-check">
  344.         <fail>
  345.             <condition>
  346.             <not>
  347.                 <antversion atleast="1.8.4" />
  348.             </not>
  349.         </condition>
  350.         Looks like you're using an older version of Ant than we support. Please upgrade to at least 1.8.4 and try again!
  351.         </fail>
  352.     </target>
  353.  
  354.     <target name="crashlytics-get-credentials" depends="ant-version-check">
  355.         <echo>Please enter your Fabric Credentials:</echo>
  356.         <input message="email: " addproperty="fabric.email"/>
  357.         <input message="password: " addproperty="fabric.password">
  358.             <handler type="secure"/>
  359.         </input>
  360.     </target>
  361.  
  362.     <target name="crashlytics-onboard" depends="crashlytics-init,crashlytics-get-credentials" description="Onboard a new app">
  363.         <java jar="${crashlytics.devtools.jar}" fork="true" failonerror="true" spawn="false">
  364.             <arg value="-onboard"/>
  365.             <arg value="-fabricEmail"/>
  366.             <arg value="${fabric.email}"/>
  367.             <arg value="-fabricPassword"/>
  368.             <arg value="${fabric.password}"/>
  369.             <arg value="-androidRes"/>
  370.             <arg value="${crashlytics.res.path}"/>
  371.             <arg value="-androidManifest"/>
  372.             <arg value="${crashlytics.manifest.path}"/>
  373.         </java>
  374.         <antcall target="crashlytics-update-dependencies" />
  375.     </target>
  376. </project>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement