Hi! Hartmut Goebel <h.goe...@goebel-consult.de> skribis:
> while packaging some java apache common packages, I found myself adding > some build steps over and over again, like this one: > > (replace 'install > (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$"))))) > > Now I tried replacing this by a simple line like > > (add-after 'install 'install-javadocs install-javadocs) > > and of course some function: > > (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) > )) Note that the commas here (aka. “unquote”) mean that this expression must be enclosed in a ` (aka. “quasiquote”). See <https://www.gnu.org/software/guile/manual/html_node/Expression-Syntax.html#Expression-Syntax>. > I did not manage this - not even if not using "name" and "version" and > not using any function parameters. > > What is the correct code? Like David, I would suggest creating a build-side module, say, (guix build java-utils), or maybe augmenting (guix build ant-build-system), and putting ‘install-javadoc’ in there (Ricardo?). The code in there will not be in a quasiquote context, so you won’t be able to use “,name” and “,version” to get at the package name and version. Instead, you could use ‘package-name->name+version’ from (guix build utils): (define* (install-javadoc #:key outputs …) (let ((out (assoc-ref outputs "out"))) (call-with-values (lambda () (package-name->name+version (strip-store-file-name out))) (lambda (name version) …)))) HTH! Ludo’.