Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Two ways:</p> <ul> <li>Use Maven : Maven is great, and has android build support too. But still with default android structure, everything doesn't works as effortlessly as default Ant builds. I hope in future Google introduces Maven structure. </li> <li>Good old <code>Apache Ant</code>: the default ant build file lies in <code>sdk_path/tools/ant/build.xml</code>, this is imported into project's <code>build xml</code>. Hence custom targets can be added for some additional work. Best place to put them is in a <code>custom_rules.xml</code> file at project root and import in project's <code>build.xml</code>.</li> </ul> <p><code>custom_rules.xml</code>:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;project name="MyProject" default="help"&gt; &lt;!-- IDE produces default jar as: out/production/classes.jar , so we define a custom target to rename the jar, generate and package docs jar along with it --&gt; &lt;target name="package_library" depends="init_pack_lib, check_lib_jar, rename_lib_jar,generate_javadoc"/&gt; &lt;!-- init all properties to use--&gt; &lt;target name="init_pack_lib"&gt; &lt;property name="real.out.dir" value="${basedir}/out/production"/&gt; &lt;property name="lib.gen.jar.file" value="${real.out.dir}/classes.jar"/&gt; &lt;property name="docs.dir" value="${real.out.dir}/Docs"/&gt; &lt;!-- we need to peek into manifest xml file--&gt; &lt;xmlproperty file="${manifest.abs.file}" collapseattributes="true"/&gt; &lt;property name="app.package" value="${manifest.package}"/&gt; &lt;property name="app.dist.name" value="${ant.project.name}_${manifest.android:versionName}"/&gt; &lt;property name="doc.package.names" value="${app.package}.*"/&gt; &lt;/target&gt; &lt;!-- is classes.jar generated ?--&gt; &lt;target name="check_lib_jar"&gt; &lt;available file="${lib.gen.jar.file}" property="lib.jar.found"/&gt; &lt;/target&gt; &lt;!-- if so, give it a better name--&gt; &lt;target name="rename_lib_jar" if="${lib.jar.found}"&gt; &lt;move file="${lib.gen.jar.file}" tofile="${real.out.dir}/${app.dist.name}.jar"/&gt; &lt;/target&gt; &lt;!-- generate and package JavaDoc for project--&gt; &lt;target name="generate_javadoc" depends="check_doc_dir, create_doc_dir, clean_docs_dir"&gt; &lt;javadoc packagenames="${doc.package.names}" sourcepath="${source.absolute.dir}" destdir="${docs.dir}" verbose="false" /&gt; &lt;jar compress="${jar.compress}" basedir="${docs.dir}" jarfile="${real.out.dir}/${app.dist.name}_JavaDoc.jar"/&gt; &lt;/target&gt; &lt;!-- what about JavaDocs destination directory ? --&gt; &lt;target name="check_doc_dir"&gt; &lt;condition property="docs.dir.not.exists"&gt; &lt;not&gt; &lt;available type="dir" file="${docs.dir}" property="docs.dir.exists"/&gt; &lt;/not&gt; &lt;/condition&gt; &lt;/target&gt; &lt;!-- make docs directory if it isn't there already--&gt; &lt;target name="create_doc_dir" if="docs.dir.not.exists"&gt; &lt;mkdir dir="${docs.dir}"/&gt; &lt;/target&gt; &lt;!-- wipe previous JavaDocs files--&gt; &lt;target name="clean_docs_dir" if="docs.dir.exists"&gt; &lt;delete includeemptydirs="true"&gt; &lt;fileset dir="${docs.dir}" includes="**/*"/&gt; &lt;/delete&gt; &lt;/target&gt; &lt;/project&gt; </code></pre> <p>To create package, simply run <code>ant package_library</code> from project root. You can include these in a build target so, they run on every build.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload