ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Barrie Treloar <>
Subject Get emacs to find the correct build.xml and automatically pass it to ant.
Date Wed, 20 Sep 2000 07:52:37 GMT
On 20 Sep 2000, Stefan Bodewig wrote:

> It is useful for a lot of people I know - those using (X)Emacs/JDE can
> now simply say "build using make" and set the make command to ant and
> it will always pick up build.xml without the need to explicitly
> specify the -buildfile switch, for example.

To do this with Emacs/JDE do the following:

(I'll add this to FAQ when its working :)

        Customize jde-build-use-make and set it to true.
        [This makes jde use make instead of its own internal builder]

        Customize jde-read-make-args and set it to true.
        [This makes jde prompt you for the arguments to give to make.
        You can just hit return if you dont want to pass any arguments
        (the common case), otherwise you can include the target you
        want invoked.  Dont specify the build file to use, we will do
        this another way]

        Customize jde-make-program and set it to "ant".
        [This makes jde use "ant" instead of "make" as the build program]

        To your .emacs files add the following, this causes jde to try
        and load a prj.el file whenever you open a .java file.  This
        allows us to do some black magic a bit later.
            ;; JDE mode
            (require 'jde)
                     (add-hook 'jde-mode-hook 
                               '(lambda ()

        For each project hierarchy create a prj.el file at the top
        level.  JDE will search the directory hierarchy to find the
        prj.el file and use the first one it finds.  For example, if
        you are in <TOP>/src/org/apache/tools/ant/ and you load and the file <TOP>/prj.el exists it will load it.
        The prj.el file will customize the jde-make-args to include
        the correct build file based on the java file that was

        The prj.el file should contain the following lisp code:

;;; BEGIN prj.el

;; This file is loaded by JDE-mode via JDE->Project->Project File->Load.
;; The only value that requires changing is the jde-make-args variable
;; Notes:  It is important to use make-local-variable as this allows
;; each buffer to have its own version of the build.xml file.
;; Therefore two source files from two different projects will
;; correctly use the write build.xml file.

; The location of the Ant build file.
(make-local-variable 'jde-make-args)
(setq jde-make-args "-f <TOP>/build.xml")

;; You may want to add the following (this allows C-z C-z or
;; "compile" to use ant instead of "make")  This is more natural to
;; old emacs hackers than C-c C-v C-b.
; Set C-z C-z to be the same as C-c C-v C-b inside jde major modes
(local-set-key "\C-z\C-z" 'jde-build)

;;; END prj.el

Happy hacking,
Barrie Treloar

  Barrie Treloar                      Phone: +61 8 8303 3300
  Senior Analyst/Programmer           Fax:   +61 8 8303 4403 
  Electronic Commerce Division        Email:
  Camtech (SA) Pty Ltd      
 --- Level 8, 10 Pulteney Street, Adelaide SA 5000, Australia. ---

View raw message