GitXplorerGitXplorer
h

shade

public
5 stars
2 forks
0 issues

Commits

List of commits on branch main.
Unverified
45e9a57ee7c42dd8e9794e7559ee5aca28dcf576

Add install-shaded-jar task

committed 8 years ago
Unverified
829772b604397249473d2ff461fccee0f4eb231b

Work around incorrect handling of $ in patterns by maven-shade-plugin

committed 8 years ago
Unverified
6d301f661695aa13ab1fd3333e341502c458bfd8

Fix handling of loader and function classes in the top-level namespace

committed 8 years ago
Unverified
146816c5d0f558b5a68afdee1d133617ba7597a3

Release 0.2.0

committed 8 years ago
Unverified
2e594b3552b72c64a572134a4b89ad854113881b

Fix accidental shading of packages with prefixes in common

committed 8 years ago
Unverified
f53a9c4f84c295791846c6b50f35e87f4547a551

Release 0.1.0

committed 8 years ago

README

The README file for this repository.

shade

shade is a tool for relocating namespaces within uberjars to avoid dependency clashes.

Motivation

Test helper libraries' dependencies are liable to clash with those of the code under test. To avoid this, the helper library can be distributed as an uberjar with its dependencies "shaded" under a different namespace.

Installation

The easiest way to get started is to add the lein-shade plugin to your Leiningen project map:

:plugins [[lein-shade "0.4.0"]]

Usage

As is typical when building an uberjar, you'll need to use AOT compilation:

:profiles {...
           :uberjar {:aot :all}
           ...}

Unlike when building an application uberjar, you probably don't want to bundle Clojure itself. You can omit it by moving the dependency to the :provided profile:

:profiles {...
           :provided {:dependencies [[org.clojure/clojure "1.8.0"]
                                     ...]}
           ...}

You'll want to omit dependencies that are bundled in the uberjar from the POM, otherwise consumers of your library will download them as transitive dependencies. To do so, move your dependencies to the :shaded profile, and add :shaded to your :default profile:

:profiles {...
           :shaded {:dependencies [...]}
           :default [:leiningen/default :shaded]
           ...}

If you run lein shade-jar now, you'll get an uberjar under target/shaded. However, the namespaces within your dependencies won't have been relocated, so version clashes will still be problematic. To relocate those namespaces, you need to specify them in your project map:

:shade {:namespaces [foo.bar
                     ...]}

Now when you run lein shade-jar, those namespaces will have been hidden under the your-project.shaded namespace in the uberjar (so foo.bar is now your-project.shaded.foo.bar).

You can customize where shaded dependencies are hidden if you want:

:shade {:namespaces [...]
        :under my-project.hidden}

Deploying shaded uberjars

You can deploy your shaded uberjar using lein deploy-shaded-jar [repository]. You might want to alias the deploy task:

:aliases {...
          "deploy" ["deploy-shaded-jar" "clojars"]
          ...}

You can also install your shaded uberjar to your local repository using lein install-shaded-jar. Similarly, you might want to alias the install task:

:aliases {...
          "install" ["install-shaded-jar"]
          ...}

License

Copyright © 2017 Red Badger

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.