(use-modules (guix) (guix build-system ant) (guix licenses) (gnu packages base) (gnu packages java) (gnu packages zip) ) (define* (apache-commons-url projname version #:optional (basename (string-append "commons-" projname))) (string-append "https://archive.apache.org/dist/commons/" projname "/source/" basename "-" version "-src.tar.gz")) ; todo: how to use these as a phase, like ; (replace 'install install-jars) ; (add-after 'build build-javadoc) (define* (symlink-junit-jar #:key outputs #:allow-other-keys) ; Put a symlink to the acutal junit.jar into lib/jsunit-VERSION.jar (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")))) (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) ; build command for calling the ant task "javadoc" (zero? (apply system* `("ant" "javadoc" ,@make-flags)))) (define* (install-javadoc #:key outputs #:allow-other-keys) ; build command for installing the javs docs into ; DOC/share/doc/NAME-VERSION (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 (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 ;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$"))))) (add-after 'install 'install-doc ;install-javadoc) (lambda* (#:key outputs #:allow-other-keys) ; (`install-javadoc outputs ,name ,version) (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) )) java-commons-io