Am 02.09.2016 um 09:47 schrieb Ricardo Wurmus:
> This should not be on the CLASSPATH.  The “ant-build-system” sets
> CLASSPATH to the result of running “generate-classpath” on all inputs.
> Currently, all this does it add any and all “.jar” files to the
> CLASSPATH.  To keep “jar” itself out, the regular expression should be
> changed from
>
>    (find-files dir "\\.*jar$")
>
> to something like
>
>    (find-files dir "\\.jar$")

Thanks for this tip, it helped. (Will submit a patch later)

Meantime I managed to build commons-io, commons-cli, commons-lang and
commons-codec.

I found all of these need intervention for building, as there is no
"install" target (maybe I missed something). Echo of the packages
behaves a bit different (e.g. different directory names), while sharing
some common patterns. I'll attach my WIP for your convenience.

I failed building commons-logging, which requires e.g. javax.servelet,
the avalon-frameweork and much more.


-- 
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
Information Security Management, Security Governance, Secure Software
Development

Goebel Consult, Landshut
http://www.goebel-consult.de

Blog:
http://www.goebel-consult.de/blog/warum-sie-nicht-perl-programmiern-sollten
Kolumne:
http://www.cissp-gefluester.de/2011-08-horrorszenario-bring-your-own-device

(use-modules (guix)
             (guix build-system ant)
             (guix licenses)
(gnu packages base)
(gnu packages java))


(define (apache-commons-url projname version)
  ; todo: add option for passing the archive basename (default: projname)
  (let ((basename projname))
    (string-append
     "https://archive.apache.org/dist/commons/"; projname "/source/"
     "commons-" basename "-" version "-src.tar.gz")))

; todo: how to use these as a phase, like
;  (replace 'install install-jars)
;  (add-after 'build build-javadoc)

(define* (install-jars #:key outputs #:allow-other-keys)
  (let ((share (string-append (assoc-ref outputs "out")
                              "/share/java")))
    (for-each (λ (f) (install-file f share))
              (find-files "." "\\.jar2$"))))

(define* (build-javadoc #:key (make-flags '()) #:allow-other-keys)
  (zero? (apply system* `("ant" "javadoc" ,@make-flags))))

;(define* (install-javadoc #:key outputs #:allow-other-keys)
;  (let ((docs (string-append (assoc-ref outputs "doc")
;                             "/share/doc/" ,name "-" ,version "/")))
;    (mkdir-p docs)
;    (copy-recursively "target/apidocs" docs)
;    ))

;(define-public java-commons-io-2.5
  (package
    (name "java-commons-io")
    (version "2.5")
    (source (origin
      (method url-fetch)
      (uri (apache-commons-url "io" version))
      (sha256 (base32 "0q5y41jrcjvx9hzs47x5kdhnasdy6rm4bzqd2jxl02w717m7a7v3"))))
    (build-system ant-build-system)
    (outputs '("out" "doc"))
    (arguments
     `(#:test-target "test"
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'symlink-junit.jar
           (lambda* (#:key inputs #:allow-other-keys)
             (let ((junit (assoc-ref inputs "java-junit"))
                   (junit-version "4.12")) ; from build.xml
               (mkdir-p "lib")
               (symlink (string-append junit "/share/java/junit.jar")
                        (string-append "lib/junit-" junit-version ".jar")))
             ))

         (add-after 'build 'build-javadoc ;build-javadoc)
           (lambda* (#:key (make-flags '()) #:allow-other-keys)
             (zero? (apply system* `("ant" "javadoc" ,@make-flags)))))
         (replace 'install ;install-jars)
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((share (string-append (assoc-ref outputs "out") 
                                         "/share/java")))
               (for-each (λ (f) (install-file f share))
                         (find-files "target" "\\.jar$")))))
         ; todo: install poms for maven
         (add-after 'install 'install-doc ;install-javadoc)
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((docs (string-append (assoc-ref outputs "doc")
                                        "/share/doc/" ,name "-" ,version "/")))
               (mkdir-p docs)
               (copy-recursively "target/apidocs" docs)
               )))

)))
    (native-inputs
     `(("java-junit" ,java-junit)
       ("(java-hamcrest-core" ,java-hamcrest-core)))
    (home-page "http://commons.apache.org/io/";)
    (synopsis "Common useful IO related classes")
    (description "Commons-IO contains utility classes, stream implementations,
file filters and endian classes.")
    (license asl2.0)
);)

;(define-public java-commons-cli-2.5
  (package
    (name "java-commons-cli")
    (version "1.3.1")
    (source (origin
      (method url-fetch)
      (uri (apache-commons-url "cli" version))
      (sha256 (base32 "1fkjn552i12vp3xxk21ws4p70fi0lyjm004vzxsdaz7gdpgyxxyl"))))
    (build-system ant-build-system)
    ; todo: javadoc
    (arguments
     ; commons-cli does not provida a proper build.xml but seems to require
     ; maven for building
     `(#:jar-name (string-append "commons-cli-" ,version ".jar")
       #:phases
       (modify-phases %standard-phases
         ; todo: install poms for maven
         (delete 'check))))
    (native-inputs
     `(("java-junit" ,java-junit)))
    (home-page "http://commons.apache.org/cli/";)
    (synopsis "parsing command line options")
    (description "Commons-CLI library provides an API for parsing command line
options passed to programs.  It's also able to print help messages detailing
the options available for a command line tool.")
    (license asl2.0)
);)

(package
    (name "java-commons-codec")
    (version "1.10")
    (source (origin
      (method url-fetch)
      (uri (apache-commons-url "codec" version))
      (sha256 (base32 "1w9qg30y4s0x8gnmr2fgj4lyplfn788jqxbcz27lf5kbr6n8xr65"))))
    (build-system ant-build-system)
    (outputs '("out" "doc"))
    (arguments
     ; commons-cli does not provida a proper build.xml but seems to require
     ; maven for building
     `(#:test-target "test"
       #:phases
       (modify-phases %standard-phases
         (delete 'check)
         (add-after 'build 'build-javadoc ;build-javadoc)
           (lambda* (#:key (make-flags '()) #:allow-other-keys)
             (zero? (apply system* `("ant" "javadoc" ,@make-flags)))))
         (replace 'install ;install-jars)
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((share (string-append (assoc-ref outputs "out") 
                                         "/share/java")))
               (for-each (λ (f) (install-file f share))
                         (find-files "dist" "\\.jar$")))))
         ; todo: install poms for maven
         (add-after 'install 'install-doc ;install-javadoc)
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((docs (string-append (assoc-ref outputs "doc")
                                        "/share/doc/" ,name "-" ,version "/")))
               (mkdir-p docs)
               (copy-recursively "dist/docs/api" docs)
               )))
)))
    (native-inputs
     `(("java-junit" ,java-junit)))
    (home-page "http://commons.apache.org/codec/";)
    (synopsis "Common encoders and decoders such as Base64, Hex, Phonetic and 
URLs")
    (description "")
    (license asl2.0)
);)



;(define-public java-commons-lang-2.6
  (package
    (name "java-commons-lang")
    ; note: current release is lang3-3.4 (mind the different archive name)
    (version "2.6")
    (source (origin
      (method url-fetch)
      (uri (apache-commons-url "lang" version))
      (sha256 (base32 "1mxwagqadzx1b2al7i0z1v0r235aj2njdyijf02szq0vhmqrfiq5"))))
    (build-system ant-build-system)
    (outputs '("out" "doc"))
    (arguments
     `(#:test-target "test"
       #:phases
       (modify-phases %standard-phases
         (delete 'check) ; todo: make tests work
         (add-after 'unpack 'symlink-junit.jar
           (lambda* (#:key inputs #:allow-other-keys)
             (let ((junit (assoc-ref inputs "java-junit"))
                   (junit-version "4.12")) ; from build.xml
               (mkdir-p "lib")
               (symlink (string-append junit "/share/java/junit.jar")
                        (string-append "lib/junit-" junit-version ".jar")))
             ))
         (add-before 'check 'set-tzdir
           (lambda* (#:key inputs #:allow-other-keys)
             (setenv "TZDIR"
                     (string-append (assoc-ref inputs "tzdata")
                                    "/share/zoneinfo"))
             #t))
         (add-after 'build 'build-javadoc ;build-javadoc)
           (lambda* (#:key (make-flags '()) #:allow-other-keys)
             (zero? (apply system* `("ant" "javadoc" ,@make-flags)))))
         (replace 'install ;install-jars)
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((share (string-append (assoc-ref outputs "out") 
                                         "/share/java")))
               (for-each (λ (f) (install-file f share))
                         (find-files "target" "\\.jar$")))))
         ; todo: install poms for maven
         (add-after 'install 'install-doc ;install-javadoc)
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((docs (string-append (assoc-ref outputs "doc")
                                        "/share/doc/" ,name "-" ,version "/")))
               (mkdir-p docs)
               (copy-recursively "target/apidocs" docs)
               )))

)))
    (native-inputs
     `(("java-junit" ,java-junit)
       ; The test-suite tests some timezone dependant functions,
       ; thus tzdata needs to be installed.
       ("tzdata", tzdata)
       ;("(java-hamcrest-core" ,java-hamcrest-core)
))
    (home-page "http://commons.apache.org/lang/";)
    (synopsis "Common useful IO related classes")
    (description "Commons-IO contains utility classes, stream implementations,
file filters and endian classes.")
    (license asl2.0)
);)



;(define-public java-commons-logging-2.6
  (package
    (name "java-commons-logging")
    (version "1.2")
    (source (origin
      (method url-fetch)
      (uri (apache-commons-url "logging" version))
      (sha256 (base32 "10bwcy5w8d7y39n0krlwhnp8ds3kj5zhmzj0zxnkw0qdlsjmsrj9"))))
    (build-system ant-build-system)
    (outputs '("out" "doc"))
    (arguments
     `(#:test-target "test"
       #:build-target "compile"
       #:phases
       (modify-phases %standard-phases
         (delete 'check) ; todo: make tests work
         (add-after 'unpack 'symlink-junit.jar
           (lambda* (#:key inputs #:allow-other-keys)
             (let ((junit (assoc-ref inputs "java-junit"))
                   (junit-version "4.12")) ; from build.xml
               (mkdir-p "lib")
               (symlink (string-append junit "/share/java/junit.jar")
                        (string-append "lib/junit-" junit-version ".jar")))
             ))
         (add-after 'build 'build-javadoc ;build-javadoc)
           (lambda* (#:key (make-flags '()) #:allow-other-keys)
             (zero? (apply system* `("ant" "javadoc" ,@make-flags)))))
         (replace 'install ;install-jars)
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((share (string-append (assoc-ref outputs "out") 
                                         "/share/java")))
               (for-each (λ (f) (install-file f share))
                         (find-files "target" "\\.jar$")))))
         ; todo: install poms for maven
         (add-after 'install 'install-doc ;install-javadoc)
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((docs (string-append (assoc-ref outputs "doc")
                                        "/share/doc/" ,name "-" ,version "/")))
               (mkdir-p docs)
               (copy-recursively "target/apidocs" docs)
               )))

)))
    (native-inputs
     `(("java-junit" ,java-junit)
       ;avalon,
       ;("(java-hamcrest-core" ,java-hamcrest-core)
))
    (home-page "http://commons.apache.org/logging/";)
    (synopsis "Common useful IO related classes")
    (description "Commons-IO contains utility classes, stream implementations,
file filters and endian classes.")
    (license asl2.0)
);)

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to