Build script: Allow customizing output folder

Change-Id: I0c998ae00f85866d14967564184cd2be1c346d87
diff --git a/build.xml b/build.xml
index 10c840e..bd672f9 100644
--- a/build.xml
+++ b/build.xml
@@ -1,7 +1,15 @@
 <project name="IntelliJ IDEA Community Edition" default="all">
   <property name="project.home" value="${basedir}"/>
-  <property name="out.dir" value="${project.home}/out"/>
-  <property name="tmp.dir" value="${project.home}/out/tmp"/>
+
+  <!--
+    Sets the out folder. Defaults to ${basedir}/out.
+    To override, use command line arg "out": e.g. -Dout=/path/
+  -->
+  <condition property="out.dir" value="${out}" else="${project.home}/out">
+    <isset property="out" />
+  </condition>
+
+  <property name="tmp.dir" value="${out.dir}/tmp"/>
 
   <target name="cleanup">
     <delete dir="${out.dir}" failonerror="false"/>
@@ -16,7 +24,8 @@
     <attribute name="script" />
     <sequential>
       <java failonerror="true" jar="${project.home}/lib/ant/lib/ant-launcher.jar" fork="true">
-        <jvmarg line="-Xmx512m -XX:MaxPermSize=152m"/>
+        <jvmarg line="-Xmx768m -XX:MaxPermSize=152m"/>
+        <jvmarg value="-Dout=${out.dir}" />
 
         <arg line="&quot;-Dgant.script=@{script}&quot;"/>
         <arg line="&quot;-Dteamcity.build.tempDir=${tmp.dir}&quot;"/>
diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant
index eb0e9f1..45a3356d 100644
--- a/build/scripts/utils.gant
+++ b/build/scripts/utils.gant
@@ -165,7 +165,10 @@
 
 binding.setVariable("notifyArtifactBuilt", { String artifactPath ->
   if (!artifactPath.startsWith(home)) {
-    projectBuilder.error("Artifact path $artifactPath should start with $home")
+    // AndroidStudio: make this to be just an info as the out folder is typically
+    // not in the home folder
+    projectBuilder.info("Artifact path $artifactPath should start with $home")
+    return
   }
   def relativePath = artifactPath.substring(home.length())
   if (relativePath.startsWith("/")) {