views:

870

answers:

2

I'm reconfiguring a build server that someone else setup a long time ago to use a new Maven repository. However, the old repository is still being referenced and I can't figure out where that reference is coming from.

M2_HOME=/usr/share/maven2

/etc/maven2/m2.conf (usr/share/maven2/conf/m2.conf links here)

main is org.apache.maven.cli.MavenCli from plexus.core

set maven.home default ${user.home}/m2

[plexus.core]
load ${maven.home}/lib/*.jar

/etc/maven2/conf also has a settings.xml with all entries commented out.

The build user has a ~/.m2/settings.xml: referencing NewRepo.

<settings>
    <pluginGroups>
    </pluginGroups>
    <servers>
    </servers>
    <profiles>
        <profile>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <id>personal</id>
            <repositories>
                <repository>
                    <id>new-repo</id>
                    <name>New Maven 2 Repo</name>
                    <url>http://NewRepo/&lt;/url&gt;
                </repository>
      <!-- Some other standard repos like maven.org here -->
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>ibiblio</id>
                    <name>Ibiblio Maven 2 Repo</name>
                    <url>http://repo1.maven.org/maven2/&lt;/url&gt;
                </pluginRepository>
                <pluginRepository>
                  <id>apache-snapshots</id>
                  <name>Apache Snapshots Maven 2 Repo</name>
                  <url>http://people.apache.org./maven-snapshot-repository/&lt;/url&gt;
                </pluginRepository>
            </pluginRepositories>
         </profile>
     </profiles>
</settings>

There is also a /mnt/public/maven/settings.xml with the exact same content as the build user's settings.xml

I searched the entire file system to ensure there are no other settings.xml files.

When running

mvn release:prepare

I get the warning:

[INFO] NOTE: Maven is executing in offline mode. Any artifacts not already in your local repository will be inaccessible.

When running

mvn release:perform

I get the error:

Error deploying artifact: Failed to transfer file: http://OldRepo

Where could that reference to http://OldRepo be hiding?

EDIT

The project's pom.xml references a parent POM as follows:

<parent>
    <groupId>MyParent</groupId>
    <artifactId>maven</artifactId>
    <version>20090727</version>
</parent>

There is no reference to

<distributionManagement>

in the project's POM. I have been unable to locate the parent POM.

+2  A: 

About repositories inside a profile declared in the settings.xml, the documentation says:

Repositories are remote collections of projects from which Maven uses to populate the local repository of the build system. It is from this local repository that Maven calls it plugins and dependencies. Different remote repositories may contain different projects, and under the active profile they may be searched for a matching release or snapshot artifact.

So this is not used for release management. To configure where an artifact is deployed, you need to add a distributionManagement element in your pom.

The following is an example of how a distributionManagement element can be configured within a project pom.xml file.

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany.app</groupId>
  <artifactId>app</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>Application</name>
  <url>http://app.mycompany.com&lt;/url&gt;
  ...
  <distributionManagement>
    <repository>
      <id>myRepoId</id>
      <name>myCompanyReporsitory</name>
      <url>ftp://repository.mycompany.com/repository</url>
    </repository>
  </distributionManagement>
  ...
</project>

Look for this element in your pom or in a parent pom (it could be declared in a corporate parent pom).

EDIT: you can override the distributionManagement in your pom but it would be better to modify it in the parent pom and release this new version in your enterprise repository if this is a definitive change.

Pascal Thivent
There's no distributionManagement node in the project's POM. There is a reference to a parent POM (added to my question) but there's no path specified to the parent, and there's no other project at all in the build directory. Searched the file system for all pom.xml to try and locate the parent POM but no luck.
Eric J.
You can declare a parent using its `groupId`, `artifactId` and `version`, without the `relativePath`, if this parent has been released in your enterprise repository. This is actually how a "corporate" pom should be used (which seems to be the case here). The parent pom must have been downloaded in your local repository.
Pascal Thivent
Ah, that did it. The parent POM is in the repository.
Eric J.
A: 

Maybe is silly to suggest but have you tried with your old friend grep, if is it available?

pedromarce
First thing I tried :-) I tried to grep all regular files under 5K in size for the relevant text (after first trying on pom.xml and *.xml). I have a grep running now checking all files. That one's been running for a while now.
Eric J.
good luck then :)
pedromarce