ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefano Mazzocchi <stef...@apache.org>
Subject Re: Platform specific code (was: Meta-info on Mac)
Date Tue, 22 Feb 2000 18:09:12 GMT
William Uther wrote:
> 
> --On Tue, Feb 22, 2000 1:02 PM +0100 Stefano Mazzocchi <stefano@apache.org>
> wrote:
> 
> > 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: org.apache.tools.ant.platform
> with a sub-package: org.apache.tools.ant.platform.mac
> 
> add an interface
> 
> interface org.apache.tools.ant.argRunnable {
>         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}"
>            destdir="${build.classes}"
>            excludes="**/platform/**"
>            classpath="${classpath}"
>            debug="on"
>            deprecation="on"
>     />
>   </target>
> 
>   <target name="mac" depends="compile">
>     <javac srcdir="${src.dir}"
>            destdir="${build.classes}"
>            includes="**/platform/mac/**"
>            classpath="${classpath}"
>            debug="on"
>            deprecation="on"
>     />
>   </target>
> 
> 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,
> etc.

+1
 
> > (BTW, have you guys looked at javadep?)
> 
> No, I hadn't.  I just went searching for it and found:
> 
> <http://ptolemy.eecs.berkeley.edu/~cxh/java/javadepend/>
> 
> and
> 
> <http://www.cs.McGill.CA/~stever/software/JavaDeps/>
> 
> 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.

to be honest, I didn't quite get Arnout's idea... :/ 

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<stefano@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Come to the first official Apache Software Foundation Conference!  
------------------------- http://ApacheCon.Com ---------------------



Mime
View raw message