Skip to content

Document how to use duct with tools.deps #92

@RickMoynihan

Description

@RickMoynihan

I've just ported a duct project to work with tools.deps, and I've worked around some of the issues that come up.

Below are some notes on the issues and those which I have found solutions for. At some point they may be a useful basis for forming some documentation on the subject, or perhaps changing the duct project templates themselves.

The main issue I encountered is how to generate duct uberjars. With lein duct requires the addition of the lein-duct plugin to ensure that duct_hierarchy.edn files from dependencies are merged together into a single duct_hierarchy.edn at the top of the root of the classpath. The main reason this is necessary is because the lein uberjar process flattens all jars into one classpath root. It's worth noting that this is not what typically happens at a REPL. At a REPL the classpath is typically composed of your dependency jars, so the files are indepedently addressable via the classloader's getResources which returns all matches for a given file on the classpath appropriately disambiguated by their jar/classloader. duct.core correctly iterates over this which means providing you don't destroy this context in your uberjar step, you shouldn't need a plugin to handle merge conflicts (lein uses :uberjar-merge-with).

So how can you generate uberjars without destroying that context, and do so from tools.deps? The answer is pack.alpha and specifically their support for creating capsule uberjars. Essentially Capsule provides us a way to package an uberjar of jars instead of a munged uberjar of classes; capsule then transparently manages the extraction process and the rebuilding of the classpath. The upshot is that your uberjar is then a much more similar environment to your repl, and duct will naturally handle the resolution of duct_hierarchy.edn itself.

The only other thing I know duct does that I have not yet looked at, is :aot compiling the dependencies specified in your duct system by calling :duct/compile. I expect for those that require this, it should be relatively easy to add.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions