Packaged clojure.data.xml, more improvements on lein_makepkg, major refactor coming soon

Today was a very productive day. I managed to pack clojure.data.xml without too much hassle, a very interesting package since it doesn’t use leiningen and not all the source has to be bundled into the package. I think clojure.data.xml has been the most fun library I’ve had the chance to play so far; my other two packages, stencil and quoin, were very straightforward: Download the souce code, use our semi-standard rules file (or use clojurehelper –javahelper), fix a few more things and voilĂ , a fresh deb file ready to be installed. clojure.data.xml has a few interesting things:

  • comes with a changes file that we don’t need but process by default (package.docs)
  • has an src directory that includes tests
  • the tags changed over time in github which made it a little more difficult to write a watchfile

Ignoring CHANGES.md wasn’t much of an issue since changing the .docs file and only listing README.md was everything I needed. When I initially packaged clojure.data.xml I realized lein xml would complain because /clojure/data/xml.clj was not being found in the classpath. This was all due to the fact that src had a weird structure when I downloaded it from upstream. It included the tests and the data under the same folder (src) and our rules file automatically grabs the src and makes a jar out of it. The result was a jar file which contained the code and the tests under the same root directory:

`-- src
    |-- main
    |   `-- clojure
    |       `-- clojure
    |           `-- data
    |               `-- xml.clj
    `-- test
        `-- clojure
            `-- clojure
                `-- data
                    `-- xml
                        |-- test_emit.clj
                        |-- test_parse.clj
                        |-- test_seq_tree.clj
                        |-- test_sexp.clj
                        `-- test_utils.clj

Not what we want. The answer was to change the jar command on the rules file to make it read only from src/main/clojure/ resulting in a clojure/data/xml.clj structure.

The biggest change in lein_makepkg was to use configparser to read options from ~/.clojurehelper.conf. I had to read a lot about it in order to understand how it worked; as usual I had to spend some time fixing newbie mistakes. The tests now ignore the config file by default unless the ignore_configfile class variable is set to False manually. The strategy is to merge the options read from commandline into the configuration file properties. Also fixed a few other things suck as pep8 and python 3 compatibility.

Tomorrow I’ll work on a major refactor that must be done in lein_makepkg. I’m beginning to see how the current structure is getting less flexible and with every change I make I have to think on whether it will break something else. Thanks to the tests I detect when breaking happens but not always so I think is also time to improve the tests.

One thought on “Packaged clojure.data.xml, more improvements on lein_makepkg, major refactor coming soon

  1. Pingback: New components, hopefully for the best | eugecm

Leave a comment