Maven Internal Repository, Is it Really This Hard?

前端 未结 3 1827
没有蜡笔的小新
没有蜡笔的小新 2020-12-24 03:55

I have several projects which use Maven and I would like to run an internal repository on my work network. I have several libraries which are from third parties and cannot b

相关标签:
3条回答
  • 2020-12-24 04:30

    I would suggest to use the Nexus evaluation guide (latest available version is 2.13 now) that comes with the Nexus Pro Installer, but also works with Nexus Open Source for the simple use cases of proxying and deploying components.

    The examples are also available on github and include setups for Maven, Ant/Ivy and Gradle. Once you have a look at the examples and read the guide you will be able to set up your projects in the same way easily.

    And of course if there is any problems you can always ask on the mailing list or chat with the developers on hipchat

    0 讨论(0)
  • 2020-12-24 04:38

    Repository managers like Archiva and Nexus are more than just an internal repository. They serve as proxies that obviate reaching out to Maven central or other external repository.

    For just an internal repository all you need is a network or HTTP accessible location that has the structure of a Maven repository. Then you refer to it as another repository in your settings file.

    <repository>
      <id>my-internal-repo</id>
      <url>http://myrepo.mycompany.com/</url>
    </repository>
    

    See more in Maven's documentation at http://maven.apache.org/guides/introduction/introduction-to-repositories.html.

    0 讨论(0)
  • 2020-12-24 04:50

    I have only worked with Nexus, but I found it very easy to install:

    1. Go to http://www.sonatype.org/nexus/go to download the OSS version
    2. Get the 'WAR' distribution
    3. Install the servlet in my installation of Tomcat, via the Web Application Manager

    At that point, I can visit http://myserver:8080/nexus to see everything working.

    For a superficial setup, I add the default password to my settings.xml:

        <servers>
                <server>
                        <id>my-snapshots</id>
                        <username>admin</username>
                        <password>admin123</password>
                </server>
                <server>
                        <id>my-releases</id>
                        <username>admin</username>
                        <password>admin123</password>
                </server>
        </servers>
    

    and in my POM file:

        <distributionManagement>
                <snapshotRepository>
                        <id>my-snapshots</id>
                        <name>My internal repository</name>
                        <url>http://myserver:8080/nexus/content/repositories/snapshots</url>
                </snapshotRepository>
                <repository>
                        <id>my-releases</id>
                        <name>My internal repository</name>
                        <url>http://myserver:8080/nexus/content/repositories/releases</url>
                </repository>
        </distributionManagement>
    

    To go beyond this, the learning curve jumps up quite a bit, but I found Sonatype's online books to be pretty good. Repository Management with Nexus is the one for understanding what you can do with the repository server. The only thing I found tricky is that some of the info applies only to their commercial software and they don't work too hard to advertise the difference.

    0 讨论(0)
提交回复
热议问题