Does Leiningen read maven settings in .m2/settings.xml?

牧云@^-^@ 提交于 2019-12-04 19:05:17

问题


I have several additional repositories in ~/.m2/settings.xml. I tried lein search and it doesn't find the packages in my repositories. How can I tell leiningen to search repositories in maven settings?


回答1:


You can add the :repositories tag to your project.clj file:

(defproject com.foo/bar "1.0.0-SNAPSHOT"
  ;; ...other configuration...
  :repositories [["java.net" "http://download.java.net/maven/2"]])

Take a look at the official sample project.clj.

You'll have to copy over the repository configuration from your settings.xml file, but this is the idiomatic and recommended way to manage repositories with Leiningen.

Does lein2 use repositories defined in ~/.m2/settings.xml?




回答2:


BTW, if you really want to add Maven repositories or mirrors on user profile level (useful for internal company proxy repositories like Nexus, especially if Lein has its usual problems with corporate NTLM proxies), then you can do this in ~/.lein/profiles.clj / %USERPROFILE%\.lein\profiles.clj:

How to configure leiningen's maven usage?

In my case, on Windows, it was sufficient to place this :mirrors map in my %USERPROFILE%\.lein\profiles.clj:

{:user
    {
        :java-cmd "C:\\Program Files\\Java\\jdk1.7.0_09\\bin\\java.exe"
            :plugins [    ]
            :mirrors {
                #".+"  "http://internal-nexus.example.com/content/groups/public-all/"
            }
    }
}

`

The #".+" specifies the name of mirrored repository using pattern syntax that matches all possible names (resulting in mirroring every repository), as described in this Leiningen issue report 271.



来源:https://stackoverflow.com/questions/15910567/does-leiningen-read-maven-settings-in-m2-settings-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!