source: tags/1.5.0/contrib/abcl-asdf/mvn-module.lisp

Last change on this file was 15018, checked in by Mark Evenson, 3 years ago

asdf-mvn-module: enable use of MVN-MODULE in ASDF definitions

The MVN-MODULE component allows finer control over Maven's
behavior when the transitive dependency graph contains conflicting

(:mvn-module NAME

:dependencies DEPENDENCIES
:managed-dependencies MANAGED-DEPENDENCIES
:exclusions EXCLUSIONS)



A list of Maven artifacts in the form of colon or slash separated


A List of maven artifacts. If an dependency with same GROUPID and
ARTIFACTID are encountered, the version specified here overrides.


A list of partial maven artifacts groupid:artifactid. Dependencies
with same groupid and artifactid are exluded

An example of a MVN-MODULE ASDF declaration:

(defsystem foo

:defsystem-depends-on (asdf-mvn-module)
:components ((:mvn-module maven







c.f. <>

Originally from <>.

File size: 3.4 KB
1(in-package :abcl-asdf)
3;;; <>
4;;; If a artifact is root then its optional dependencies are
5;; collected. If the same artifact is not root, then the optional
6;;; dependencies are not collected. We don't need optionals since from
7;;; our point of view we are the top pom and everything specified are
8;;; dependencies
9;;; Used by asdf-mvn-module. 
10(defun resolve-multiple-maven-dependencies
11    (dependencies &optional managed-dependencies exclusions (first-is-root nil))
12  "Return a list of jar file paths that satisfy dependencies
14 dependencies: a list of maven artifacts. color or slash separated
15   components groupid:artifactid:versionid
17 managed-dependencies: a list of maven artifacts. If an dependency
18   with same groupid and artifactid are encountered, the version
19   specified here overrides.
21 exclusions: a list of partial maven artifacts
22   groupid:artifactid. Dependencies with same groupid and artifactid are
23   exluded
25 first-is-root: If the first dependency should include optional
26   dependencies, set this to t. Usually not.
27 "
28  (let (aether)
29    (with-aether (aether)
30      (let ((collect-request (java:jnew (jss:find-java-class "CollectRequest")))
31            (exclusions-collection (jss:new 'hashset) )
32            (compile-scope (java:jfield (jss:find-java-class "JavaScopes") "COMPILE")))
33        (loop for e  in exclusions
34           for (groupid artifactid) = (abcl-build:split-string e #\:)
35           ;; If i have scope be compile-scope it doesn't get excluded!!
36           for exclusion = (jss:new 'aether.graph.Exclusion groupid artifactid "" "jar")
37           do (#"add" exclusions-collection exclusion))
38        (loop for a in dependencies
39           for artifact = (make-artifact (#"replaceAll" a "/" ":"))
40           for dependency = (jss:new 'aether.graph.Dependency artifact compile-scope)
41           do 
42           ;; setExclusions returns a new dependency. We have to use
43           ;; that. That passed dependency i not modified!
44           ;;
45           ;; Nice of them to clearly document that :-/
46       (setq dependency (#"setExclusions" dependency exclusions-collection))
47       (if first-is-root
48     (#"setRoot" collect-request dependency)
49     (#"addDependency" collect-request dependency))
50       (setq first-is-root nil))
51        (loop for a in managed-dependencies
52           for artifact = (make-artifact (#"replaceAll" a "/" ":"))
53           for dependency = (jss:new 'aether.graph.Dependency artifact compile-scope)
54           do (setq dependency (#"setExclusions" dependency exclusions-collection))
55       (#"addManagedDependency" collect-request dependency))
56        (let ((dependencies (#"collectDependencies" (ensure-repository-system) (ensure-session) collect-request))
57              (nodelist-generator (jss:new 'PreorderNodeListGenerator))
58              (dependency-request (jss:new 'DependencyRequest)))
59          (#"setRoot" dependency-request (#"getRoot" dependencies))
60          (#"resolveDependencies" (ensure-repository-system) (ensure-session) dependency-request)
61          (#"accept" (#"getRoot" dependencies) nodelist-generator)
62          (abcl-build:split-string (#"getClassPath" nodelist-generator) #\:))))))
Note: See TracBrowser for help on using the repository browser.