librelist archives

« back to archive

Fwd: Setting default repositories for new projects

Fwd: Setting default repositories for new projects

From:
bill robertson
Date:
2014-03-04 @ 22:32
Hello,

I've been digging through search results on leiningen for a way to set
default repositories. I first ran into a discussion on init.clj, which
turns out to be unsupported in lein 2. The discussion on migrating from 1.x
to 2.x suggests to put things that used to be in init.clj into the user
profile.

However, adding repositories to user profile invokes a repeatability
warning. Which makes sense. I could leave it as is, but I really dislike
telling people to ignore warnings. It trains you to do the wrong thing. I
would not like to add the repositories stanza to each project.clj file by
hand either because it would be error prone.

Is there an easier way to get this in every project.clj file w/o warnings
and/or a lot of manual labor?

Thanks,
Bill Robertson

Re: [leiningen] Fwd: Setting default repositories for new projects

From:
Jean Niklas L'orange
Date:
2014-03-05 @ 18:56
Hello Bill,

On 4 March 2014 23:32, bill robertson <billrobertson42@gmail.com> wrote:
>
> Is there an easier way to get this in every project.clj file w/o warnings
> and/or a lot of manual labor?
>

I think you can do this through profiles.d and some dereferencing:

In `~/.lein/profiles.d/my-company-defaults.clj`, insert the default
repositories. Then, in the project.clj, add in the following:

(def company-repos
  (get-in (leiningen.core.user/profiles-d-profiles)
          [:my-company-defaults :repositories]
          ^:replace [])) ;; Ensure failure if the profile lookup fails.

(defproject my-project ...
  :repositories ~company-repos
  ...)

Of course, instead of changing `intrarepo.mycompany.com` in all the
different `project.clj`'s, you should change the DNS entry of `
intrarepo.mycompany.com`. As far as I know, that's the rationale behind
having a DNS entry in the first place, isn't it?

I would recommend to make an internal template for this, regardless of the
course you take. That removes the small overhead related to each new
project your company create.

-- 
Regards,
Jean Niklas L'orange

Re: [leiningen] Fwd: Setting default repositories for new projects

From:
bill robertson
Date:
2014-03-05 @ 20:50
That's an interesting approach. I've been thinking about the template route
as well.

Thanks for the feedback.

-Bill


On Wed, Mar 5, 2014 at 1:56 PM, Jean Niklas L'orange
<jeannikl@hypirion.com>wrote:

> Hello Bill,
>
> On 4 March 2014 23:32, bill robertson <billrobertson42@gmail.com> wrote:
>>
>> Is there an easier way to get this in every project.clj file w/o warnings
>> and/or a lot of manual labor?
>>
>
> I think you can do this through profiles.d and some dereferencing:
>
> In `~/.lein/profiles.d/my-company-defaults.clj`, insert the default
> repositories. Then, in the project.clj, add in the following:
>
> (def company-repos
>   (get-in (leiningen.core.user/profiles-d-profiles)
>           [:my-company-defaults :repositories]
>           ^:replace [])) ;; Ensure failure if the profile lookup fails.
>
> (defproject my-project ...
>   :repositories ~company-repos
>   ...)
>
> Of course, instead of changing `intrarepo.mycompany.com` in all the
> different `project.clj`'s, you should change the DNS entry of `
> intrarepo.mycompany.com`. As far as I know, that's the rationale behind
> having a DNS entry in the first place, isn't it?
>
> I would recommend to make an internal template for this, regardless of the
> course you take. That removes the small overhead related to each new
> project your company create.
>
> --
> Regards,
> Jean Niklas L'orange
>