teknopaul
teknopaul

Reputation: 6762

How to stop maven making requests to the internet and use a single internal repo

I'd like to connect to a single internal maven repository

My pom.xml has

<repositories>
  <repository>
    <id>nexus</id>
    <url>http://mymavenserver/foo/baa</url>
  </repository>
</repositories>

same for pluginRepositories and distributionManagement

no repositories specified in settings.xml.

But maven still makes requests to http://repo.maven.apache.org/ and can't find resources.

Worse that that, it sends requests over plain insecure HTTP.

http://repo.maven.apache.org/mycompany/myprivateproject/mydevversion/pom.xml

Which is all information that should not be exposed on the Internet.

I need to tell maven to never expose my personal info on the Internet, never go to central, never download code over HTTP from the Internet.

I cant use -o since I do need remote access to a properly secured internal server for distributing assets.

Upvotes: 0

Views: 165

Answers (2)

khmarbaise
khmarbaise

Reputation: 97359

First don't configure such things in your pom file. This belong to the settings.xml file where have to configure your repository manager 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>

This will redirect any access to any repository to the given URL in the settings.xml file.

Upvotes: 0

Akash
Akash

Reputation: 593

Try setting this in your pom:

<repositories>
<repository>
  <id>nexus</id>
   <url>http://mymavenserver/foo/baa</url>
  <releases>
    <enabled>false</enabled>
  </releases>
</repository>
<pluginRepositories>

    <pluginRepository>
        <id>nexus</id>
        <url>http://mymavenserver/foo/baa</url>
        <releases><enabled>false</enabled></releases>
    </pluginRepository>

Upvotes: 1

Related Questions