Bomin
Bomin

Reputation: 1667

Customize maven remote repository

So my company has an internal maven repository deployed, and I'm supposed to download everything internally not from maven central repository. I'm setting the repositories element like this

<project>
    <repositories>
       <repository>
          <id>Internal-maven-repo</id>
          <name>Repo</name>
          <url>http://build.a.com/nexus/content/groups/repo</url>
          <snapshots>
             <enabled>false</enabled>
          </snapshots>
       </repository>
    </repositories>
</project>

So, when doing maven package, do I need to specify a repository id in pom.xml? How do I know it's downloading from the internal repository but not externally?

Upvotes: 2

Views: 66

Answers (1)

khmarbaise
khmarbaise

Reputation: 97447

The correct configuration for a settings.xml in relationship with a nexus repository manager looks like this:

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>

And it is necessary to enable snapshots as well as releases.

Upvotes: 1

Related Questions