Changeset 13430


Ignore:
Timestamp:
08/01/11 21:34:26 (10 years ago)
Author:
Mark Evenson
Message:

Refactor ASDF extensions from JSS into ABCL-ASDF.

The JAR-FILE, JAR-DIRECTORY, and CLASS-FILE-DIRECTORY ASDF extensions
are now part of the ABCL-ASDF contrib as we aim to centralize all such
things in one place. *ADDED-TO-CLASSPATH* is now part of the
ABCL-ASDF package as well.

There is currently a (mostly) recursive relationship between JSS and
ABCL-ASDF, as each (mostly) requires the other for operation.
JSS:ENSURE-COMPATIBILITY will ensure that JSS continues to understand
the refactored extensions.

Location:
trunk/abcl/contrib
Files:
7 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/abcl/contrib/abcl-asdf/abcl-asdf.asd

    r13355 r13430  
    44(defsystem :abcl-asdf
    55  :author "Mark Evenson"
    6   :version "0.2.0"
    7   :depends-on ("jss") ;;; XXX move the JSS ASDf defintions here? uggh.
     6  :version "0.3.0"
     7  :depends-on ("jss")
    88  :components
    99  ((:module base :pathname "" :components
    1010      ((:file "abcl-asdf")
    11              (:file "maven-embedder" :depends-on ("abcl-asdf"))))))
     11             (:file "asdf-jar"
     12                    :depends-on ("abcl-asdf"))
     13             (:file "maven-embedder"
     14                    :depends-on ("abcl-asdf" "asdf-jar"))))))
  • trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp

    r13367 r13430  
    66
    77   #:resolve-artifact
    8    #:resolve-dependencies))
     8   #:resolve-dependencies
     9
     10   #:add-directory-jars-to-class-path
     11   #:need-to-add-directory-jar?
     12   
     13   #:*added-to-classpath*
     14   #:*inhibit-add-to-classpath*))
    915
    1016(in-package :asdf)
  • trunk/abcl/contrib/abcl-asdf/asdf-jar.lisp

    r13429 r13430  
     1(in-package :abcl-asdf)
     2
     3(defvar *added-to-classpath* nil)
     4
     5(defvar *inhibit-add-to-classpath* nil)
     6
     7(defun add-directory-jars-to-class-path (directory recursive-p)
     8  (loop :for jar :in (if recursive-p
     9                         (all-jars-below directory)
     10                         (directory (merge-pathnames "*.jar" directory)))
     11     :do (java:add-to-classpath jar)))
     12
     13(defun all-jars-below (directory)
     14  (loop :with q = (system:list-directory directory)
     15     :while q :for top = (pop q)
     16     :if (null (pathname-name top))
     17       :do (setq q (append q (all-jars-below top)))
     18     :if (equal (pathname-type top) "jar")
     19       :collect top))
     20
     21(defun need-to-add-directory-jar? (directory recursive-p)
     22  (loop :for jar :in (if recursive-p
     23                         (all-jars-below directory)
     24                         (directory (merge-pathnames "*.jar" directory)))
     25     :doing (if (not (member (namestring (truename jar)) *added-to-classpath* :test 'equal))
     26                (return-from need-to-add-directory-jar? t)))
     27  nil)
     28
    129(in-package :asdf)
    230
     
    432
    533(defmethod perform ((operation compile-op) (c jar-directory))
    6   (unless jss:*inhibit-add-to-classpath*
    7     (jss:add-directory-jars-to-class-path (truename (component-pathname c)) t)))
     34  (unless abcl-asdf:*inhibit-add-to-classpath*
     35    (abcl-asdf:add-directory-jars-to-class-path (truename (component-pathname c)) t)))
    836
    937(defmethod perform ((operation load-op) (c jar-directory))
    10   (unless jss:*inhibit-add-to-classpath*
    11     (jss:add-directory-jars-to-class-path (truename (component-pathname c)) t)))
     38  (unless abcl-asdf:*inhibit-add-to-classpath*
     39    (abcl-asdf:add-directory-jars-to-class-path (truename (component-pathname c)) t)))
    1240
    1341(defmethod operation-done-p ((operation load-op) (c jar-directory))
    14   (or jss:*inhibit-add-to-classpath*
    15     (not (jss:need-to-add-directory-jar? (component-pathname c) t))))
     42  (or abcl-asdf:*inhibit-add-to-classpath*
     43      (not (abcl-asdf:need-to-add-directory-jar? (component-pathname c) t))))
    1644
    1745(defmethod operation-done-p ((operation compile-op) (c jar-directory))
     
    2048(defclass jar-file (static-file) ())
    2149
     50(defmethod source-file-type ((c jar-file) (s module)) "jar")
     51
    2252(defmethod perform ((operation compile-op) (c jar-file))
    23   (jss:add-to-classpath (component-pathname c)))
     53  (java:add-to-classpath (component-pathname c)))
    2454
    2555(defmethod perform ((operation load-op) (c jar-file))
    26   (or jss:*inhibit-add-to-classpath*
    27       (jss:add-to-classpath (component-pathname c))))
     56  (or abcl-asdf:*inhibit-add-to-classpath*
     57      (java:add-to-classpath (component-pathname c))))
    2858
    2959(defmethod operation-done-p ((operation load-op) (c jar-file))
    30   (or jss:*inhibit-add-to-classpath*
    31       (member (namestring (truename (component-pathname c))) jss:*added-to-classpath* :test 'equal)))
     60  (or abcl-asdf:*inhibit-add-to-classpath*
     61      (member (namestring (truename (component-pathname c)))
     62              abcl-asdf:*added-to-classpath* :test 'equal)))
    3263
    3364(defmethod operation-done-p ((operation compile-op) (c jar-file))
     
    3768
    3869(defmethod perform ((operation compile-op) (c class-file-directory))
    39   (jss:add-to-classpath (component-pathname c)))
     70  (java:add-to-classpath (component-pathname c)))
    4071
    4172(defmethod perform ((operation load-op) (c class-file-directory))
    42   (jss:add-to-classpath (component-pathname c)))
    43 
    44 (defmethod source-file-type ((c jar-file) (s module)) "jar")
     73  (java:add-to-classpath (component-pathname c)))
    4574
    4675
    4776
    4877
     78
  • trunk/abcl/contrib/abcl-asdf/maven-embedder.lisp

    r13367 r13430  
    8282  (unless (ensure-mvn-version)
    8383    (error "We need maven-3.0.3 or later."))
    84   (jss:add-directory-jars-to-class-path *mvn-libs-directory* nil)
     84  (add-directory-jars-to-class-path *mvn-libs-directory* nil)
    8585  (setf *init* t))
    8686
  • trunk/abcl/contrib/jss/compat.lisp

    r13396 r13430  
    55
    66(defun ensure-compatibility ()
    7   (setf *cl-user-compatibility* t)
    8   (let ((dont-export '(add-to-classpath *cl-user-compatibility*)))
     7  (require 'abcl-asdf)
     8  (loop :for symbol :in '("add-directory-jars-to-class-path"
     9                          "need-to-add-directory-jar?")
     10        :do
     11          (unintern (intern symbol "CL-USER") :cl-user)
     12        :do
     13          (import (intern symbol "ABCL-ASDF") :cl-user))
     14  (let ((dont-export '(*cl-user-compatibility* add-to-classpath)))
    915    (loop :for symbol :being :each :external-symbol :in :jss
    1016       :when (not (find symbol dont-export))
    11        :do
    12          (unintern symbol :cl-user)
    13        :and :do
    14          (import symbol :cl-user))))
     17         :do
     18           (unintern symbol :cl-user)
     19         :and :do
     20           (import symbol :cl-user)))
     21  (setf *cl-user-compatibility* t))
     22
     23;;; Because we're the last file in the ASDF system at the moment
     24(provide 'jss)
     25
    1526
    1627   
  • trunk/abcl/contrib/jss/invoke.lisp

    r13398 r13430  
    447447      collect (#"getName" (#"elementAt" classesv i))))))
    448448   
    449 (defvar *added-to-classpath* nil)
    450 
    451 (defvar *inhibit-add-to-classpath* nil)
    452 
    453 (defun add-to-classpath (path &optional force)
    454   (unless *inhibit-add-to-classpath*
    455 ;;;    (ensure-dynamic-classpath)
    456 ;;;    (clear-invoke-imports)
    457     (let ((absolute (namestring (truename path))))
    458 ;;       (when (not (equal (pathname-type absolute) (pathname-type path)))
    459 ;;  (warn "HEY! ~a, ~a ~a, ~a" path (pathname-type path) absolute (pathname-type absolute))
    460 ;;  (setq @ (list path absolute)))
    461       ;; NOTE: for jar files, specified as a component, the ".jar" is part of the pathname-name :(
    462       (when (or force (not (member absolute *added-to-classpath* :test 'equalp)))
    463 ;;; (#"addClassPath" *classpath-manager* (new 'java.net.url (#"replaceAll" (#"replaceAll" (concatenate 'string "file://" absolute) "\\\\" "/") "C:" "")))
    464 ;;; (#"setClassLoader" '|jsint.Import| (#"getBaseLoader" *classpath-manager*))
    465 ; (format t "path=~a type=~a~%"  absolute (pathname-type absolute))
    466         (java:add-to-classpath path)
    467   (cond ((equal (pathname-type absolute) "jar")
    468          (jar-import absolute))
    469         ((file-directory-p absolute)
    470          (classfiles-import absolute)))
    471   (push absolute *added-to-classpath*)))))
    472 
    473449(defun get-dynamic-class-path ()
    474450  (rest
     
    525501       (pushnew full-class-name (gethash name *class-name-to-full-case-insensitive*)
    526502    :test 'equal)))
    527 
    528 (defun add-directory-jars-to-class-path (directory recursive-p)
    529   (if recursive-p
    530       (loop for jar in (all-jars-below directory) do (add-to-classpath jar))
    531       (loop for jar in (directory (merge-pathnames "*.jar" directory)) do (add-to-classpath jar))))
    532 
    533 (defun need-to-add-directory-jar? (directory recursive-p)
    534   (if recursive-p
    535       (loop for jar in (all-jars-below directory)
    536    do
    537      (if (not (member (namestring (truename jar)) *added-to-classpath* :test 'equal))
    538          (return-from need-to-add-directory-jar? t)))
    539       (loop for jar in (directory (merge-pathnames "*.jar" directory))
    540    do
    541      (if (not (member (namestring (truename jar)) *added-to-classpath* :test 'equal))
    542          (return-from need-to-add-directory-jar? t))))
    543   nil)
    544503
    545504(defun set-to-list (set)
  • trunk/abcl/contrib/jss/jss.asd

    r13397 r13430  
    44(defsystem :jss
    55  :author "Alan Ruttenberg, Mark Evenson"
    6   :version "2.2.0"
     6  :version "3.0.0"
    77  :components
    8   ((:module base :pathname "" :serial t
     8  ((:module base
     9            :pathname "" :serial t
    910            :components ((:file "packages")
    1011                         (:file "invoke")
    11                          (:file "asdf-jar")
     12                         (:file "classpath")
    1213                         (:file "compat")))))
    1314
  • trunk/abcl/contrib/jss/packages.lisp

    r13398 r13430  
    1111
    1212   #:invoke-add-imports
    13    #:add-directory-jars-to-class-path
    14    #:add-to-classpath
    1513   #:find-java-class
    16    #:need-to-add-directory-jar?
    1714   #:jcmn
    1815   #:japropos
    1916   #:new
     17   
     18   #:jar-import
     19   #:classfiles-import
    2020
    2121;;; Useful utilities to convert common Java items to Lisp counterparts
     
    3535
    3636;;; Enable compatibility with jss-1.0 by placing symbols in CL-USER
    37    #:ensure-compatibility #:*cl-user-compatibility*)
    38    (:shadow #:add-to-classpath))
     37   #:ensure-compatibility #:*cl-user-compatibility*))
    3938
     39
Note: See TracChangeset for help on using the changeset viewer.