source: trunk/abcl/contrib/abcl-asdf/mvn-module.lisp

Last change on this file was 15115, checked in by mevenson, 8 months ago

contrib/abcl-asdf/mvn-module collect request needs a repository

(Alan Ruttenberg)

The part of the patch involving ABCL-ASDF:RESOLVE has already been
addressed in Ferrada's MVN fixes contained in
<https://abcl.org/trac/changeset/15100>.

Merges <https://github.com/armedbear/abcl/pull/67>

File size: 3.4 KB
Line 
1(in-package :abcl-asdf)
2
3;;; <https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html>
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
13
14 dependencies: a list of maven artifacts. color or slash separated
15   components groupid:artifactid:versionid
16
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.
20
21 exclusions: a list of partial maven artifacts
22   groupid:artifactid. Dependencies with same groupid and artifactid are
23   exluded
24
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 'java.util.HashSet))
32            (compile-scope (java:jfield (jss:find-java-class "JavaScopes") "COMPILE")))
33  (#"addRepository" collect-request (ensure-remote-repository))
34        (loop for e  in exclusions
35           for (groupid artifactid) = (abcl-build:split-string e #\:)
36           ;; If i have scope be compile-scope it doesn't get excluded!!
37           for exclusion = (jss:new 'aether.graph.Exclusion groupid artifactid "" "jar")
38           do (#"add" exclusions-collection exclusion))
39        (loop for a in dependencies
40           for artifact = (make-artifact (#"replaceAll" a "/" ":"))
41           for dependency = (jss:new 'aether.graph.Dependency artifact compile-scope)
42           do 
43           ;; setExclusions returns a new dependency. We have to use
44           ;; that. That passed dependency i not modified!
45           ;; http://grepcode.com/file/repo1.maven.org/maven2/org.eclipse.aether/aether-api/1.0.2.v0150114/org/eclipse/aether/graph/Dependency.java#Dependency.getOptional%28%29
46           ;; Nice of them to clearly document that :-/
47       (setq dependency (#"setExclusions" dependency exclusions-collection))
48       (if first-is-root
49     (#"setRoot" collect-request dependency)
50     (#"addDependency" collect-request dependency))
51       (setq first-is-root nil))
52        (loop for a in managed-dependencies
53           for artifact = (make-artifact (#"replaceAll" a "/" ":"))
54           for dependency = (jss:new 'aether.graph.Dependency artifact compile-scope)
55           do (setq dependency (#"setExclusions" dependency exclusions-collection))
56       (#"addManagedDependency" collect-request dependency))
57        (let ((dependencies (#"collectDependencies" (ensure-repository-system) (ensure-session) collect-request))
58              (nodelist-generator (jss:new 'PreorderNodeListGenerator))
59              (dependency-request (jss:new 'DependencyRequest)))
60          (#"setRoot" dependency-request (#"getRoot" dependencies))
61          (#"resolveDependencies" (ensure-repository-system) (ensure-session) dependency-request)
62          (#"accept" (#"getRoot" dependencies) nodelist-generator)
63          (abcl-build:split-string (#"getClassPath" nodelist-generator) #\:))))))
Note: See TracBrowser for help on using the repository browser.