Overriding central works in profile, but not directly?

Viewed 5

I've spend a lot of time looking for error in maven configuration.

I've overriden central with internal caching repository:

<activeProfiles>
  <activeProfile>internal</activeProfile>
</activeProfiles>
<profiles>
  <profile>
    <id>internal</id>
    <repositories>
      <repository>
        <id>central</id>
        <url>https://internal.rep/nexus/repository/public</url>
        <releases>
          <enabled>true</enabled>
        </releases>
        <snapshots>
          <enabled>true</enabled>
        </snapshots>
      </repository>
  </profile>
</profiles>        

However, that configuration was not working on the build server. There were attempts made to download artifacts from central maven repository.

I've found out that there, in settings.xml, the repositories section was declared directly in <settings> and not in profile:

<settings>
  <repositories>
    <repository>
      <id>central</id>
      <url>https://internal.rep/nexus/repository/public</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
</settings>

which I've initially ignored, because it shouldn't make any difference. It did.

But why are repositories ignored, that are defined not in profile? There was no warning about invalid settings.xml, the maven behaved as if those tags were not there...

Do generally everything in settings.xml need to be declared in profile? I'm using Maven 3.8

0 Answers
Related