[kepler-dev] using ant to detect J3D

Matt Jones jones at nceas.ucsb.edu
Fri Jul 15 15:54:58 PDT 2005


Thanks Dan.  In addition to nesting the compilation inside of the
checkJ3D target, you can also use the "unless" and "if" commands to
check a property value to do something conditionally.  There is an
example of this in the checkOS, lin.prep, and win.prep targets of the
current build.  IN this case, you could use checkJ3D to determine if the
jar is available, and then based on the value of the J3D.available
property decide whether to include or exclude the source that depends on
it, something like this:

<target name="copyJ3Dsource" depends="prepare,checkJ3D"
        if="J3D.available">
   <copy todir="${kep.build.src}" filtering="yes">
      <fileset dir="${srcdir}">
        <include name="org/kepler/J3Dmodule/**"/>
      </fileset>
    </copy>
</target>

I've intended to do this for all of the 3rd party dependencies for a
long time but never gotten around to it.  That is why so many of the
optional things in PTII are excluded from the Kepler build.  It would be
nice if this were set up generally.

Matt

Dan Higgins wrote:
> Hi Ilkay,
> 
>     You may have already figured this out, but I got interested in how 
> to detect if J3D is installed using ant.
> 
>     The clue was to look at the PT config to see how it is detected 
> there. There is a java file (java3DTest.java) in the PTII/config/ dir 
> that is used in the PT configure. Basically, they just try to compile 
> this file which import a class from J3D and if the compile works, then 
> J3D is installed; otherwise it is not.
> 
>     In Ant, we can use the Available and Condition tasks. For example, 
> this seems to work
> 
>   <!--target to detemine if java3D is available -->
>   <target name="checkJ3D">
>     <condition property="J3D.available">
>       <available classname="javax.media.j3d.Canvas3D"/>
>     </condition>
>   </target>
>   <target name="hasJ3D" depends="checkJ3D" if="J3D.available">
>     <echo>Java3D is available</echo>
>   </target>
> 
> Running the target 'hasJ3D' will only run <echo> if the 
> 'javax.media.j3d.Canvas3D' class is available (The choice of the 
> Canvas3D class was arbitrary). Simple replace any J3D specific 
> compilation commandswhere the <echo> is and it will only be compiled 
> when appropriate.
> 
> Dan
> 

-- 
-------------------------------------------------------------------
Matt Jones                                     jones at nceas.ucsb.edu
http://www.nceas.ucsb.edu/    Fax: 425-920-2439    Ph: 907-789-0496
National Center for Ecological Analysis and Synthesis (NCEAS)
University of California Santa Barbara
Interested in ecological informatics? http://www.ecoinformatics.org
-------------------------------------------------------------------


More information about the Kepler-dev mailing list