Title: RE: relative paths

Hi,
        Wow, calm down! I was just trying to help. I was not criticizing JDE or anything.

        Anyway, let's see: yes on a second thought I agree that Stefan's  problem is different then mine, and I agree that creating a prj.el on the project root is a much less "esoteric" solution. That is precisely how I use pry.el in my projects. I should have recognized that, I apologize.

        But I stand by my assertion that using relative paths can be error prone in some scenarios. If they start to  get too big (six, seven layers) they become cumbersome and hard to get right, and if you change any directory strutcture in your project you have to go back changing all affected relative paths.

        In my case in particular - which may not be very common - we use ClearCase for source control on Windows boxes. That means that I may want to work on different project trees with the same structure but mapped to different drives (depending on which release/bug fix/view you're working at the moment). Yes I could use relative paths, but using defadvice I was able to use an environment variable to point to specific points in my project tree. So instead of

        ../../../../../lib/proj1/jars
        ../../../../../out/file1.jar

        I can have

        $PROJ_ROOT/lib/proj1/jars
        $PROJ_ROOT/out/file1.jar

        Which IMHO is much more readable and easier to maintain. If you need to change the structure of your project you just have one place to change - not every place where you use a relative path.

        I only used defadvice on jde-load-project-file because there was no jde hook - and I searched for them, in the source code - that would do what I wanted. I had to ensure that every time a project was (re)loaded that the environment variables would be reset based on the current path. Which hook should I use? Could a new jde hook be created for that purpose?

        Regards,
                Nascif

PS: Sorry for the previous HTML e-mail.


-----Original Message-----
From: Paul Kinnucan [mailto:[EMAIL PROTECTED]]
Sent: Monday, August 13, 2001 11:24 AM
To: Abousalh-Neto, Nascif [NCRTP:3X50:EXCH]; Stefan Heimann
Cc: jde
Subject: Re: relative paths


 
----- Original Message -----
From: Nascif Abousalh-Neto
To: Paul Kinnucan ; Stefan Heimann
Cc: [EMAIL PROTECTED]
Sent: Monday, August 13, 2001 10:08 AM
Subject: RE: relative paths


Hi Stefan,
        I had a similar problem to solve,
His problem is that he does not have prj.el file in his source tree, therefore the JDE resolves relative paths against the current buffer directory. Is that your problem? If so, the solution is simple: put a prj.el file in your source tree at the place you want to be the resolution point, typically at the root of your project directory. See the JDE User's Guide for more information.

and used defadvice and environment variables instead of relative paths (which are very error prone and hard to maintain anyway). In my .emacs I have the followin

In what respect are relative paths hard to maintain or error-prone? My group has been using them for months to develop a major commercial  product without the slightest difficulty. If you have a problem with the JDE's implementation of relative paths, please state the problem in detail and recommend improvements so that others may benefit. 

 
In any case, it is more helpful to explain how to use a feature correctly than to recommend a workaround that depends on defadvice and is more esoteric than the feature it attempts to circumvent.

 
BTW, please try to use plain text when posting  to the JDE list out of consideration for those of us who are using plain text mail programs.

- Paul

;;;{{{ set PTM_VOB and JARS_PATH environment variables
;;; based on file name of current buffer.
(setq vob-name "ptm")
(defun extract-vob-mount-path (path-components path-prefix)
        ""
        (if (string= vob-name (car path-components))
                        (concat path-prefix vob-name)
                (extract-vob-mount-path (cdr path-components)
                                                                        (concat path-prefix (car path-components) "/")))

)
(defun set-ptm-vob-var ()
  "Sets the PTM_VOB environment variable to the mounting point directory
   of the view containing the current buffer.
   For example: d:/Views/NASCIF_VIEW/ptm"
  (interactive)
  (setq vob-mount-path
                                (extract-vob-mount-path (split-string (buffer-file-name) "/") ""))
  (setenv "PTM_VOB" vob-mount-path)
  (setenv "JARS_PATH" (concat vob-mount-path "/RunTime/CentrexIP/jars"))
  (setenv "MI2_APPS" (concat vob-mount-path "/RunTime/CentrexIP/MI2/apps"))
  (message (getenv "PTM_VOB")))
; set PTM_VOB and JARS_PATH env variables based on loaded project
(defadvice jde-load-project-file (before set-ptm-vob-var-advice
                                         activate compile)
  "When loading a new project, also resets the PTM_VOB environment variable
   to match the mouting path of the current file"
  (set-ptm-vob-var))
;;;}}}
set-ptm-vob-var sets two environment variables, that depend on my ClearCase View. Their content is set based on the current buffer path, and instead of searching from the leaf up (like in a relative path) I start from the root down until I reach a known segment (the project root directory). I then set this absolute path in an environment variable, which is used by the JDE customization variables.

Good luck,
        Nascif
> -----Original Message-----
> From: Paul Kinnucan [mailto:[EMAIL PROTECTED]]
> Sent: Friday, August 10, 2001 12:32 AM
> To: Stefan Heimann
> Cc: [EMAIL PROTECTED]
> Subject: Re: relative paths
>
>
> At 02:46 AM 8/10/2001 +0200, you wrote:
> >Hi!
> >
> >I have the following project file:
> >
>
> This does not look like a project file to me. It looks like a
> .emacs file.
> I would suspect that you actually do not have a project file
> in your source
> hierarchy, in which case the JDE would treat relative paths
> as relative to
> the directory of the current source buffer, which appears to be the
> behavior you are experiencing.
>
> - Paul
>
> P.S. using setq to set JDE customization variables usually leads to
> problems. Please read the JDE user's guide section on customizing JDE
> variables.
>
> >
> >(setq jde-resolve-relative-paths t)
> >(defvar tmp-javacode-dir "~/javacode-tmp")
> >
> >(defvar cp  '("./"
> >          tmp-javacode-dir
> >          "./../../../lib/ejb.jar"
> >          "$JIKESPATH"))
> >
> >(custom-set-variables
> > '(jde-global-classpath cp)
> > '(jde-compile-option-directory tmp-javacode-dir)  ;;
> necessary for all the
> >completion commands
> > '(compile-command (concat "~/root-room-access/build.sh"))
> >)
> >
> >
> >I think I followed the rules described in the documentation, I don't
> >want to use absolute path in my project file. The problem is: When I
> >invoke the comiler, the paths are interpreted relativly to the file I
> >want to compile and not to the project file. Because I don't
> know what
> >structure my source code directory will habe, I don't see any way to
> >write a portable project file. The solution would be treating the
> >paths relativ to the location of the project file.
> >
> >Any suggestions??
> >
> >By Stefan
>
>

Reply via email to