Changeset 13364


Ignore:
Timestamp:
06/27/11 10:23:32 (10 years ago)
Author:
Mark Evenson
Message:

Use java.util.regex to deal with versions more cleanly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/contrib/abcl-asdf/maven-embedder.lisp

    r13362 r13364  
    2424               (truename (read-line (sys::process-output
    2525                                     (sys::run-program "which" `(,mvn-path)))))
    26              ('end-of-file ()
    27                nil))))
     26             (end-of-file () nil))))
    2827      (when mvn
    2928        (return-from find-mvn mvn)))))
     
    4342
    4443(defun mvn-version ()
    45   (let ((line
    46          (read-line (sys::process-output (sys::run-program
    47                                           (namestring (find-mvn)) '("-version")))))
    48         (prefix "Apache Maven "))
     44  (let* ((line
     45         (read-line (sys::process-output
     46                     (sys::run-program
     47                      (namestring (find-mvn)) '("-version")))))
     48         (pattern (#"compile"
     49                   'regex.Pattern
     50                   "Apache Maven ([0-9]+)\\.([0-9]+)\\.([0-9]+)"))
     51         (matcher (#"matcher" pattern line))
     52         (found (#"find" matcher)))
     53    (unless found
     54      (return-from mvn-version nil))
     55    (mapcar #'parse-integer
     56            `(,(#"group" matcher 1)
     57              ,(#"group" matcher 2)
     58              ,(#"group" matcher 3)))))
    4959
    50     (unless (eql (search prefix line) 0)
    51       (return-from mvn-version nil))
    52     (let ((version (subseq line (length prefix))))
    53       version)))
    54 
    55 ;;; XXX will break with release of Maven 3.1.x
    5660(defun ensure-mvn-version ()
    5761  "Return t if Maven version is 3.0.3 or greater."
    58   (let ((version-string (mvn-version)))
    59     (and (search "3.0" version-string)
    60          (>= (parse-integer (subseq version-string
    61                                     4 (search " (" version-string)))
    62              3))))
     62  (let* ((version (mvn-version))
     63         (major (first version))
     64         (minor (second version))
     65         (patch (third version)))
     66    (or
     67     (and (>= major 3)
     68          (>= minor 1))
     69     (and (>= major 3)
     70          (>= major 0)
     71          (>= patch 3)))))
    6372
    6473(defparameter *init* nil)
Note: See TracChangeset for help on using the changeset viewer.