How to use a maven 1 repository with maven 2?

11,542

The Nexus repository manager is able to proxy Maven 1 repositories for Maven {2,3} clients.

Maven 3 no longer has the possibility of using 'legacy' repositories, see Maven 3.x compatibility notes.

Share:
11,542
Dominic
Author by

Dominic

Updated on June 04, 2022

Comments

  • Dominic
    Dominic almost 2 years

    I am having problem building my project (using maven 2) which references some jars from a maven 1 repository.

    The scenario: My company has a private maven 1 repository that has the following info:

    <url>http://my-company-maven1-repo/maven-repository<url>
    

    It has the layout of:

       maven-repository
                  |_repository
                         |_ ....
                         |_ ....
                         |_vectorgraphics
                                  |_jars
                                      |_freehep_swing-2.0.3.jar
                                      |_freehep_io-2.0.2.jar
    

    What I have tried: 1. Following the guide here: relevant maven official docs My mvn2 pom.xml:

    <repository>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <id>my-repo</id>        <-- I made up a temporary id/name
      <name>my_repo></name>
      <url>http://my-company-maven1-repo/maven-repository<url>
      <layout>
    <repository>
    <dependencies>
      <dependency>
        <groupId>vectorgraphics</groupId>
        <artifactId>freehep-swing</artifactId>
        <version>2.0.3</version>
        <scope>jar</scope>
      </dependency>
    </dependencies>
    

    The result was weird, my company's maven1 repo was completely ignored. Instead, mvn2 attempted to download the jar from "maven2 central":

    Downloading http://repo1.maven.org/maven2/vectorgraphics/freehep-swing/2.0.3/freehep-swing-2.0.3.pom 
    

    And the resulted freehep-swing-2.0.3.pom (in my local .m2/repository/) has the following errors:

    legacy-http\://my-company-maven1-repo/maven-repository/.lastUpdated=1305430120039
    http\://my-company-maven1-repo/maven-repository/.error=Could not transfer artifact vectorgraphics\:freehep-swing\:pom\:2.0.3 from/to my-repo (http\://my-company-maven1-repo/maven-repository)\: No connector available to access repository my-repo (http\://my-company-maven1-repo/maven-repository) of type legacy using the available factories AsyncRepositoryConnectorFactory, WagonRepositoryConnectorFactory
    http\://repo1.maven.org/maven2/.error=
    http\://repo1.maven.org/maven2/.lastUpdated=1305430120281
    

    If anyone can point out to me how to fetch that freehep_swing-2.0.3.jar from the maven1 repository (with layout shown above), I would really really appreciate that.

    Thanks,

    Tung