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 | |
---|
29 | (in-package :asdf) |
---|
30 | |
---|
31 | (defclass jar-directory (static-file) ()) |
---|
32 | |
---|
33 | (defmethod perform ((operation compile-op) (c jar-directory)) |
---|
34 | (unless abcl-asdf:*inhibit-add-to-classpath* |
---|
35 | (abcl-asdf:add-directory-jars-to-class-path (truename (component-pathname c)) t))) |
---|
36 | |
---|
37 | (defmethod perform ((operation load-op) (c jar-directory)) |
---|
38 | (unless abcl-asdf:*inhibit-add-to-classpath* |
---|
39 | (abcl-asdf:add-directory-jars-to-class-path (truename (component-pathname c)) t))) |
---|
40 | |
---|
41 | (defmethod operation-done-p ((operation load-op) (c jar-directory)) |
---|
42 | (or abcl-asdf:*inhibit-add-to-classpath* |
---|
43 | (not (abcl-asdf:need-to-add-directory-jar? (component-pathname c) t)))) |
---|
44 | |
---|
45 | (defmethod operation-done-p ((operation compile-op) (c jar-directory)) |
---|
46 | t) |
---|
47 | |
---|
48 | (defclass jar-file (static-file) ()) |
---|
49 | |
---|
50 | (defmethod source-file-type ((c jar-file) (s module)) "jar") |
---|
51 | |
---|
52 | (defmethod perform ((operation compile-op) (c jar-file)) |
---|
53 | (java:add-to-classpath (component-pathname c))) |
---|
54 | |
---|
55 | (defmethod perform ((operation load-op) (c jar-file)) |
---|
56 | (or abcl-asdf:*inhibit-add-to-classpath* |
---|
57 | (java:add-to-classpath (component-pathname c)))) |
---|
58 | |
---|
59 | (defmethod operation-done-p ((operation load-op) (c jar-file)) |
---|
60 | (or abcl-asdf:*inhibit-add-to-classpath* |
---|
61 | (member (namestring (truename (component-pathname c))) |
---|
62 | abcl-asdf:*added-to-classpath* :test 'equal))) |
---|
63 | |
---|
64 | (defmethod operation-done-p ((operation compile-op) (c jar-file)) |
---|
65 | t) |
---|
66 | |
---|
67 | (defclass class-file-directory (static-file) ()) |
---|
68 | |
---|
69 | (defmethod perform ((operation compile-op) (c class-file-directory)) |
---|
70 | (java:add-to-classpath (component-pathname c))) |
---|
71 | |
---|
72 | (defmethod perform ((operation load-op) (c class-file-directory)) |
---|
73 | (java:add-to-classpath (component-pathname c))) |
---|
74 | |
---|
75 | |
---|
76 | |
---|
77 | |
---|
78 | |
---|