zcaudate-me/lein-repack

Allow customization of generated project.clj files

jeroenvandijk opened this issue · 11 comments

I have a (private) project with a high level of nesting of namespaces (E.g. my-company.product-type.functionality).

I have a configuration like this:

:repack {
 :root my-company
 :exclude [] 
 :levels 3}

When I look at the project.clj files in the interim dir after lein repack split I see project definitions with names like:

my-company.product-type.functionality.product-type.functionality.a

I would like to customize this to something like

my-company/product-type.functionality.a

I tried some hacking in project.clj, but I think this is only possible by changing some internals of lein-repack.

Hi Jeroen,

You're right. I've actually got the same problem in my day to day job. Let me have a think about this feature and get back to you :)

Chris.

On 7 Jul 2014, at 23:27, Jeroen van Dijk notifications@github.com wrote:

I have a (private) project with a high level of nesting of namespaces (E.g. my-company.product-type.functionality).

I have a configuration like this:

:repack {
:root my-company
:exclude []
:levels 3}
When I look at the project.clj files in the interim dir after lein repack split I see project definitions with names like:

my-company.product-type.functionality.product-type.functionality.a
I would like to customize this to something like

my-company/product-type.functionality.a
I tried some hacking in project.clj, but I think this is only possible by changing some internals of lein-repack.


Reply to this email directly or view it on GitHub.

Hi Chris,

I had a thought about it as well. I think the main power of lein-repack is to sort out the dependencies of the sub projects and make a first division. Since there a probably other customizations required in other contexts, maybe it makes sense to have an extra configuration option for repack, a function, that can be used to manipulate the sub project.clj edn and will be called just before writing the intermediaries. Does this make sense?

Cheers,
Jeroen

Hey Jeroen,

I don't think it's too difficult to add in the extra bit of functionality. Though there may be some corner cases that are a little tricky. I'm just a little bit swamped at the moment with other things. Unless i am mistaken, The logic should be isolated to manifest and split.

Would you be able to give a example of what you would want to write under the :repack key in project.clj for your project - and that'll give us an example to work off.

Hi Chris,

I've created a pull request to show you what I need. It's not super clean, but it would work for me

Thanks mate =)

Will have a play today with these changes

hmm... with the current version that I pulled from, it seems like all the files are still in the same directory when I run lein repack split. is this the intended behaviour right now?

Sorry! my fault.. I changed something

Can you confirm that I'm getting the same results. So right now the split namespace looks like this:
im.chit/hara.b.c.hara.checkers

I'm assuming that it should be :
im.chit/hara.checkers

Okay I've push v0.1.4 to clojars. please have a look at the :repack settings for hara. and the generated output

I had to change my :repack configuration to:

  :repack {:root a.b.c.hara
           :exclude []
           :levels 1
           :name-fn (fn [name package] (str name "." (last (clojure.string/split package #"\."))))}

When I set :levels to 2 I get dependencies of branches that are not there with the above code. So it is a bit tricky. For one level it seems to work fine.

have a look at the new version on clojars (0.1.4) it turned out to be quite an easy fix =)

Yeah it work for me too. Thanks!