views:

859

answers:

3

I am trying to set up Maven with a Repository located in our local Network and I already have set up a Repository for snapshots and one for Releases (both apache archiva).

Downloading the packages from the release repository works fine. However I keep getting errors, when I try to load SNAPSHOT versions from the snapshot repository, when I try to download a SNAPSHOT I deployed myself:

[INFO] ------------------------------------------------------------------------  
[ERROR] BUILD ERROR  
[INFO] ------------------------------------------------------------------------  
[INFO] Failed to resolve artifact.  

Missing:  
----------  
1) my.company:product2:jar.lastUpdated:0.0.2-SNAPSHOT

  Try downloading the file manually from the project website.  
[...]

 Path to dependency:   
        1) my.company:product1:war:0.0.1-SNAPSHOT  
        2) my.company:product2:jar.lastUpdated:0.0.2-SNAPSHOT  

 ----------
1 required artifact is missing.

for artifact: 
 my.company:product1:war:0.0.1-SNAPSHOT

from the specified remote repositories:  
  my-internal (http://my-repo:8080/archiva/repository/internal),  
  central (http://repo1.maven.org/maven2),
  my-snapshots (http://my-repo:8080/archiva/repository/snapshots),

The package is available in the snapshots-repo, network is up, login works fine.

My pom.xml looks like this:

 [...]
<repositories>
  <repository>
  <id>my-snapshots</id>
  <name>my name Snapshots Repository</name>
  <url>http://my-snapshots:8080/archiva/repository/snapshots&lt;/url&gt;
  <snapshots>
<enabled/>
<updatePolicy/>
<checksumPolicy/>
</snapshots>
</repository>
<repository>
  <id>my-internal</id>
  <name>my name internal Repository</name>
  <url>http://my-repo:8080/archiva/repository/internal&lt;/url&gt;
</repository>
  </repositories>
 [...]

<dependency>
    <groupId>my.company</groupId>
    <artifactId>frontend-api</artifactId>
    <version>0.0.2-SNAPSHOT</version>
    <type>jar.lastUpdated</type>
</dependency>
 [...]

I checked also the maven-metadata.xml that was downloaded from the snapshot-repo:

<?xml version="1.0" encoding="UTF-8"?>
<metadata>
 <groupId>my.company</groupId>
 <artifactId>product2</artifactId>
 <version>0.0.2-SNAPSHOT</version>
 <versioning>
    <snapshot>
      <buildNumber>7</buildNumber>
     <timestamp>20090824.130209</timestamp>
  </snapshot>
   <lastUpdated>20090824130209</lastUpdated>
 </versioning>
</metadata>

It shows the correct date and timestamp (a package containing this timestamp is present in the repo).

Am I missing something concerning the repository setup or the SNAPSHOT concept? Did anybody had the same problem? Or does somebody know about some detailed documentation about SNAPSHOTs and Repositories?

+1  A: 

What does the dependency declaration for my-app look like? I'd expect it to look like this:

<dependency>
  <groupId>my.company</groupId>
  <artifactId>product2</artifactId>
  <version>0.0.2-SNAPSHOT</version>
</dependency>

From the error, it looks like it has been generated by an archetype and added the lastUpdated type. If that is the case removing lastUpdated should resolve the issue.

If that's not the case, can you share the section of your POM please?

For more information on Maven SNAPSHOT versions, see the Maven book:

Maven versions can contain a string literal to signify that a project is currently under active development. If a version contains the string “SNAPSHOT,” then Maven will expand this token to a date and time value converted to UTC (Coordinated Universal Time) when you install or release this component. For example, if your project has a version of “1.0-SNAPSHOT” and you deploy this project’s artifacts to a Maven repository, Maven would expand this version to “1.0-20080207-230803-1” if you were to deploy a release at 11:08 PM on February 7th, 2008 UTC. In other words, when you deploy a snapshot, you are not making a release of a software component; you are releasing a snapshot of a component at a specific time.

The lastUpdated property is therefore not typically needed.

Rich Seller
Why is the lastUpdated type a problem? Isn't that exactly what I should want: the last SNAPSHOT updated in the repository?
Bertolt
the SNAPSHOT keyword already indicates to Maven that it is in development and the latest version is to be used, the lastUpdated property is not required
Rich Seller
I've updated my answer with more information on SNAPSHOTs
Rich Seller
A: 

Run the mvn with the -e flag for more detailed error messages.

ZacharyP
The output is from running "mvn -e".
Bertolt
A: 

What about your settings.xml file?

if your pom xml has the following:

<repositories>
   <repository>
   <id>my-snapshots</id>
   <name>my name Snapshots Repository</name>
   <url>http://my-snapshots:8080/archiva/repository/snapshots&lt;/url&gt;
   <snapshots>
       <enabled/>
       <updatePolicy/>
       <checksumPolicy/>
   </snapshots>
</repository>

then the setting.xml should have something like:

<server>
    <id>my-snapshots</id>
    <username>user</username>
    <password>pass</password>
    <privateKey>${user.home}/.ssh/id_dsa</privateKey>
    <passphrase>some_passphrase</passphrase>
    <filePermissions>664</filePermissions>
    <directoryPermissions>775</directoryPermissions>
    <configuration></configuration>
  </server>

1) The repository username and password must be as above

2) The id tag in both settings and pom must be the same:

<id>my-snapshots</id>
rperez