Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-5784

SO question regarding replacing name tag with ${project.parent.name} does not work in multi module builds.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Not A Problem
    • None
    • None
    • None

    Description

      Based on the following stackoverflow question: http://stackoverflow.com/questions/29013184/maven-support-for-property-substitution-in-project-name
      The described behaviour looks wrong to me.

      The question is: Is it bug?

      Copied content from SO:

      In a multi module project, I want to reuse the project name from the parent pom as part of the project name for each module. The only info I have managed to find says that property substitution is not allowed in /project/(groupId|artifactId|version), which suggests that it is allowed in /project/name.

      I have tried setting /project/name to `${project.parent.name} - Some Module` in the pom for a sub module, but it seems that this property is only substituted selectively: sometimes the literal string `${project.parent.name} - Some Module` is used, sometimes the substitution works.

      In the reactor summary, for example, the literal string is used:

          [INFO] ------------------------------------------------------------------------
          [INFO] Reactor Summary:
          [INFO]
          [INFO] Glorious Parent .................................... SUCCESS [  0.016 s]
          [INFO] ${project.parent.name} - Some Module ............... SUCCESS [  2.482 s]
          [INFO] ------------------------------------------------------------------------
          [INFO] BUILD SUCCESS
          [INFO] ------------------------------------------------------------------------
      

      Same thing for the archiver when creating a manifest file using `<addDefaultSpecificationEntries>` or `<addDefaultImplementationEntries>`.

      However, if I manually add manifest entries, the substitution happens:

          <manifestEntries>
              <Project-Name>${project.name}</Project-Name>
          </manifestEntries>
      

      Results in `Project-Name: Glorious Parent - Some Module`

      Is there any way to know when or where the substitution will happen, or - preferrably - to make it happen everywhere, all the time?

      *Example pom.xml: (parent)*

          <?xml version="1.0" encoding="UTF-8"?>
          <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>dummy-group-id</groupId>
          	<artifactId>dummy-parent</artifactId>
          	<version>1.0</version>
          	<packaging>pom</packaging>
          	<name>Glorious Parent</name>
          	
          	<properties>
          		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
          	</properties>
          
            <modules>
              <module>child</module>
            </modules>
          </project>
      

      *Example child/pom.xml: (module)*

          <?xml version="1.0" encoding="UTF-8"?>
          <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>
          	
          	<parent>
          		<groupId>dummy-group-id</groupId>
          		<artifactId>dummy-parent</artifactId>
          		<version>1.0</version>
          	</parent>
          
          	<artifactId>dummy-test-artifact</artifactId>
          	<name>${project.parent.name} - Some Module</name>
          
          	<build>
          		<plugins>
          			<plugin>
          				<groupId>org.apache.maven.plugins</groupId>
          				<artifactId>maven-jar-plugin</artifactId>
          				<version>2.6</version>
          				<configuration>
          					<archive>
          						<manifest>
          							<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
          							<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
          						</manifest>
          						<manifestEntries>
          							<Project-Name>${project.name}</Project-Name>
          						</manifestEntries>
          					</archive>
          				</configuration>
          			</plugin>
          		</plugins>
          	</build>
          	
          </project>
      

      *Resulting manifest:*

          Manifest-Version: 1.0
          Implementation-Title: ${project.parent.name} - Some Module
          Project-Name: Glorious Parent - Some Module
          Implementation-Version: 1.0
          Archiver-Version: Plexus Archiver
          Built-By: developer
          Specification-Title: ${project.parent.name} - Some Module
          Implementation-Vendor-Id: dummy-group-id
          Created-By: Apache Maven 3.2.5
          Build-Jdk: 1.8.0_31
          Specification-Version: 1.0
      

      *File structure:*

      myproject/
      pom.xml
      child/
      pom.xml

      *Maven version:* 3.2.5

      Attachments

        Issue Links

          Activity

            People

              schulte77 Christian Schulte
              khmarbaise Karl Heinz Marbaise
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: