Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ant and external jars relative to an environment variable



At 12:03 PM -0400 8/18/06, Robert La Ferla wrote:
I have several external jars that are located relative to a directory specified by an environment variable $MYPROJECT. I need to construct a classpath within my build.xml so that javac can compile my project. I do not want to include the external jars in my project - just reference them. It seemed pretty straightforward but I can't seem to get it to work under XCode. I have had some success from the Terminal though. What's the recommended way to do this?

Here's my compile target:

    <target name="compile" description="Compile code">
        <mkdir dir="${bin}"/>
        <mkdir dir="${lib}"/>
        <javac srcdir="${src}" destdir="${bin}"
               source="1.5" target="1.5"
               includeAntRuntime="no"
			   classpath="${myclasspath}"
			   debug="${compile.debug}">
		</javac>
    </target>


One thing I discovered is that a "property" value does not evaluate/expand other environmental variables. It expects a constant.


e.g.
<property name="myclasspath" value=".:${env. MYPROJECT}/endorsed/xercesImpl.jar:${env. MYPROJECT}/endorsed/jdom.jar"/>


I also tried :

<path id="myclasspath">
<pathelement path=".:${env. MYPROJECT}/endorsed/xercesImpl.jar:${env. MYPROJECT}/endorsed/jdom.jar"/>
</path>


and then used classpathref="myclasspath" in the javac task but that didn't work either. I also tried using FileSets.

What am I missing?


SYSTEM/VERSION INFO

Mac OS X Intel 10.4.7 and XCode 2.3

% ant -version
Apache Ant version 1.6.5 compiled on April 11 2006
% uname -a
Darwin localhost 8.7.1 Darwin Kernel Version 8.7.1: Wed Jun 7 16:19:56 PDT 2006; root:xnu-792.9.72.obj~2/RELEASE_I386 i386 i386

I can't address the mix of XCode and Ant, but I do have some Ant stuff that uses environment variables. In every one of those build.xml files, I have an early entry like:


<property environment="env"/>

And then at various other points as needed I have:

<property name="propname" location="${env.VARNAME}"/>

That allows me to use "propname" where needed, in this case as a directory location. Since you specifically asked about using jar files from such a location, I might suggest using a <fileset> as part of your classpath build. In some of my project files, I have some that specifically designate all jar directories in a given directory using *.jar. You might do something like:

<path id="myclasspath">
  <fileset dir="${propname}">
    <include name="*.jar"/>
  </fileset>
</path>

Don't know if this helps...

= Steve =
--
Steve W. Jackson
Montgomery, Alabama
http://homepage.mac.com/stevejackson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >ant and external jars relative to an environment variable (From: Robert La Ferla <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.