I use absolute paths for all my ant builds, but I don't use
jde-ant at the moment.  The idea would be the same either way
though, since the trick is really in properly setting up your
build.xml file.

The simplest way I've found is to pass in
-Dbasedir=/absolute/path/to/project
on the ant command line and then I use "${basedir}/" as a prefix
throughout when I define directory and file properties.  Works great.
For example:

  <property name="dir.dist" value="${basedir}/dist"/>
  <property name="file.distjar"
value="${dir.dist}/${project.name}-${project.version}.jar"/>

Of course project.name and project.version come from another
file property that I include (again based on basedir) such as:

  <property file="${basedir}/build.properties" />   

Perhaps jde-ant supports this already or could be modified
relatively easily to pass in -Dbasedir=.  The way I figure
out my basedir in my jde-mode-hook is to call a function I
wrote that grabs the buffer name and walks up the tree until
I find a build.xml.  If I find one, I build a compile command
that invokes ant.  If I don't find a build.xml
file, then I leave the make command untouched (make -k).
Thus my mode hook even works in older trees where we still
use make instead of ant.  Here's the function for example,
don't know how much work it'd be to incorporate into
jde-ant.el:

;;;; -- Support for ANT builds using \M-x compile
(defvar my-ant-build-filename "build.xml"
"The name of the ant build file (default build.xml)")

(defvar my-ant-command "ant"
"The command to invoke ant (default=ant), for example ant or ant.bat.")

(defun my-find-ant-build-file (dir)
  "Finds the build file in the directory or an ascendant directory."
  (let ((file (find my-ant-build-filename
                    (directory-files dir) :test 'string=)))
    (if dir
        (if file
            (concat dir file)
          (let ((parent (file-name-directory (directory-file-name dir))))
            (if (and (and parent (file-exists-p parent))
                     (not (string= dir parent)))
                (my-find-ant-build-file parent)
              nil)))
      nil)))

(defun my-set-compile-command ()
  "Silently set up ant compile-command on current file if build.xml can be
found.
If unable to find build.xml, do nothing.  Add this to your java-mode-hook."
  (interactive)
  (let ((build-file (my-find-ant-build-file (file-name-directory
buffer-file-name))))
    (if build-file
        (let ((tmp-dir (directory-file-name (file-name-directory
build-file))))
              (let ((tmp-cmd (concat "cd " tmp-dir " ; ./" my-ant-command "
-buildfile " build-file " -Dbasedir=" tmp-dir)))
                (message (concat "setting compile-command: " tmp-cmd))
                (make-local-variable 'compile-command)
                (setq compile-command tmp-cmd)))
      ;(message (concat "Not setting compile-command.  Could not find
build.xml file for " buffer-file-name))
      )))


Troy

-----Original Message-----
From: BURNETT Ross [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 22, 2001 10:45 PM
To: Max Gravitt; [EMAIL PROTECTED]
Subject: RE: using "-Dbuffer=" with jde-ant


Hi Max,

>From what I've seen, Ant requires the file name in <include ..> to be
relative to srcdir, not an absolute path. Hence you need to convert the
value of "buffer" to be relative to srcdir.

Hopefully a jde-ant user has already done this (or worked out how to get Ant
to use absolute paths) and can provide the solution here.

Regards,

Ross

<apologies for unstoppable signature verbiage>
 
> -----Original Message-----
> From: Max Gravitt [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, 23 August 2001 00:43
> To: [EMAIL PROTECTED]
> Subject: using "-Dbuffer=" with jde-ant
> 
> 
> Hi all,
> 
> My problem has to do with how jde-ant is interacting with Ant 
> via the "buffer" system property.  This question may be 
> better directed to an Ant community, but I've opted to start 
> here first in hopes other JDE users use jde-ant/Ant/-Dbuffer 
> the same way.
> 
> I'm trying to use Ant to compile only one file at a time 
> using the "buffer" system property.  Ant isn't compiling any 
> file, even though I set the "include" to the buffer system property.
> 
> Below are my build.xml target and compilation buffers.  Any ideas?
> As I only receive the digest, please be sure to include my 
> email address in your reply.
> 
> thanks in advance,
> Max
> 
> Here is my target (see that I attempt to only compile the 
> file specified by using "<include name="${buffer}"/>):
> 
>  <target name="compile1" depends="init">
>     <!-- Compile the java code from ${src} and place binaries 
> in ${build}-->
>     <echo message="${buffer}"/>
>     <javac srcdir="${src}" 
>       destdir="${build}/WEB-INF/classes"
>       debug="on">
>       <include name="${buffer}"/>
>       <classpath>
>           <pathelement location="${src}/WEB-INF/classes"/>
>           <fileset dir="${src}/WEB-INF/lib">
>                   <include name="**/*.jar"/> 
>           </fileset>
>       </classpath>
>     </javac>
>   </target>
> 
> Here is the *compilation* buffer:
> 
> cd c:/itsv3/src/WEB-INF/classes/com/sas/itsv/ui/
> ant.bat 
> -Dbuffer=c:/itsv3/src/WEB-INF/classes/com/sas/itsv/ui/GetPrope
> rties.java -emacs  -find build.xml compile1 
> Searching for build.xml ...
> Buildfile: c:\itsv3\build.xml
> 
> init:
> 
> compile1:
> c:/itsv3/src/WEB-INF/classes/com/sas/itsv/ui/GetProperties.java
> 
> BUILD SUCCESSFUL
> 
> Total time: 1 second
> 


IMPORTANT NOTICE:
This e-mail and any attachment to it is intended only to be read or used by
the named addressee.  It is confidential and may contain legally privileged
information.  No confidentiality or privilege is waived or lost by any
mistaken transmission to you.  If you receive this e-mail in error, please
immediately delete it from your system and notify the sender.  You must not
disclose, copy or use any part of this e-mail if you are not the intended
recipient.  The RTA is not responsible for any unauthorised alterations to
this e-mail or attachment to it.  

Reply via email to