GitXplorerGitXplorer
h

shade

public
5 stars
2 forks
0 issues

Commits

List of commits on branch main.
Verified
846b24d4a0e8d6d304cf97e0001e564ac6b9a805

Release 0.4.0

hhaines committed 4 years ago
Verified
ea9f16ff48aeed1f96af76aefd35ef68a41a668b

Add changelog entry for #1

hhaines committed 4 years ago
Verified
3f4fe312aed752baca44b80411d0f58357354960

Update GitHub repository links

hhaines committed 4 years ago
Verified
503160a3a58936303976dec40ba8c3bbc5dfbf53

Merge pull request #1 from emlyn/update

hhaines committed 4 years ago
Unverified
a642fffa19a3a3eb38f85f9d313a7db3cce925a6

update maven shade plugin

eemlyn committed 4 years ago
Unverified
ff993e822384a0fcd18a5243694f8ed0082d4c90

Release 0.3.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.