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: [email protected]
> For additional commands, e-mail: [email protected]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]