;; jde-ant.el --- Use Apache Ant to build your JDE projects ;; ;; Author: Jason Stell | jason.stell@globalone.net ;; Created: 19 Oct 2000 ;; Version 1.1 ;; ;; Commentary: ;; This file defines jde-ant-build and some helper functions. ;; jde-ant-build uses the specified ant program/shell script to ;; execute a specified build file (in the project root). ;; ;; ;; Installation: ;; -- Make sure this file is accessible via your emacs load-path ;; -- Add the following to your .emacs ;; (require 'jde-ant) ;; -- Customize the ant variables, which can be found in the ;; jde-project group ;; -- Optionally create a keybinding for jde-ant-build ;; ;; ;; To do: ;; -- allow interactive ant target/argument specification. ;; {DONE - version 1.1} ;; ;; -- consider using jde-run-java-vm to execute Ant instead of ;; requiring a shell script. ;; ;; ;; Notes: ;; -- The JDE (Java Development Environment for Emacs) can be ;; downloaded at http://sunsite.auc.dk/jde/ ;; ;; -- Apache Ant is a Java & XML build system that can be downloaded ;; at http://jakarta.apache.org/ant/ ;; ;; Version History: ;; ;; -- Version 1.1 (20 October 2000) ;; : Added interactive prompts (optional, based on customizable ;; toggles) for Ant target and additional args. Removed the ;; jde-ant-target custom variable, since this is really ;; represented by the default target in the build file. ;; : The -f switch seems to be causing problems. Removed it from ;; the default jde-ant-args. ;; : Basic changes to the way the ant command is assembled. ;; ;; -- Version 1.0 (19 October 2000) ;; Initial Version (require 'compile) (require 'jde) (defcustom jde-ant-program "ant" "*Specifies name of ant program/script." :group 'jde-project :type 'string) (defcustom jde-ant-args "-Demacs=true" "*Specifies arguments to be passed to make program." :group 'jde-project :type 'string) (defcustom jde-ant-buildfile "build.xml" "*Specifies the buildfile to use." :group 'jde-project :type 'string) (defcustom jde-ant-read-target nil "*Specify whether to prompt for a build target. If non-nil, the jde-ant-build command prompts you for an ant target." :group 'jde-project :type 'boolean) (defvar jde-ant-interactive-target "" "Target to use for the build in place of the default target.") (defcustom jde-ant-read-args nil "*Specify whether to prompt for additional arguments to pass to ant. If non-nil, the jde-ant-build command prompts you for the additional arguments." :group 'jde-project :type 'boolean) (defvar jde-ant-interactive-args "" "Additional arguments for the ant command.") (defun jde-build-ant-command (target more-args) "Constructs the java ant command." (let (ant-command) (setq ant-command (concat jde-ant-program " -D" buffer-file-name)) (if (not (string= jde-ant-buildfile "")) (setq ant-command (concat ant-command "-buildfile " jde-ant-buildfile " "))) (if (not (string= target "")) (setq ant-command (concat ant-command target " "))) (if (not (string= jde-ant-args "")) (setq ant-command (concat ant-command jde-ant-args " "))) (if (not (string= more-args "")) (setq ant-command (concat ant-command more-args " "))) ant-command)) ;;;###autoload (defun jde-ant-build () "Build the current project using Ant." (interactive) (if jde-ant-read-target (setq jde-ant-interactive-target (read-from-minibuffer "Target to build: " jde-ant-interactive-target nil nil '(jde-ant-interactive-target-arg-history . 1)))) (if jde-ant-read-args (setq jde-ant-interactive-args (read-from-minibuffer "Additional build args: " jde-ant-interactive-args nil nil '(jde-ant-interactive-args-arg-history . 1)))) (let ((compile-command (jde-build-ant-command jde-ant-interactive-target jde-ant-interactive-args))) (when compile-command ;; Force save-some-buffers to use the minibuffer ;; to query user about whether to save modified buffers. ;; Otherwise, when user invokes the command from ;; menu, save-some-buffers tries to popup a menu ;; which seems not to be supported--at least on ;; the PC. (if (eq system-type 'windows-nt) (let ((temp last-nonmenu-event)) ;; The next line makes emacs think that the command ;; was invoked from the minibuffer, even when it ;; is actually invoked from the menu-bar. (setq last-nonmenu-event t) (save-some-buffers (not compilation-ask-about-save) nil) (setq last-nonmenu-event temp)) (save-some-buffers (not compilation-ask-about-save) nil)) (let ((default-directory (jde-find-project-file default-directory))) (message "%s" compile-command) (compile-internal compile-command "No more errors") )))) (provide 'jde-ant) ;; End of jde-ant.el