I wish to define the distributionManagement values for all my projects in a 
common parent pom.

parent pom.xml

   <url>${site.url}</url>

   <properties>
      <site.base.url>file:///Users/macuser/Sites</site.base.url>
      <site.url>${site.base.url}/${project.artifactId}</site.url>
   </properties>
   
   <distributionManagement>
      <site>
         <id>local</id>
         <url>${site.url}</url>
      </site>
   </distributionManagement>


The effective pom for this is as expected:

  <url>file:///Users/macuser/Sites/parent-pom</url>
  <distributionManagement>
    <site>
      <id>local</id>
      <url>file:///Users/macuser/Sites/parent-pom</url>
    </site>
  </distributionManagement>
  <properties>
    <site.base.url>file:///Users/macuser/Sites</site.base.url>
    <site.url>file:///Users/macuser/Sites/parent-pom</site.url>
  </properties>


In child pom, I specify the parent pom only, no other elements.  I expect the 
distributionManagement to inherit from the parent.

<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>mlgiroux</groupId>
    <artifactId>parent-pom</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <relativePath></relativePath>
  </parent>
  <artifactId>parent-pom-test</artifactId>
  <packaging>pom</packaging>
</project>

The effective pom is strange:

  <url>file:///Users/macuser/Sites/parent-pom-test/parent-pom-test</url>
  <distributionManagement>
    <site>
      <id>local</id>
      <url>file:///Users/macuser/Sites/parent-pom-test/parent-pom-test</url>
    </site>
  </distributionManagement>
  <properties>
    <site.base.url>file:///Users/macuser/Sites</site.base.url>
    <site.url>file:///Users/macuser/Sites/parent-pom-test</site.url>
  </properties>

The site.url property has been resolved as I expected, but the <url> elements 
for project.url and distributionManagement.site.url that were defined in the 
parent as ${site.url} have the artifactId twice.  As if I had specified 
${site.base.url}/${project.artifactId}/${project.artifactId}

Now, if I add the url and distributionManagement to the child pom as:
   <url>${site.url}</url>

   <distributionManagement>
      <site>
         <id>local</id>
         <url>${site.url}</url>
      </site>
   </distributionManagement>


The effective pom is exactly as I expect with the artifactId specified exactly 
once in the effective values.

  <url>file:///Users/macuser/Sites/parent-pom-test</url>
  <distributionManagement>
    <site>
      <id>local</id>
      <url>file:///Users/macuser/Sites/parent-pom-test</url>
    </site>
  </distributionManagement>


I think it is important to point out that the child is NOT a sub module of the 
parent.  It specifies a parent, but it is itself a root module.

This feels like a defect to me.

Michael Giroux

Reply via email to