Skip to content

Yet another programming solutions log

Sample bits from programming for the future generations.

Technologies Technologies
  • Algorithms and Data Structures
  • Java Tutorials
  • JUnit Tutorial
  • MongoDB Tutorial
  • Quartz Scheduler Tutorial
  • Spock Framework Tutorial
  • Spring Framework
  • Bash Tutorial
  • Clojure Tutorial
  • Design Patterns
  • Developer’s Tools
  • Productivity
  • About
Expand Search Form

Maven use company repository

farenda 2016-10-21 0

Maven use company repository (Nexus)

In this post we’ll show how to configure Maven to download project libraries from your company’s repository/mirror instead of the Internet.

In most cases, when developing software in corporations, you would like to download all project libraries from a repository (Nexus) located in corporate network, which is much faster than from the Internet.

Mirror repository in settings.xml

Configuration for all your Maven projects can be done in ~/.m2/settings.xml (.m2 directory located in your home/user directory):

<?xml version="1.0" encoding="utf-8"?>
<settings>
  <!-- other configuration if any -->
  <mirrors>
    <!-- you can setup more mirrors, but usually it's one -->
    <mirror>
      <id>your-company-mirror</id>
      <name>Your Company Mirror</name>
      <url>https://maven.your-company.com/content/groups/all_repos</url>
      <mirrorOf>external:*</mirrorOf>
    </mirror>
  </mirrors>
  <!-- other configuration if any -->
</settings>

Just use the address of your company’s Nexus repository and make sure to set path (here /content/groups/all_repos) to what is used in your company’s Nexus.

Maven mirrorOf syntax

The key part is configuration is mirrorOf. It allows to select, using ids or wildcards, which repositories should be mirrored:

  • *
    Tells Maven that all libraries should be taken from company’s repository.
  • external:*
    Fetch all from company repo, except those on the localhost and from files (sometimes libs are in a project’s subdirectory).
  • repoId1,repoId2
    Use company repository instead of repositories with these ids. For others download normally.
  • *,!repoId
    Mirror everything except (note the exclamation mark) repository with id repoId.

Now, when you run maven package or just import a project in your IDE, then Maven will download packages from the URL provided above.

Voila! :-)

Share with the World!
Categories Dev Tools Tags java, maven
Previous: Java XML validate using SchemaFactory
Next: Java 8 reduce by example

Recent Posts

  • Java 8 Date Time concepts
  • Maven dependency to local JAR
  • Caesar cipher in Java
  • Java casting trick
  • Java 8 flatMap practical example
  • Linked List – remove element
  • Linked List – insert element at position
  • Linked List add element at the end
  • Create Java Streams
  • Floyd Cycle detection in Java

Pages

  • About Farenda
  • Algorithms and Data Structures
  • Bash Tutorial
  • Bean Validation Tutorial
  • Clojure Tutorial
  • Design Patterns
  • Java 8 Streams and Lambda Expressions Tutorial
  • Java Basics Tutorial
  • Java Collections Tutorial
  • Java Concurrency Tutorial
  • Java IO Tutorial
  • Java Tutorials
  • Java Util Tutorial
  • Java XML Tutorial
  • JUnit Tutorial
  • MongoDB Tutorial
  • Quartz Scheduler Tutorial
  • Software Developer’s Tools
  • Spock Framework Tutorial
  • Spring Framework

Tags

algorithms bash bean-validation books clojure design-patterns embedmongo exercises git gof gradle groovy hateoas hsqldb i18n java java-basics java-collections java-concurrency java-io java-lang java-time java-util java-xml java8 java8-files junit linux lists log4j logging maven mongodb performance quartz refactoring regex rest slf4j solid spring spring-boot spring-core sql unit-tests

Yet another programming solutions log © 2021

sponsored
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok