From: Jim Weirich Date: 2003-03-15T19:39:25+09:00 Subject: Re: The onion truck strikes again ... Announcing rake On Sat, 2003-03-15 at 04:09, Seth Kurtzberg wrote: > > I see this functionality as an add-in library. I already have a stand > > alone program (called jdepend.rb) which determines the dependencies in a > > Java project. I can see reworking the jdepend code so that it can be > > used as a library and then in your Rakefile have ... > > > > require 'jdepend' > > JDepend.generate_java_dependencies > > > > or something like that. Since a Rakefile is really Ruby code, its > > trivial to extend it in ways that are difficult in a Makefile. > > True, but there are also disadvantages to that approach. Specifically, either > you are using code in the makefile to generate itself (as in appending > additional dependency rules), or you use a second file to hold additional > dependencies. Both are undesirable. I've done both with Makefiles, but that's not what I am suggesting. Consider the following code (which could be placed directly in a Rakefile)... Dir['src/**/*.java'].each do |srcfile| classfile = srcfile.sub(/^src/, 'classes').sub(/\.java$/, 'class') file srcfile file classfile => [srcfile] + dependencies_for(classfile) do |t| sys %{javac -classpath classes -sourcepath src #{t.name}} end end That code directly recreates the dependencies without generating the text of the Rakefile. It would be run afresh every time a Rakefile is loaded. Of course, calculating dependencies could be a time consuming operations, so perhaps you wouldn't want to do it this way ... but you could (very easily). I think there are some very interesting possibilities here. -- -- Jim Weirich jweirich@one.net http://w3.one.net/~jweirich --------------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)