>>> joakim@... seems to think that:
>I'm trying to make a maven2 project type for ede, by subclassing
>ede-simple. However, I have no idea how to do this.
>
>I thought maybe I would be offered the type "simple" when I did ede-new
>on a directory, but this doesnt seem to be the case. How is ede-simple
>meant to be used?
>
>I attach my current maven2 file, which only contains comments with
>questions atm.
Hi Joakim,
I never finished getting the EDE Simple project working with an
example subclass to a point that I like. My original intention was to
move the ede-cpp-root to a subclass of ede-simple. If I had finished
that, then there would be a good starting place. I also haven't gone
through ede-simple.el with my recent optimizations so I'm not sure
what state it is in right now. In the end it was unclear to me if
working to build a nice UI to create such a project would be worth it
when the existing overhead of hacking a little lisp code in someone's
.emacs would do.
If your intention is to have a simple way to tag the root of a maven
project, then you are probably correct to subclass ede-simple, I just
haven't done that myself yet.
If you want to have ede compile/debug commands hooked up, and have
special include paths and other EDE provided features, then you
probably want to replicate the emacs or linux specialized projects.
The project style in ede-linux.el shows an example of identifying the
root of some project, scanning files for data, and modifying include
paths. I would guess this is what you want to do. The piece that is
missing is the auxiliary save file.
If you want an aux save file, and perhaps auto-generate your pom
file, then you would want to mimic an ede-proj.el project style. If
you did that you could have a user create an EDE project, and save it
out to pom.xml via code generation. If there is a pom.xml file per
directory, then you could probably just extend the existing ede-proj
to output yet another makefile type.
To help get you started, below find a quick-hack which makes a
"maven" project based on some pom.xml file. It is a standalone
single-root-project style, like the Emacs project type. I don't know
anything else about Maven, but this should provide the framework you need
to get started.
If you have any other questions, let me know.
Eric
-------------
;;; ede-maven.el --- Special project Maven
;; Copyright (C) 2008 Eric M. Ludlam
;; Author: Eric M. Ludlam <eric@...>
;; X-RCS: $Id$
;; 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., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;;
(require 'ede)
;;; Code:
;; Because there is one root project file, and no sub project files,
;; we need a special root-finding function.
;; Second note. This upward scan is a bit lame. It would be nice if
;; there were a better way.
;;;###autoload
(defun ede-maven-project-root (&optional dir)
"Get the root directory for DIR."
(when (not dir) (setq dir default-directory))
(let ((ans nil))
(while (and dir (not ans))
(when (file-exists-p (expand-file-name "pom.xml" dir))
(setq ans dir))
(setq dir (ede-up-directory dir)))
ans))
;;;###autoload
(defun ede-maven-load (dir &optional rootproj)
"Return a Maven Project object if there is a match.
Return nil if there isn't one.
Argument DIR is the directory it is created for.
ROOTPROJ is nil, since there is only one project."
(let ((this
(ede-maven-project "Maven"
:name "maven" ; make fancy name fro mdir here.
:directory dir
:file "pom.xml")))
(ede-add-project-to-global-list this)
))
;;;###autoload
(add-to-list 'ede-project-class-files
(ede-project-autoload "maven"
:name "MAVEN"
:file 'ede-maven
:proj-file "pom.xml"
:proj-root 'ede-maven-project-root
:load-type 'ede-maven-load
:class-sym 'ede-maven-project
:new-p nil)
t)
(defclass ede-maven-target-java (ede-target)
()
"EDE Maven Project target for Java code.
All directories need at least one target.")
(defclass ede-maven-target-c (ede-target)
()
"EDE Maven Project target for Maven C code.
All directories need at least one target.")
(defclass ede-maven-target-misc (ede-target)
()
"EDE Maven Project target for Misc files.
All directories need at least one target.")
;;;###autoload
(defclass ede-maven-project (ede-project)
(
)
"Project Type for the Maven source code."
:method-invocation-order :depth-first)
(defmethod initialize-instance ((this ede-maven-project)
&rest fields)
"Make sure the :targets is setup."
(call-next-method)
(unless (slot-boundp this 'targets)
(oset this :targets nil))
)
;;; File Stuff
;;
(defmethod ede-project-root-directory ((this ede-maven-project)
&optional file)
"Return the root for THIS Maven project with file."
(file-name-directory (oref this file)))
(defmethod ede-project-root ((this ede-maven-project))
"Return my root."
this)
(defmethod ede-find-subproject-for-directory ((proj ede-maven-project)
dir)
"Return PROJ, for handling all subdirs below DIR."
proj)
;;; TARGET MANAGEMENT
;;
(defun ede-maven-find-matching-target (class dir targets)
"Find a target that is a CLASS and is in DIR in the list of TARGETS."
(let ((match nil))
(dolist (T targets)
(when (and (object-of-class-p T class)
(string= (oref T :path) dir))
(setq match T)
))
match))
(defmethod ede-find-target ((proj ede-maven-project) buffer)
"Find an EDE target in PROJ for BUFFER.
If one doesn't exist, create a new one for this directory."
(let* ((ext (file-name-extension (buffer-file-name buffer)))
(cls (cond ((not ext)
'ede-maven-target-misc)
((string-match "\\(c\\|h\\)\\(pp\\|++\\)?" ext)
'ede-maven-target-c)
((string-match "java" ext)
'ede-maven-target-el)
(t 'ede-maven-target-misc)))
(targets (oref proj targets))
(dir default-directory)
(ans (ede-maven-find-matching-target cls dir targets))
)
(when (not ans)
(setq ans (make-instance
cls
:name (file-name-nondirectory
(directory-file-name dir))
:path dir
:source nil))
(object-add-to-list proj :targets ans)
)
ans))
;;; UTILITIES SUPPORT.
;;
(provide 'ede-maven)
;;; ede-maven.el ends here
|