[armedbear-cvs] r13367 - trunk/abcl/contrib/abcl-asdf
mevenson at common-lisp.net
mevenson at common-lisp.net
Wed Jun 29 15:35:07 UTC 2011
Author: mevenson
Date: Wed Jun 29 08:35:07 2011
New Revision: 13367
Log:
RESOLVE-DEPENDENCIES now working for remote resolution.
Something like
CL-USER> (require :abcl-asdf)
CL-USER> (abcl-asdf:resolve-dependencies "org.slf4j" "slf4j-api" "1.6.1")
should download the required dependencies for the corresponding Maven
artifact, returning the result as a string suitable for inclusion in
the CLASSPATH.
Abandoned strategy of using Maven Ant tasks to directly maniuplating
the Aether API in contemporary version of Maven 3.
Remove MVN package, folding symbols into ABCL-ASDF until clearer API
vision is in place as there is no need to complicate things at this
point.
The ASDF links are not currently working, nor is the ability to find
the Maven location under WIN32 as the resolution mechanism currently
uses UNIX 'which'.
Modified:
trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp
trunk/abcl/contrib/abcl-asdf/maven-embedder.lisp
Modified: trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp
==============================================================================
--- trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp Wed Jun 29 08:34:58 2011 (r13366)
+++ trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp Wed Jun 29 08:35:07 2011 (r13367)
@@ -1,95 +1,44 @@
(defpackage #:abcl-asdf
(:use :cl)
- (:export #:package))
+ (:export
+ #:satisfy
+ #:as-classpath
-
-(defpackage #:mvn
- (:use :cl)
- (:export #:satisfy
- #:as-classpath))
+ #:resolve-artifact
+ #:resolve-dependencies))
(in-package :asdf)
-(defclass iri (static-class) ())
+(defclass iri (static-class)
+ (schema authority path query fragment))
(defclass mvn (iri) ())
;;; We interpret compilation to ensure that load-op will succeed
(defmethod perform ((op compile-op) (c mvn))
(let ((version (component-version c)))
- (mvn:satisfy (component-name c)
- :version (if version version :latest))))
+ (abcl-asdf:satisfy (component-name c)
+ :version (if version version :latest))))
(defmethod perform ((operation load-op) (c mvn))
(let ((version (component-version c)))
(java:add-to-classpath
- (mvn:as-classpath
- (mvn:satisfy (component-name c)
+ (abcl-asdf:as-classpath
+ (abcl-asdf:satisfy (component-name c)
:version (if version version :latest))))))
-(in-package :abcl-asdf)
-
-(defun decompose (iri)
- (declare (ignore iri))
- ;;; XXX test
- `((:scheme :jvm)
- (:authority :mvn)
- (:host "log4j")
- (:version "1.4.10")))
-
-(in-package :mvn)
-
-(defparameter *maven-ant-tasks.jar*
- "/export/home/evenson/src/apache-maven-3.0.3/maven-ant-tasks-2.1.1.jar")
-
-#|
-
-Ant with Maven tasks would add the following
-
- <artifact:dependencies pathId="abcl.dynamic.classpath">
- <dependency groupId="junit" artifactId="junit" version="3.8.2"/>
- </artifact:dependencies>
-|#
-
-(defvar *ant-build-template*
- (format nil
- "<?xml version='1.0' encoding='UTF-8'?>
-<project xmlns='antlib:org.apache.tools.ant'
- xmlns:artifact='antlib:org.apache.maven.artifact.ant'
- name='abcl-mvn-~A' default='install'>
-
- <artifact:dependencies pathId='abcl.dynamic.classpath'>
- <dependency groupId='~A' artifactId='~A' version='~A'/>
- </artifact:dependencies>
-
- <path id='abcl.jar'>
- <pathelement location='/export/home/evenson/work/abcl/dist/abcl.jar'/>
- </path>
-
- <target name='install'>
- <java classname='org.armedbear.lisp.Main'>
- <classpath refid='abcl.jar'>
- <classpath refid='abcl.dynamic.classpath'>
- </java>
- </target>
-</project>
-" (symbol-name (gensym)) "junit" "junit" "3.8.2"))
+(in-package #:abcl-asdf)
(defun satisfy (name &key (version :latest))
- (declare (ignore name version))
- (let ((build.xml (ext:make-temp-file)))
- (with-open-file (s build.xml :direction :output)
- (write-string *ant-build-template* s ))
- (ext:run-program
- (format nil "ant -find ~A -lib ~A"
- build.xml
- *maven-ant-tasks.jar*))))
-
-(defun as-classpath (mvn)
+ (declare (ignore version))
+ (resolve-dependencies name))
+
+(defun as-classpath (classpath)
"For a given MVN entry, return a list of loadable archives
suitable for addition to the classpath."
- (declare (ignore mvn))
- (error "unimplemented"))
-
-
-
+ (split-string classpath ":"))
+(defun split-string (string split-char)
+ (loop :for i = 0 :then (1+ j)
+ :as j = (position split-char string :test #'string-equal :start i)
+ :collect (subseq string i j)
+ :while j))
\ No newline at end of file
Modified: trunk/abcl/contrib/abcl-asdf/maven-embedder.lisp
==============================================================================
--- trunk/abcl/contrib/abcl-asdf/maven-embedder.lisp Wed Jun 29 08:34:58 2011 (r13366)
+++ trunk/abcl/contrib/abcl-asdf/maven-embedder.lisp Wed Jun 29 08:35:07 2011 (r13367)
@@ -11,11 +11,13 @@
#|
Test:
+(resolve-dependencies "org.slf4j" "slf4j-api" "1.6.1")
-(resolve "org.slf4j" "slf4j-api" "1.6.1")
+(resolve-dependencies "org.apache.maven" "maven-aether-provider" "3.0.3")
|#
-(defvar *mavens* '("/opt/local/bin/mvn3" "mvn3" "mvn"))
+(defvar *mavens* '("/opt/local/bin/mvn3" "mvn3" "mvn" "mvn.bat")
+ "Locations to search for the Maven executable.")
(defun find-mvn ()
(dolist (mvn-path *mavens*)
@@ -82,37 +84,43 @@
(jss:add-directory-jars-to-class-path *mvn-libs-directory* nil)
(setf *init* t))
+(defun make-wagon-provider ()
+ (unless *init* (init))
+ (java:jinterface-implementation
+ "org.sonatype.aether.connector.wagon.WagonProvider"
+ "lookup"
+ (lambda (role-hint)
+ (if (string-equal "http" role-hint)
+ (java:jnew "org.apache.maven.wagon.providers.http.LightweightHttpWagon")
+ java:+null+))
+ "release"
+ (lambda (wagon)
+ (declare (ignore wagon)))))
+
(defun repository-system ()
(unless *init* (init))
(let ((locator
(java:jnew "org.apache.maven.repository.internal.DefaultServiceLocator"))
- (wagon-class
- (java:jclass "org.sonatype.aether.connector.wagon.WagonProvider"))
- (wagon-provider
- (jss:find-java-class "LightweightHttpWagon"))
- (repository-connector-factory-class
- (java:jclass "org.sonatype.aether.connector.wagon.WagonRepositoryConnector"))
+ (repository-connector-factory-class
+ (java:jclass "org.sonatype.aether.spi.connector.RepositoryConnectorFactory"))
(wagon-repository-connector-factory-class
(java:jclass "org.sonatype.aether.connector.wagon.WagonRepositoryConnectorFactory"))
+ (wagon-provider-class
+ (java:jclass "org.sonatype.aether.connector.wagon.WagonProvider"))
(repository-system-class
(java:jclass "org.sonatype.aether.RepositorySystem")))
- (#"setService" locator wagon-class wagon-provider)
- (#"addService" locator
- repository-connector-factory-class
+ (#"addService" locator
+ repository-connector-factory-class
wagon-repository-connector-factory-class)
- (#"getService" locator repository-system-class)))
-
-#|
-private static RepositorySystem newRepositorySystem()
-{
- DefaultServiceLocator locator = new DefaultServiceLocator();
- locator.setServices( WagonProvider.class, new ManualWagonProvider() );
- locator.addService( RepositoryConnectorFactory.class, WagonRepositoryConnectorFactory.class );
-
- return locator.getService( RepositorySystem.class );
-}
-|#
-
+ (#"setServices" locator
+ wagon-provider-class
+ (java:jnew-array-from-list
+ "org.sonatype.aether.connector.wagon.WagonProvider"
+ (list
+ (make-wagon-provider))))
+ (#"getService" locator
+ repository-system-class)))
+
(defun new-session (repository-system)
(let ((session
(java:jnew (jss:find-java-class "MavenRepositorySystemSession")))
@@ -124,19 +132,25 @@
session
(#"newLocalRepositoryManager" repository-system local-repository))))
-#|
-private static RepositorySystemSession newSession( RepositorySystem system )
-{
- MavenRepositorySystemSession session = new MavenRepositorySystemSession();
-
- LocalRepository localRepo = new LocalRepository( "target/local-repo" );
- session.setLocalRepositoryManager( system.newLocalRepositoryManager( localRepo ) );
-
- return session;
-}
-|#
+(defun resolve-artifact (group-id artifact-id version)
+ (let* ((system
+ (repository-system))
+ (session
+ (new-session system))
+ (repository
+ (jss:new "org.sonatype.aether.repository.RemoteRepository"
+ "central" "default" "http://repo1.maven.org/maven2/"))
+ (artifact-string (format nil "~A:~A:~A"
+ group-id artifact-id version))
+ (artifact
+ (jss:new "org.sonatype.aether.util.artifact.DefaultArtifact" artifact-string))
+ (artifact-request
+ (java:jnew "org.sonatype.aether.resolution.ArtifactRequest")))
+ (#"setArtifact" artifact-request artifact)
+ (#"addRepository" artifact-request repository)
+ (#"resolveArtifact" system session artifact-request)))
-(defun resolve (group-id artifact-id version)
+(defun resolve-dependencies (group-id artifact-id version)
(unless *init* (init))
(let* ((system
(repository-system))
@@ -151,8 +165,7 @@
artifact "compile"))
(central
(java:jnew (jss:find-java-class "RemoteRepository")
- "central" "default"
- "http://repo1.maven.org/maven2/"))
+ "central" "default" "http://repo1.maven.org/maven2/"))
(collect-request (java:jnew (jss:find-java-class "CollectRequest"))))
(#"setRoot" collect-request dependency)
(#"addRepository" collect-request central)
@@ -167,30 +180,8 @@
(#"accept" node nlg)
(#"getClassPath" nlg))))
-#|
-public static void main( String[] args )
- throws Exception
-{
- RepositorySystem repoSystem = newRepositorySystem();
-
- RepositorySystemSession session = newSession( repoSystem );
-
- Dependency dependency =
- new Dependency( new DefaultArtifact( "org.apache.maven:maven-profile:2.2.1" ), "compile" );
- RemoteRepository central = new RemoteRepository( "central", "default", "http://repo1.maven.org/maven2/" );
-
- CollectRequest collectRequest = new CollectRequest();
- collectRequest.setRoot( dependency );
- collectRequest.addRepository( central );
- DependencyNode node = repoSystem.collectDependencies( session, collectRequest ).getRoot();
-
- DependencyRequest dependencyRequest = new DependencyRequest( node, null );
-
- repoSystem.resolveDependencies( session, dependencyRequest );
-
- PreorderNodeListGenerator nlg = new PreorderNodeListGenerator();
- node.accept( nlg );
- System.out.println( nlg.getClassPath() );
-}
-|#
+
+
+
+
More information about the armedbear-cvs
mailing list