title: Passing jvm argument to ant via jenkins confuses android build tools
body: <p>I'm attempting to integrate a third party monitoring solution (New Relic) into my Android app, which uses an ant-based build.  The integration instructions say to set the <code>ANT_OPTS</code> environment variable to <code>-javaagent:{path to a jar file}</code> before executing the ant command to perform the build.</p>
  
  <p>This works swimmingly when I launch my ant build manually from the command line.</p>
  
  <p>However, we also launch ant builds via Jenkins.  In the Jenkins build configuration there's a section for configuring your ant builds.  In this section is an entry called "Java Options".  From searching elsewhere I've gathered this is the place to put JVM arguments. Typically people want to increase the max heap size, etc.</p>
  
  <p>So I put this in the Java Options section:</p>
  
  <p><code>-javaagent:{path to a jar file}</code></p>
  
  <p>The Jenkins builds, however, fail during the Android "-dex" target as follows:</p>
  
  <pre><code>  [dex] input: /Users/builduser/.jenkins/jobs/Android - Latest/workspace/android/bin/proguard/obfuscated.jar
    [dex] [newrelic.info] Detected the New Relic Android agent in an Ant build (/Users/builduser/.jenkins/jobs/Android - Latest/workspace/android/bin/proguard/obfuscated.jar)
    [dex] Converting compiled files and external libraries into /Users/builduser/.jenkins/jobs/Android - Latest/workspace/android/bin/classes.dex...
     [dx] Unrecognized option: -
     [dx] Could not create the Java virtual machine.
  </code></pre>
  
  <p>I suspect this is not a Google/Android issue because these builds succeed when I set ANT_OPTS and launch the build from a command line.  Something about the way Jenkins handles JVM args is screwy and is confusing the Android build tools.</p>
  
  <p>Anybody have a workaround?</p>