Maven-plugin : maven downloads only pom, not jar file from internal repo

maven-2maven-plugin

I'm quite new to maven and I'm facing some trouble with a plug-in I wrote and published on the company's internal (archiva) repository.

The building and publication of the plug-in seems to work, as I can see, on the url of the repo, that :

  • the repo directory is created
  • the directory contains :
    • the pom , pom.sh1 , pom.md5 files
    • the jar , jar.sh1 , jar.md5 files

In the pom.xml file of my plug-in, I have referenced the url of our internal repo :

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.myorg</groupId>
  <artifactId>myorg-build-info-plugin</artifactId>
  <packaging>maven-plugin</packaging>
  <version>1.0.0</version>
  <name>myorg-build-info-plugin Maven Mojo</name>
  <url>labserver.myorg-domain.com:8380/archiva/repository/internal</url>
....

Ten I reference this plugin in another pom.xml :

<plugin>
          <groupId>com.morg</groupId>
          <artifactId>myorg-build-info-plugin</artifactId>
          <version>1.0.0</version>
...

And I do provide the internal repo in the same pom.xml :

<repositories>
        <repository>
            <id>myorg-repo</id>
            <name>Repository for Myorg Artifacts</name>
            <url>http://labserver.myorg-domain.com:8380/archiva/repository/internal</url>
            <layout>default</layout>
        </repository>

Finally If i execute a maven clean operation on that pom file ( executing mvn clean -e ) I got the following error :

+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building com.myorg.projectname
[INFO]    task-segment: [clean]
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/com/myorg/myorg-build-info-plugin/1.0.0/myorg-build-info-plugin-1.0.0.pom
[INFO] Unable to find resource 'com.myorg:myorg-build-info-plugin:pom:1.0.0' in repository central (http://repo1.maven.org/maven2)
Downloading: http://labserver.myorg-domain.com:8380/archiva/repository/internal/com/myorg/myorg-build-info-plugin/1.0.0/myorg-build-info-plugin-1.0.0.pom
1K downloaded  (myorg-build-info-plugin-1.0.0.pom)
Downloading: http://repo1.maven.org/maven2/com/myorg/myorg-build-info-plugin/1.0.0/myorg-build-info-plugin-1.0.0.jar
[INFO] Unable to find resource 'com.myorg:myorg-build-info-plugin:maven-plugin:1.0.0' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] A required plugin was not found: Plugin could not be found - check that the goal name is correct: Unable to download the artifact from any repository

Try downloading the file manually from the project website.

Then, install it using the command: 
...

Now from what I can see :

  • the pom file is correctly fetched from our internal repo
  • the jar file fetching fails because it's trying to fetch it from the http://repo1.maven.org/maven2

I'd expect that all the repos are scanned, especially the internal repo declared in the file.

Obviously this is not the case.

So if anyone has any clues on why is this happening, I'd really appreciate some help !

TIA,

PS : I'm using maven 2.2.1 for debian with a JDK 1.6.029

Best Answer

The first thing i would recommend is to use a repository manager like Archiva, Artifctory or Nexus furthermore i recommend to read the following article: http://www.sonatype.com/people/2009/02/why-putting-repositories-in-your-poms-is-a-bad-idea/. Apart from the previous you need to define an pluginRepository area like this:

 <pluginRepositories>
    <pluginRepository>
      <id>central</id>
      <name>Maven Plugin Repository</name>
      <url>http://repo1.maven.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
    </pluginRepository>
  </pluginRepositories>
Related Topic