Quantcast
Viewing latest article 4
Browse Latest Browse All 13

(conj project libraries)

Well, adding dependencies to the project went smoother than I thought.

Adding the necessary libraries to the :dependencies vector in project.clj was nearly all I had to do. Leiningen automatically finds all Clojure namespaces on the classpath and compiles them. Though there were a few things I had to resolve:
  • DEX and APK packaging utilities really don't like being fed with the same jars. Same jars are the same regardless of their version - so packaging both Clojure 1.2.1 and Clojure 1.4.0 is impossible. Since each Clojure dependency library has its own dependencies so the Leiningen's dependency list fills up with different versions of the same jars. Currently I filter them out with a function that classifies these jars by their location in the ~/.m2/ folder (it looks like ~/.m2/repository/groupId/library-name/version/jarname.jar). And I agree that it is a bad BAD BAD solution. A much better option would be to process the POM-file that is stored in the same folder with this jar but that's not the safest you can get. The best thing to do I think is to extract the POM from the jar itself and then process it.
  • APK requires clojure.jar being packed as sources as well as binaries. I don't yet fully understand why it does this but after the discovery I decided that I should pack all dependencies as sources (unique ones, of course). There was the fun part: APK took project.clj-s from different libraries and said: "Nah, duplicate files, won't do". I was almost ready (psychologically) to reinvent another wheel when it turned out that source reference for libraries is not necessary. Phew.
So I may now say that I made it possible to run nREPL on the device by means of Leiningen. But that was the easy part.

The harder part is to provide all the tasks to be used conveniently. Right now my complete build line looks like this:
 lein droid cpl, droid dex, droid crunch, droid package, droid apk, droid sign, droid zip, droid install, droid run  
Can't say I've got huge problems executing it (shell history works, after all) but it is still a bit ugly. It gets even worse if you want to release your project - I thought I'd rely on Lein 2 profiles which are merged using `with-profile` task. Which affects only the command before comma. In other words, to release the thing I would have to type something like:
 lein with-profile release droid cpl, droid with-profile release droid dex, ...
Which is, of course, pure horror.

It can be easily solved by adding something like `doall` subtask (which I've already done). But it doesn't quite feel "the leiningen way" where all tasks do more or less only one thing. And I surely don't want to reimplement Leiningen's subtasks model and handle all comma-separated commands myself.

This difficult dilemma concludes my post for today. If anyone have an idea of how to do this better, please feel free to leave a note in the comments. Thank you.

Viewing latest article 4
Browse Latest Browse All 13

Trending Articles