You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by NRO <no...@gmail.com> on 2013/10/03 10:33:13 UTC

Parent SNAPSHOT not resolved Maven 2.2.1 - 3.0.4 - (Nexus repo)

A maven project which have a parent SNAPSHOT cannot be resolved when :

a) the Parent SNAPSHOT pom is not present in the local maven repository 
b) the Parent SNAPSHOT pom is deployed in a Nexus repository by another
developer.
c) settings.xml has a mirror redirecting all (*) to Nexus
d) there is no <repository> entry in the settings.xml file as Nexus is used
for all resolutions.

Easy to reproduce on Maven 2.2.1, 3.0.4 and probably earlier releases.

- If the SNAPSHOT parent is instead used as a dependency of the project then
maven can resolve the dependency and retrieve it from Nexus.

Work around:

If you add a dumb repo entry in the settings.xml file, then it works.

Exemple of such entry is a fake repository and it does not even have to be a
snapshot repo...

settings.xml

[...]
<repositories>
        <repository>
                <id>foo</id>
                <url>http://foo</url>
        </repository>
</repositories> 
[...]

simplest work around.

But to MHO, there is a bug in the Maven code when doing parent snapshot
resolution. If the parent snapshot is not present in the local repo AND
there is no <repository> entry in the settings.xml file, it simply fails. It
does not try the mirror. 




--
View this message in context: http://maven.40175.n5.nabble.com/Parent-SNAPSHOT-not-resolved-Maven-2-2-1-3-0-4-Nexus-repo-tp5772374.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Parent SNAPSHOT not resolved Maven 2.2.1 - 3.0.4 - (Nexus repo)

Posted by NRO <no...@gmail.com>.
That makes sense.



--
View this message in context: http://maven.40175.n5.nabble.com/Parent-SNAPSHOT-not-resolved-Maven-2-2-1-3-0-4-Nexus-repo-tp5772374p5772388.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Parent SNAPSHOT not resolved Maven 2.2.1 - 3.0.4 - (Nexus repo)

Posted by Stuart McCulloch <mc...@gmail.com>.
On 3 Oct 2013, at 14:31, NRO wrote:

> Thanks for the clear explanation.
> 
> All our artifacts are served by our Nexus Repository Manager (external and
> internal).
> All our repositories (hosted and proxy) are managed by Nexus, this is why
> our settings.xml and parent poms does not need to refer to other
> repositories because we want to control all from Nexus.
> 
> So declaring a fake snapshot repository will help Maven re-route resolution
> to a parent pom...
> 
> BTW if you replace the snapshot parent by a release version, the same
> problem appear despite the maven central in super pom...

This isn't what I see locally using the same poms as below, with the parent version set to a release it will attempt to fetch it:

	...snip...
	Downloading: http://repo.maven.apache.org/maven2/a/b/c/parente/0.0.1/parente-0.0.1.pom

Repeating the same test using a mirror (and clearing the local repository of any cached records about the pom, see below):

	...snip...
	Downloading: https://some.repo.manager/content/groups/some.group/a/b/c/parente/0.0.1/parente-0.0.1.pom

Note that Maven will record failed attempts to fetch releases in your local repository:

	[ERROR] Non-resolvable parent POM: Failure to find a.b.c:parente:pom:0.0.1 in http://repo.maven.apache.org/maven2 was cached in the local repository,
		resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 7, column 10 -> [Help 2]

and will not attempt to fetch the release again until the update interval elapses (default is daily) or you use -U to force it to re-check.

> Again adding the fake repository helps solving the case.
> 
> I am still not convinced it is a feature ;-)

Since there is no snapshot repository defined in the current pom.xml, settings.xml, or Maven super-pom - and the relativePath doesn't lead to the parent pom - how should Maven know where to fetch it?

I guess you could say that defining a mirror in your settings.xml should add an implicit snapshot repository definition, but how would you remove such a repository definition if you didn't want it? Because each snapshot repository is queried separately, if you then defined additional snapshot repositories then you could end up with multiple queries going through the mirror. In a way this all comes back to the fact that mirror != repository and I'm not sure that mixing these concepts by adding implicit repositories based on mirror definitions is a good thing - especially when there's a simple solution (declare the repository in settings.xml) that captures the intent and would also work when not mirroring.

(just my 2 sen)

> --
> View this message in context: http://maven.40175.n5.nabble.com/Parent-SNAPSHOT-not-resolved-Maven-2-2-1-3-0-4-Nexus-repo-tp5772374p5772386.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Parent SNAPSHOT not resolved Maven 2.2.1 - 3.0.4 - (Nexus repo)

Posted by NRO <no...@gmail.com>.
Thanks for the clear explanation.

All our artifacts are served by our Nexus Repository Manager (external and
internal).
All our repositories (hosted and proxy) are managed by Nexus, this is why
our settings.xml and parent poms does not need to refer to other
repositories because we want to control all from Nexus.

So declaring a fake snapshot repository will help Maven re-route resolution
to a parent pom...

BTW if you replace the snapshot parent by a release version, the same
problem appear despite the maven central in super pom...

Again adding the fake repository helps solving the case.

I am still not convinced it is a feature ;-)



--
View this message in context: http://maven.40175.n5.nabble.com/Parent-SNAPSHOT-not-resolved-Maven-2-2-1-3-0-4-Nexus-repo-tp5772374p5772386.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Parent SNAPSHOT not resolved Maven 2.2.1 - 3.0.4 - (Nexus repo)

Posted by Stuart McCulloch <mc...@gmail.com>.
The scenario described below fails for me with or without a mirror setting - as I would expect it to.

Given a child project with a missing parent pom Maven will attempt to resolve the parent given the available context, namely:

	settings.xml
	current pom.xml
	Maven's super-pom

If neither the settings.xml nor the current pom.xml define a snapshot repository then the only repository definition is from Maven's default super-pom:

  <repositories>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Central Repository</name>
      <url>http://repo.maven.apache.org/maven2</url>
    </repository>
  </repositories>

which clearly disables snapshots.

Defining a mirror in your settings.xml does not change repository definitions, as Tamas mentioned before all it does is re-route requests via the mirror. Therefore since there are no repositories defined with snapshots enabled, Maven will not request to fetch the parent pom snapshot. But if you add a snapshot repository definition somewhere (settings.xml or current pom.xml) then Maven will respect that and request the parent pom snapshot from that repository. If you have a mirror in your settings.xml then that request will be routed via the server defined in the mirror.

Note that Maven will also attempt to use the parent relativePath definition from the current pom to attempt to find the parent pom on disk - so assuming the default relativePath, Maven would also be able to find the parent pom if it was located in the parent directory relative to the child (../pom.xml).

The same thing is true of snapshot dependencies - if none of your settings.xml, pom.xml, or any pom in the hierarchy define a snapshot repository then Maven will not have anywhere it could request the snapshot from, regardless of the mirror definition (as mirror != repository). Only if the snapshot dependency was available somewhere in the reactor (the effective plan of the build on disk) would Maven be able to resolve the snapshot.

HTH

On 3 Oct 2013, at 13:22, NRO wrote:

> Ok, lets talk with a concrete simple example:
> 
> PARENT POM:
> 
> <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/xsd/maven-4.0.0.xsd">
>  <modelVersion>4.0.0</modelVersion>
> 
>  <groupId>a.b.c</groupId>
>  <artifactId>parente</artifactId>
>  <version>0.0.1-SNAPSHOT</version>
>  <packaging>pom</packaging>
>  <name>parente</name>
>  <description>ddd</description>
> 
> 	<distributionManagement>
> 		<repository>
> 			<id>internal.project.release</id>
> 			<name>internal.project.release</name>
> 			<url>${maven2Repository_projet}/project_release</url>
> 		</repository>
> 
> 		<snapshotRepository>
> 			<id>internal.project.snapshot</id>
> 			<name>internal.project.snapshot</name>
> 			<url>${maven2Repository_projet}/project_snapshot</url>
> 		</snapshotRepository>
> 
> 		<site>
> 			<id>projects_Website</id>
> 		
> <url>${projects_Website}/cti/melusine/${project.artifactId}/${project.version}</url>
> 		</site>
> 	</distributionManagement>
> </project>
> ---------------------------------------------------
> CHILD POM
> 
> <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/xsd/maven-4.0.0.xsd">
>  <modelVersion>4.0.0</modelVersion>
> 
>  <parent>
>    <groupId>a.b.c</groupId>
>    <artifactId>parente</artifactId>
>    <version>0.0.1-SNAPSHOT</version>
>  </parent>
> 
>  <groupId>a.c</groupId>
>  <artifactId>deleteme</artifactId>
>  <version>0.0.1-SNAPSHOT</version>
>  <name>aaa</name>
>  <description>bbb</description>
> </project>
> -----------------------------------------------------
> 
> These very simple Poms demonstrate the problem.
> 
> You need to deply parent first and then delete parent from local repo and
> then try building child.
> As you notice there are no SNAPSHOT repository declaration nowhere.
> Distibution managment is a separate thing in the parent itself.
> 
> 
> 
> 
> --
> View this message in context: http://maven.40175.n5.nabble.com/Parent-SNAPSHOT-not-resolved-Maven-2-2-1-3-0-4-Nexus-repo-tp5772374p5772383.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Parent SNAPSHOT not resolved Maven 2.2.1 - 3.0.4 - (Nexus repo)

Posted by NRO <no...@gmail.com>.
Ok, lets talk with a concrete simple example:

PARENT POM:

<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>a.b.c</groupId>
  <artifactId>parente</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>
  <name>parente</name>
  <description>ddd</description>
  
	<distributionManagement>
		<repository>
			<id>internal.project.release</id>
			<name>internal.project.release</name>
			<url>${maven2Repository_projet}/project_release</url>
		</repository>

		<snapshotRepository>
			<id>internal.project.snapshot</id>
			<name>internal.project.snapshot</name>
			<url>${maven2Repository_projet}/project_snapshot</url>
		</snapshotRepository>

		<site>
			<id>projects_Website</id>
		
<url>${projects_Website}/cti/melusine/${project.artifactId}/${project.version}</url>
		</site>
	</distributionManagement>
</project>
---------------------------------------------------
CHILD POM

<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>a.b.c</groupId>
    <artifactId>parente</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>

  <groupId>a.c</groupId>
  <artifactId>deleteme</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>aaa</name>
  <description>bbb</description>
</project>
-----------------------------------------------------

These very simple Poms demonstrate the problem.

You need to deply parent first and then delete parent from local repo and
then try building child.
As you notice there are no SNAPSHOT repository declaration nowhere.
Distibution managment is a separate thing in the parent itself.




--
View this message in context: http://maven.40175.n5.nabble.com/Parent-SNAPSHOT-not-resolved-Maven-2-2-1-3-0-4-Nexus-repo-tp5772374p5772383.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Parent SNAPSHOT not resolved Maven 2.2.1 - 3.0.4 - (Nexus repo)

Posted by Stuart McCulloch <mc...@gmail.com>.
On 3 Oct 2013, at 11:11, Anders Hammar wrote:

> It should be the same for deps as well as parents. One difference could be
> if you have a repo declared in the pom (not setiings.xml). It might be that
> that repo is only used for deps and not the parent, I don't know.

FWIW, I've run some tests locally and confirm it is the same for (non-reactor) dependencies when you don't have a snapshot repository declared in your pom hierarchy or settings.xml

Use "mvn help:effective-pom" to check as a lot of corporate/oss organizational setups will declare a snapshot repository somewhere, otherwise Maven would not know where to fetch non-reactor snapshots.

PS. note that an anaemic repository entry with just an id and url is still considered a snapshot repository because the default setting for the snapshots and releases flags is true unless configured otherwise.

> /Anders
> 
> On Thu, Oct 3, 2013 at 12:08 PM, NRO <no...@gmail.com> wrote:
> 
>> I understand your point, but the explaination you provide is based on how
>> it
>> is implemented...and not on how it is specified.
>> 
>> The fact that maven can resolve the same artifact when it is a dependency
>> means that it is not a limitation but an implementation issue.
>> 
>> That looks bad to me to have to add a fake repository to have Maven resolve
>> the parent SNAPSHOT.
>> 
>> Note that in my example the foo repository does not exist at all neither
>> http://foo URL.
>> It is juste a fake declaration in the settings.xml.
>> 
>> This means that maven at the end, failover and still uses the mirror to go
>> to Nexus and retrieve the SNAPSHOT parent.
>> 
>> Why (repo!=mirror) applies to Parent and not to project dependencies ?
>> 
>> At the end we added the fake repo declaration to all our settings.xml, but
>> that's not very elegant, but it works.
>> 
>> 
>> 
>> --
>> View this message in context:
>> http://maven.40175.n5.nabble.com/Parent-SNAPSHOT-not-resolved-Maven-2-2-1-3-0-4-Nexus-repo-tp5772374p5772379.html
>> Sent from the Maven - Users mailing list archive at Nabble.com.
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>> 
>> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Parent SNAPSHOT not resolved Maven 2.2.1 - 3.0.4 - (Nexus repo)

Posted by Anders Hammar <an...@hammar.net>.
It should be the same for deps as well as parents. One difference could be
if you have a repo declared in the pom (not setiings.xml). It might be that
that repo is only used for deps and not the parent, I don't know.

/Anders


On Thu, Oct 3, 2013 at 12:08 PM, NRO <no...@gmail.com> wrote:

> I understand your point, but the explaination you provide is based on how
> it
> is implemented...and not on how it is specified.
>
> The fact that maven can resolve the same artifact when it is a dependency
> means that it is not a limitation but an implementation issue.
>
> That looks bad to me to have to add a fake repository to have Maven resolve
> the parent SNAPSHOT.
>
> Note that in my example the foo repository does not exist at all neither
> http://foo URL.
> It is juste a fake declaration in the settings.xml.
>
> This means that maven at the end, failover and still uses the mirror to go
> to Nexus and retrieve the SNAPSHOT parent.
>
> Why (repo!=mirror) applies to Parent and not to project dependencies ?
>
> At the end we added the fake repo declaration to all our settings.xml, but
> that's not very elegant, but it works.
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Parent-SNAPSHOT-not-resolved-Maven-2-2-1-3-0-4-Nexus-repo-tp5772374p5772379.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Parent SNAPSHOT not resolved Maven 2.2.1 - 3.0.4 - (Nexus repo)

Posted by NRO <no...@gmail.com>.
I understand your point, but the explaination you provide is based on how it
is implemented...and not on how it is specified.

The fact that maven can resolve the same artifact when it is a dependency
means that it is not a limitation but an implementation issue.

That looks bad to me to have to add a fake repository to have Maven resolve
the parent SNAPSHOT.

Note that in my example the foo repository does not exist at all neither
http://foo URL. 
It is juste a fake declaration in the settings.xml.

This means that maven at the end, failover and still uses the mirror to go
to Nexus and retrieve the SNAPSHOT parent.

Why (repo!=mirror) applies to Parent and not to project dependencies ?

At the end we added the fake repo declaration to all our settings.xml, but
that's not very elegant, but it works.



--
View this message in context: http://maven.40175.n5.nabble.com/Parent-SNAPSHOT-not-resolved-Maven-2-2-1-3-0-4-Nexus-repo-tp5772374p5772379.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Parent SNAPSHOT not resolved Maven 2.2.1 - 3.0.4 - (Nexus repo)

Posted by Tamás Cservenák <ta...@cservenak.net>.
You wrote it so nicely:

repo != mirror.

So, you have no repo set (only Central, that cannot contain snapshots), so
there is no "candidate" repo at all present to even try to get a snapshot
from.

Mirror on the other hand is NOT a repo, it merely _redirects_ existing
reposes to some other URL.





On Thu, Oct 3, 2013 at 10:33 AM, NRO <no...@gmail.com> wrote:

>
> But to MHO, there is a bug in the Maven code when doing parent snapshot
> resolution. If the parent snapshot is not present in the local repo AND
> there is no <repository> entry in the settings.xml file, it simply fails.
> It
> does not try the mirror.
>

Re: Parent SNAPSHOT not resolved Maven 2.2.1 - 3.0.4 - (Nexus repo)

Posted by Anders Hammar <an...@hammar.net>.
As I believe this was discussed on the Nexus list, the reason is what you
state. You have no repo defined in settings.xml, which means that only the
default central repo declaration is used which is only configured for
releases and not snapshots. And you're trying to retreieve a snapshot.
So this wouldn't be a bug in core.

/Anders


On Thu, Oct 3, 2013 at 10:33 AM, NRO <no...@gmail.com> wrote:

> A maven project which have a parent SNAPSHOT cannot be resolved when :
>
> a) the Parent SNAPSHOT pom is not present in the local maven repository
> b) the Parent SNAPSHOT pom is deployed in a Nexus repository by another
> developer.
> c) settings.xml has a mirror redirecting all (*) to Nexus
> d) there is no <repository> entry in the settings.xml file as Nexus is used
> for all resolutions.
>
> Easy to reproduce on Maven 2.2.1, 3.0.4 and probably earlier releases.
>
> - If the SNAPSHOT parent is instead used as a dependency of the project
> then
> maven can resolve the dependency and retrieve it from Nexus.
>
> Work around:
>
> If you add a dumb repo entry in the settings.xml file, then it works.
>
> Exemple of such entry is a fake repository and it does not even have to be
> a
> snapshot repo...
>
> settings.xml
>
> [...]
> <repositories>
>         <repository>
>                 <id>foo</id>
>                 <url>http://foo</url>
>         </repository>
> </repositories>
> [...]
>
> simplest work around.
>
> But to MHO, there is a bug in the Maven code when doing parent snapshot
> resolution. If the parent snapshot is not present in the local repo AND
> there is no <repository> entry in the settings.xml file, it simply fails.
> It
> does not try the mirror.
>
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Parent-SNAPSHOT-not-resolved-Maven-2-2-1-3-0-4-Nexus-repo-tp5772374.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>