Using closed-source dependencies with Maven

后端 未结 3 804
生来不讨喜
生来不讨喜 2021-02-05 23:35

I have a closed-source project that I would like to build using Maven. It has a dependency on two java libraries which are not available in any public repository that I\'ve bee

3条回答
  •  失恋的感觉
    2021-02-06 00:19

    Use A dedicated Repository Server

    As per maven's Internal Repositories documentation, I could set up a repository server somewhere and put the binaries there, which all the developers would then access.

    Exactly. Set up a maven repository server with several repositories, e.g. these:

    • internal-releases
    • internal-snapshots
    • external-opensource
    • external-closedsource (this is where the lib we are talking about goes)

    But that means I have a new server to maintain (or at least a new website on an existing server). It also means I have to worry about permissions to ensure that outside parties can't access the repository.

    Yes, but a company that does serious software development should have an infrastructure like that. But if your company is serious about using Maven, there should probably also be a dedicated position for configuration management, and that person should administer this server.

    It also means I have to worry about backups and availability now so that developers don't run into hiccoughs if the repository is unavailable.

    The standard repository servers (e.g. Sonatype Nexus) are rock solid. If it ever hangs, just restart the app server / servlet container it's running on. Also, once developers have downloaded a library from the repo, it remains in the local repo, so even if the repo is down, there shouldn't be a problem (but you can't reference a new dependency when the server is down).


    Use your existing SCM as a maven repository

    OK, if you really want to use your SCM as a maven repo, here's how to do it:

    http://maven-svn-wagon.googlecode.com/svn/site/index.html

    This article describes how to setup an SVN-based maven repository for your own project. But if you want to deploy a third-party to the repo, just create a pom with the config mentioned here and use that pom to deploy:deploy-file your library.

    (There are other wagon / scm implementations also, and the configuration is slightly different, but the solution remains the same: create a pom according to the wagon implementation you are using and then do deploy:deploy-file (see more info on the usage page)

提交回复
热议问题