James Duncan Davidson wrote:
> 
> on 7/25/00 6:03 AM, Stefan Bodewig at [EMAIL PROTECTED] wrote:
> 
> >>>>>> "PD" == Peter Donald <[EMAIL PROTECTED]> writes:
> >
> > PD> Namely the ability to loop through directories like
> >
> > should be possible to borrow what you need from JDE. This is how JDE
> > searches for project.el - the project specific configuration file.
> 
> BTW.. One of a dozen things I wanted to do (and didn't) was to have Ant
> search down for the build file (or default build.xml) towards the root of
> the tree and resolve everything correctly.

I've been meaning to read this thread and post this code for,
what, three weeks. ;-) Anyway, I've attached some modified JDE
code that we use to locate the build.xml file and run ant, fwiw.

We rebind C-c C-v C-b in JDE to run vizdom-build. In practice,
however, I usually invoke compile directly once I've used
vizdom-build to generate the right command line for compile. So I
only use vizdom-build when I switch to another project.

John L
;; build.el
;; 15 June 2000

;; This file defines vizdom-build and some helper functions.
;; vizdom-build searches for a file called "build.xml" in the
;; current directory or a parent directory. If found, it invokes
;; Ant using that build file. The name "build.xml" is hard-coded.
;; The value of vizdom-ant-command needs to be updated for each
;; system.

;; To do: 
;; add a compile command (and appropriate Ant target) to compile
;;   the current buffer only.
;; let vizdom-build take a target (you can recover the compile
;;   command line currently with M-x compile and add a target
;;   there)


;; default-directory is a buffer-local variable in all buffers.

(setq vizdom-ant-command "D:/java/ant/bin/ant.bat")

;; Stolen from JDE.
(defun vizdom-root-dir-p (dir)
  (let ((parent (concat dir "../")))
    (if (eq system-type 'windows-nt)
        (not (file-exists-p parent))
      (and 
       (string= (file-truename dir) "/")
       (string= (file-truename parent) "/")))))

; Stolen from JDE.
; Seems to assume that the directory argument will end in /.
(defun vizdom-find-build-file (dir)
  (let ((file (find "build.xml"
                    (directory-files dir) :test 'string=)))
    (if file
        (concat dir file)
      (if (not (vizdom-root-dir-p dir))
          (vizdom-find-build-file (concat dir "../"))))))

;; (interactive) is required.  (file-name-directory) is defined
;; as everything up to and including the final slash, so we need
;; to remove the final slash in order to go up another directory
;; level.
(defun vizdom-build ()
  (interactive)
  (let ((buildfile (vizdom-find-build-file default-directory)))
    (if buildfile
        (let* ((buildfile (file-truename buildfile))
               (basedir  (file-name-directory buildfile)))
          (compile (concat  vizdom-ant-command 
                            " -buildfile " buildfile
                            " -Dbasedir=" basedir)))
      (message "No build file found"))))

Reply via email to