Note that there are some explanatory texts on larger screens.

plurals
  1. PORunning "headless Eclipse" inside Ant task
    primarykey
    data
    text
    <p><strong>Please note</strong> - to anybody that argues that I should "remove the backstory" here, or that this question has "nothing to do with CodePro", I would like to mention that CodePro has very little documentation for how to get their Ant tasks up-and-running properly from the command-line. CodePro is almost 100% UI-driven, which their documentation focuses on. If this question can be completely answered, I believe it will serve as one of the few (if not the only) full pieces of documentation for other developers like myself who just want to run CodePro tasks from the command-line, as part of their build.</p> <p>I'm trying to get <a href="https://developers.google.com/java-dev-tools/codepro/doc/features/ant/enhancements" rel="nofollow">CodePro AnalyTix's Ant tasks</a> working from the command-line.</p> <p>After reading the documentation, and downloading some examples, it doesn't want you to run tasks the normal way you run externally-defined tasks in Ant, which usually looks like:</p> <ol> <li>Define an <code>xmlns</code> attribute inside the root <code>&lt;project&gt;</code> element for the 3rd party Ant jar</li> <li>Define 1+ tasks with <code>&lt;taskdef&gt;</code> declarations</li> <li>Call those defined tasks from inside a <code>&lt;target&gt;</code> element</li> </ol> <p>With CodePro, the Ant tasks depend on many core Eclipse jars/classes. If you download any of their <a href="https://developers.google.com/java-dev-tools/codepro/doc/features/ant/headless" rel="nofollow">examples</a>, you'll see Windows BATCH files written that demonstrate how they want you to run their Ant tasks, and they all take on the following form:</p> <pre><code>set JAVAEXE="\Programs\jdk1.5.0_05\jre\bin\java.exe" set ECLIPSEHOME="\Programs\eclipse_330" set WORKSPACE="\Programs\eclipse_330_headless\headless_arbitrary_src_multi_audit\workspace" for /f "delims= tokens=1" %%c in ('dir /B /S /OD %ECLIPSEHOME%\plugins\org.eclipse.equinox.launcher_*.jar') do set EQUINOXJAR=%%c :run @echo on %JAVAEXE% -jar %EQUINOXJAR% -clean -noupdate -application org.eclipse.ant.core.antRunner -data %WORKSPACE% -verbose -file headless.xml %* &gt;headless_out.txt 2&gt;&amp;1 </code></pre> <p>The <code>headless.xml</code> is the Ant file that has the CodePro Ant targets and tasks.</p> <p>I tried all morning to supply my Ant lib directory with the necessary dependencies it needs to run these CodePro tasks the "normal" way, but found myself beginning to copy the entire Eclipse <code>plugins/</code> directory into <code>ANT_HOME/lib</code>! I've reverted those changes and am now ready to accept this (rather ugly) way of running Ant from the command-line.</p> <p>Borrowing from the example above, here's my new setup:</p> <ul> <li><code>build.xml</code> is my "core" Ant buildfile, and is where I will have a target named <code>run-codepro-analysis</code></li> <li><code>codepro-analysis.xml</code> is where all my CodePro tasks will be defined (inside of wrapper targets); this is equivalent to <code>headless.xml</code> in the BATCH file above</li> <li>I want <code>buildfile.xml#run-codepro-analysis</code> to call <code>&lt;java&gt;</code> and run the exact same arguments as provided in the BATCH file above, <strong>with the following exceptions</strong>: <ul> <li>Coincidentally, I already have three env vars setup on my machine: <code>JAVA_HOME</code> (pointing to my JDK), <code>ECLIPSE_HOME</code> and <code>WORKSPACE_HOME</code>; I obviously want to use these in lieu of <code>JAVAEXE</code>, <code>ECLIPSEHOME</code> and <code>WORKSPACE</code></li> <li>I want the output to be redirected to the same console/terminal as I am running <code>ant -buildfile build.xml run-codepro-analysis</code> from; <em>not</em> <code>headless_out.txt</code> or some other file</li> </ul></li> </ul> <p>Seeing that this is a pretty complicated command (with many options, arguments, and even nested argument to options), I'm not really sure how to construct the <code>&lt;java&gt;</code> elements inside the <code>run-codepro-analysis</code> target, but here's what I have so far:</p> <pre><code>&lt;target name="run-codepro-analysis"&gt; &lt;java fork="true" failonerror="true" jar="${env.ECLIPSE_HOME}/plugins/org.eclipse.equinox.launcher_*.jar"&gt; &lt;arg line="-clean -noupdate -application org.eclipse.ant.core.antRunner -data ${env.WORKSPACE_HOME} -verbose -file codepro-analysis.xml"/&gt; &lt;/target&gt; </code></pre> <p>When I run this, the build fails:</p> <blockquote> <p>[java] Unable to access jarfile /home/myuser/sandbox/workbench/eclipse/indigo-3.7/eclipse/plugins/org.eclipse.equinox.launcher_*.jar</p> </blockquote> <p>I'm not sure if this is because the wildcard is failing and its actually looking for <code>org.eclipse.equinox.launcher_*.jar</code>, or if something else inside my <code>&lt;java&gt;</code> task is configured incorrectly. Thanks in advance to anyone who can help me get this working. Like I said, there's no other comprehensive documentation on the web (that I could find, anyways) that explains how to get this working as part of a build, especially for Linux developers who can't run BATCH files.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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