How do I use checked-in jars with leiningen

后端 未结 3 1043
不知归路
不知归路 2020-12-28 08:47

We have some 3rd-party jars checked-in to our project. We\'d like to add them to the classpath. That\'s it. We don\'t want to set up a local maven repo (because that would b

3条回答
  •  一个人的身影
    2020-12-28 09:37

    I'd like to elaborate on @Jared314's excellent answer that helped me as well.

    Below is a script that automates the process of adding multiple jars from a local lib folder to a local repository:

    #!/bin/sh
    export LOCALREPO_USERNAME=
    export LOCALREPO_PASSWORD=
    
    for file in lib/*.jar
    do
        name=$(basename "$file")
        basename=${name%.jar}
    
        echo "Deploying $basename"
    
        artifactId="local/$basename"
        lein deploy localrepo1 $artifactId 1.0 $file
    
        echo "[$artifactId \"1.0\"]" >> dependencies.log
    done
    

    The list of Leiningen dependencies that can be added to project.clj is stored in dependencies.log.

    Before running the script, :repositories entry in project.clj has to be updated to allow for reading repository username and password from the environment:

      :repositories [["localrepo1" {:url "file:myrepo"
                                    :username :env/localrepo_username
                                    :password :env/localrepo_password}]]
    

    This will prevent the repository password prompt from displaying when running the script.

提交回复
热议问题