ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From William Uther <>
Subject Re: Platform specific code (was: Meta-info on Mac)
Date Tue, 22 Feb 2000 17:30:24 GMT
--On Tue, Feb 22, 2000 1:02 PM +0100 Stefano Mazzocchi <>

> sometimes devs don't have all the free time they'd like to :(

I understand.  Believe me, I understand. :)

>> > I don't want to have dependencies on stuff like that.
>> > 
>> > Can't you use reflection to instance the classes?
>> Ok.  I'll rewrite it with reflection and repost it.  Given that the other
>> would compile and run fine on all platforms I didn't bother before.
> As a standard design pattern and development guideline, ant should not
> depend on packages for compilation that are platform dependent. Say I
> want to have a task that sets the windows registry, I use reflection.
> Say I want a task for compilation dependencies that uses another
> packages and that is redistributable, then yes, it's fine for me...
> we'll make the build.xml file work around its absence, if required. 

What do you mean by 'platform dependant'?  Do you mean 'This only works on
one platform', or 'This is only needed on one plaform'?  In this case it
seems you mean the second definition - I originally assumed the first.

It is a little annoying to use reflection for the whole thing.  How does
this setup look:

Add a package:
with a sub-package:

add an interface

interface {
	Object run(Object[] args);

modify build.xml to exclude the platform package.  Add extra rules to
comile the individual platforms:

  <target name="compile" depends="prepare">
    <mkdir dir="${build.classes}"/>
    <javac srcdir="${src.dir}"

  <target name="mac" depends="compile">
    <javac srcdir="${src.dir}"

Then in the main code you can try to load the appropriate
platform-dependant class, make a new argRunnable instance and call it.
Most of the plaform dependant code goes into the argRunnable instance and
doesn't have to use reflection.  This gives you compile-time type checking,

> (BTW, have you guys looked at javadep?)

No, I hadn't.  I just went searching for it and found:




It looks like both of these process the source to get the dependancies.
Arnout Kuiper's method of looking in the .class files looks cool too.


\x/ill           :-}

View raw message