Also note that, even with the fix, it still won't work if the target name is not on the same line as '<target'. I'll try to provide a fix this weekend. Sorry for the delay; really busy at work right now!
Steve Molitor [EMAIL PROTECTED] -----Original Message----- From: Max Rydahl Andersen [mailto:[EMAIL PROTECTED]] Sent: Friday, October 26, 2001 7:47 AM To: [EMAIL PROTECTED] Subject: Re: jde-ant completion and bug-fix ? I tried to checkout jde-ant.el from CVS and found that the bug-fix regarding target-completion not being able to complete on targets where the name is not the first on the line is not in there. Here is the fix :) (defcustom jde-ant-target-regexp "<\\s-*target.+name\\s-*=\\s-*\"\\s-*\\([^\"]+\\)" "*Regular expression used to match target names in Ant build files." :group 'jde-project :type 'string) ""Molitor, Stephen"" <[EMAIL PROTECTED]> wrote in message A35A461EBB6BD511859E0002A56B89CC44B24C@EXCORP03">news:A35A461EBB6BD511859E0002A56B89CC44B24C@EXCORP03... > Max, > > The bug fix and target-completion stuff is in the latest version of > jde-ant.el, in CVS: > > http://sunsite.dk/cvsweb/jde/lisp/jde-ant.el > > Paul submitted the chagnes. I don't think this is in the latest JDE beta > distribution, which was made before these changes were submitted. > > However, it would also be really nice to get Douglas WF Acheson's changes in > as well, that added the ability to run Ant via Java from the bean shell JVM > :) > > Steve Molitor > [EMAIL PROTECTED] > > > > -----Original Message----- > From: Max Rydahl Andersen [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, October 24, 2001 2:58 PM > To: [EMAIL PROTECTED] > Subject: jde-ant completion and bug-fix ? > > > I'm just wondering wether the maintainers of jde-ant.el have incorporated > the previously posted bugfixes and addition of target-completion ? It is not > in the newest jde-ant.el. > > I have taken the liberty to merge the fixes with the newest jde-ant.el and > appended it to this posting. > > Here is the original "log" from the author. > > ;; Revision 1.10 2001/10/05 15:04:32 smolitor > ;; Added support auto completion of Ant targets in mini-buffer. > ;; Added the following defuns and variables: > ;; defun jde-ant-find-build-file > ;; defun jde-ant-get-target-alist > ;; defcustom jde-ant-complete-target > ;; defcustom jde-ant-target-regexp > ;; Modified defun jde-ant-read-target to use auto-completion, if > ;; jde-ant-complete-target is non-nil. > ;; Fixed bug in jde-build-ant-command where there was no space between the > ant > ;; command and the target. > > ;; fixed jde-ant.el > > ;; jde-ant.el --- Use Apache Ant to build your JDE projects > > ;; $Revision: 1.8 $ $Date: 2001/10/04 04:33:54 $ > > ;; > ;; Author: Jason Stell | [EMAIL PROTECTED] > ;; Created: 19 Oct 2000 > ;; Version 1.3 19 June 2001 > ;; > > ;; This file is not part of Emacs > > ;; This program is free software; you can redistribute it and/or > ;; modify it under the terms of the GNU General Public License as > ;; published by the Free Software Foundation; either version 2, or (at > ;; your option) any later version. > > ;; This program is distributed in the hope that it will be useful, but > ;; WITHOUT ANY WARRANTY; without even the implied warranty of > ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > ;; General Public License for more details. > > ;; You should have received a copy of the GNU General Public License > ;; along with this program; see the file COPYING. If not, write to > ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, > ;; Boston, MA 02111-1307, USA. > > ;; 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.3 (19 June 2001) > ;; : Addition of jde-ant-projecthelp to display list of targets for > ;; the current buildfile. > ;; -- Version 1.2 (4 June 2001) > ;; : Addition of jde-ant-read-buildfile option to prompt for the > buildfile > ;; name -- contributed by Rob Shaw <[EMAIL PROTECTED]> > ;; : Various Bug fixes contributed by Rob Shaw <[EMAIL PROTECTED]> > ;; - The setting of the system property in a format other > ;; than -Dname=value had the side effect of negating the -emacs > ;; command line argument. > ;; - The setting of the current directory to the location of the > ;; JDE project file is now taking place when > ;; jde-ant-enable-find is nil. > ;; - The ant target is now the last thing to be appended to > ;; ant command to avoid any possible confusion for ANT > ;; as to what is the desired target. > ;; -- Version 1.2b2 (25 May 2001) > ;; : Fix to properly use the -find <buildfile> Ant switch--contributed > ;; by Rob Shaw <[EMAIL PROTECTED]>. > ;; -- Version 1.2b1 (23 May 2001) > ;; : Added jde-ant-enable-find custom flag to use the -find switch > ;; available in Ant. This overrides the requirement for a JDE > ;; project file > ;; : Fixed minor bug missing whitespace before -buildfile switch > ;; when building the ant compile command > ;; -- 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 > > > (defcustom jde-ant-program "ant" > "*Specifies name of ant program/script." > :group 'jde-project > :type 'string) > > (defcustom jde-ant-args "-emacs" > "*Specifies arguments to be passed to make program." > :group 'jde-project > :type 'string) > > (defcustom jde-ant-buildfile "build.xml" > "*Specifies the default buildfile to use." > :group 'jde-project > :type 'string) > > (defcustom jde-ant-read-buildfile nil > "*Specify whether to prompt for a buildfile. If non-nil, the > jde-ant-build command prompts you for an ant buildfile." > :group 'jde-project > :type 'boolean) > > (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.") > > (defvar jde-ant-interactive-target-arg-history nil > "History of targets entered in the minibuffer.") > > (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.") > > (defvar jde-ant-interactive-args-arg-history nil > "History of targets entered in the minibuffer.") > > (defcustom jde-ant-enable-find nil > "*Specify whether the -find option should be specified in Ant. If non-nil, > Ant > will search up the directory hierarchy from the current directory for the > build > definition file. Also note that, if non-nil, this will relax the requirement > for > an explicit jde project file." > :group 'jde-project > :type 'boolean) > > (defcustom jde-ant-complete-target t > "*Specify whether to enable completion of build target names in the > minibuffer. > > If non-nil, the jde-ant-build command allows you to use tab completion > in the minibuffer to specify the build target name. This list of > valid build targets is determined by parsing the Ant build file. This > option has no effect if jde-ant-read-target is nil." > :group 'jde-project > :type 'boolean) > > (defcustom jde-ant-target-regexp > "<\\s-*target\\s-+name\\s-*=\\s-*\"\\s-*\\([^\"]+\\)" > "*Regular expression used to match target names in Ant build files." > :group 'jde-project > :type 'string) > > (defun jde-build-ant-command (target more-args) > "Constructs the java ant command." > (let (ant-command) > (setq ant-command > (concat jde-ant-program > " -Dbuffer=\"" buffer-file-name "\" ")) > > (if (not jde-ant-enable-find) > (if (not (string= jde-ant-buildfile "")) > (setq ant-command > (concat ant-command > " -buildfile \"" jde-ant-buildfile "\" ")))) > > (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 " "))) > > (if jde-ant-enable-find > (setq ant-command > (concat ant-command > " -find \"" jde-ant-buildfile "\""))) > > (if (not (string= target "")) > (setq ant-command (concat ant-command " " target " "))) > > > ant-command)) > > ;;;###autoload > (defun jde-ant-build () > "Build the current project using Ant." > (interactive) > > (if jde-ant-read-buildfile > (setq jde-ant-buildfile > (read-from-minibuffer > "Buildfile: " > jde-ant-buildfile > nil nil > '(jde-ant-buildfile-arg-history . 1)))) > > (if jde-ant-read-target > (if jde-ant-complete-target > (setq jde-ant-interactive-target > (completing-read > "Target to build: " > (jde-ant-get-target-alist) > nil > t > jde-ant-interactive-target > '(jde-ant-interactive-target-arg-history . 1))) > (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 (and (eq system-type 'windows-nt) > (not jde-xemacsp)) > (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)) > > (message "%s" compile-command) > (if (not jde-ant-enable-find) > (let ((dir (jde-find-project-file default-directory))) > (if dir > (setq default-directory dir)) > (compile-internal compile-command "No more errors"))) > > (if jde-ant-enable-find > (compile-internal compile-command "No more errors"))))) > > > ;;;###autoload > (defun jde-ant-projecthelp () > "Display Ant project help for the current project. > This will execute the Ant program with the `-projecthelp' > switch to output available targets with their descriptions > for the current buildfile. This function uses the same > rules as `jde-ant-build' for finding the buildfile." > (interactive) > > (if jde-ant-read-buildfile > (setq jde-ant-buildfile > (read-from-minibuffer > "Buildfile: " > jde-ant-buildfile > nil nil > '(jde-ant-buildfile-arg-history . 1)))) > > (let ((projecthelp-command (jde-build-ant-command nil " -projecthelp"))) > (when projecthelp-command > (message "%s" projecthelp-command) > (if (not jde-ant-enable-find) > (let ((dir (jde-find-project-file default-directory))) > (if dir > (setq default-directory dir)) > (shell-command projecthelp-command "*Ant Project Help*")) > (shell-command projecthelp-command "*Ant Project Help*"))))) > > (defun jde-ant-find-build-file (dir) > "Find the next Ant build file upwards in the directory tree from DIR. > > Returns nil if it cannot find a project file in DIR or an ascendant > directory." > (let ((file (find (cond ((string= jde-ant-buildfile "") "build.xml") > (t jde-ant-buildfile)) > (directory-files dir) :test 'string=))) > (if file > (expand-file-name file dir) > (if (not (jde-root-dir-p dir)) > (jde-ant-find-build-file (concat dir "../")))))) > > (defun jde-ant-get-target-alist () > "Returnx asociation list of valid Ant project targets. > > Returns nil if the build file can not be found." > (let (targets > (build-file (jde-ant-find-build-file default-directory))) > (when build-file > (let ((temp-buf (get-buffer-create > "*jde-ant-get-target-list-temp-buffer*"))) > (unwind-protect > (save-excursion > (set-buffer temp-buf) > (erase-buffer) > (insert-file-contents build-file) > (goto-char (point-min)) > (while (re-search-forward jde-ant-target-regexp (point-max) t) > (setq targets (append targets (list (list (match-string > 1))))))) > (kill-buffer temp-buf)))) > targets)) > > > (provide 'jde-ant) > > ;; Change History > > ;; > ;; $Log: jde-ant.el,v $ > ;; Revision 1.8 2001/10/04 04:33:54 paulk > ;; Start change history. > ;; > ;; > > ;; End of jde-ant.el >
