title: Maven with an explicit finalName won't work properly
body: <p><strong>1. Background</strong></p>
  
  <p>My maven project has a lot of modules and submodules with <code>jars</code> and <code>wars</code> and everything works. I also can deploy it on server without any problem. </p>
  
  <p>I decided to follow <a href="https://stackoverflow.com/questions/9435460/maven-naming-conventions-for-hierarchical-multiple-module-projects/9461593#9461593">this maven naming conversion</a>, I am making some tests with <code>project.name</code> and <code>project.build.finalName</code> to have an appropriate name. </p>
  
  <p>The pattern I defined to create <code>project.name</code> for the root artifact is <code>company-${project.artifactId}</code> and for the modules and sub-modules is <code>${project.parent.name}-${project.artifactId}</code>:</p>
  
  <ul>
  <li>company-any-artifact-any-module1</li>
  <li>company-any-artifact-any-module2-any-submodule1</li>
  <li>company-any-artifact-any-module2-any-submodule2</li>
  </ul>
  
  <p>The pattern for <code>project.build.finalName</code> is <code>${project.name}-${project.version}</code>:</p>
  
  <ul>
  <li>company-any-artifact-any-module1-1.0.jar</li>
  <li>company-any-artifact-any-module2-any-submodule1-2.0.jar</li>
  <li>company-any-artifact-any-module2-any-submodule2-3.0.war</li>
  </ul>
  
  <p>But instead of producing these files, maven gives me a <code>StackOverflowError</code>.</p>
  
  <p><strong>2. The example to reproduce the error</strong></p>
  
  <p>You can clone this example from github: <a href="https://github.com/pauloleitemoreira/company-any-artifact" rel="nofollow noreferrer">https://github.com/pauloleitemoreira/company-any-artifact</a></p>
  
  <p>In github, there is the <a href="https://github.com/pauloleitemoreira/company-any-artifact/tree/master" rel="nofollow noreferrer"><code>master</code></a> branch, that will reproduce this error. And there is <a href="https://github.com/pauloleitemoreira/company-any-artifact/tree/only-modules" rel="nofollow noreferrer"><code>only-modules</code></a> branch, that is a working example that uses <code>${project.parent.name}</code> to generate the jar <code>finalName</code> as I want. </p>
  
  <p>Let's consider a maven project with one root pom artifact, one pom module and one submodule.</p>
  
  <pre><code>-any-artifact
       |
       |-any-module      
             |
             |-any-submodule
  </code></pre>
  
  <p><strong>2.1 any-artifact</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com.company&lt;/groupId&gt;
      &lt;artifactId&gt;any-artifact&lt;/artifactId&gt;
      &lt;packaging&gt;pom&lt;/packaging&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  
      &lt;name&gt;company-${project.artifactId}&lt;/name&gt;
  
      &lt;modules&gt;
          &lt;module&gt;any-module&lt;/module&gt;
      &lt;/modules&gt;
  
      &lt;!-- if remove finalName, maven will not throw StackOverflow error --&gt;
      &lt;build&gt;
          &lt;finalName&gt;${project.name}-${project.version}&lt;/finalName&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p><strong>2.2 any-module</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;parent&gt;
          &lt;artifactId&gt;any-artifact&lt;/artifactId&gt;
          &lt;groupId&gt;com.company&lt;/groupId&gt;
          &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;/parent&gt;
  
      &lt;groupId&gt;com.company.any-artifact&lt;/groupId&gt;
      &lt;artifactId&gt;any-module&lt;/artifactId&gt;
      &lt;packaging&gt;pom&lt;/packaging&gt;
  
      &lt;name&gt;${project.parent.name}-${project.artifactId}&lt;/name&gt;
  
      &lt;modules&gt;
          &lt;module&gt;any-submodule&lt;/module&gt;
      &lt;/modules&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p><strong>2.3 any-submodule</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;parent&gt;
          &lt;artifactId&gt;any-module&lt;/artifactId&gt;
          &lt;groupId&gt;com.company.any-artifact&lt;/groupId&gt;
          &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;/parent&gt;
  
      &lt;groupId&gt;com.company.any-artifact.any-module&lt;/groupId&gt;
      &lt;artifactId&gt;any-submodule&lt;/artifactId&gt;
  
      &lt;name&gt;${project.parent.name}-${project.artifactId}&lt;/name&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p><strong>3. Problem</strong></p>
  
  <p>When try to <code>mvn clean install</code>, maven gives me a <code>StackOverflowError</code>:</p>
  
  <pre><code>Exception in thread "main" java.lang.StackOverflowError
      at org.codehaus.plexus.util.StringUtils.isEmpty(StringUtils.java:177)
      at org.codehaus.plexus.util.introspection.ReflectionValueExtractor.evaluate(ReflectionValueExtractor.java:194)
      at org.codehaus.plexus.util.introspection.ReflectionValueExtractor.evaluate(ReflectionValueExtractor.java:163)
      at org.apache.maven.plugin.PluginParameterExpressionEvaluator.evaluate(PluginParameterExpressionEvaluator.java:266)
      at org.apache.maven.plugin.PluginParameterExpressionEvaluator.evaluate(PluginParameterExpressionEvaluator.java:143)
      at org.apache.maven.plugin.PluginParameterExpressionEvaluator.evaluate(PluginParameterExpressionEvaluator.java:174)
      at org.apache.maven.plugin.PluginParameterExpressionEvaluator.evaluate(PluginParameterExpressionEvaluator.java:143)
      at org.apache.maven.plugin.PluginParameterExpressionEvaluator.evaluate(PluginParameterExpressionEvaluator.java:429)
      at org.apache.maven.plugin.PluginParameterExpressionEvaluator.evaluate(PluginParameterExpressionEvaluator.java:143)
      at org.apache.maven.plugin.PluginParameterExpressionEvaluator.evaluate(PluginParameterExpressionEvaluator.java:174)
      at org.apache.maven.plugin.PluginParameterExpressionEvaluator.evaluate(PluginParameterExpressionEvaluator.java:143)
      at org.apache.maven.plugin.PluginParameterExpressionEvaluator.evaluate(PluginParameterExpressionEvaluator.java:429)
      at org.apache.maven.plugin.PluginParameterExpressionEvaluator.evaluate(PluginParameterExpressionEvaluator.java:143)
      at org.apache.maven.plugin.PluginParameterExpressionEvaluator.evaluate(PluginParameterExpressionEvaluator.java:174)
      at org.apache.maven.plugin.PluginParameterExpressionEvaluator.evaluate(PluginParameterExpressionEvaluator.java:143)
  </code></pre>
  
  <p>It is important to know that the error occurs only when we are working with submodules.  If we create a project with a root POM artifact and a jar module,  the error don't occur.  </p>
  
  <p><strong>4. The question</strong></p>
  
  <p>Why this error occurs only when we are using submodules? </p>
  
  <p>Any suggestion to solve my problem? Should I forget it and set <code>project.name</code> and <code>project.build.fileName</code> manually for each project, following the pattern I want?</p>
  
  <p><strong>IMPORTANT UPDATED:</strong></p>
  
  <p>Some answers just say to use <strong><code>&amp;{parent.name}</code></strong>, but <strong>it does not work</strong>. Please, it is a question with a bounty, consider test your solution with <code>Maven version 3.3.9</code>, before answering this question.</p>
  
  <p><em>Maven version 3.3.9</em></p>
  
  <p><strong><em>Edit</em></strong> - Adding details to the question with the phase when the error occurs, things are working fine until the <code>prepare-package</code> phase, but the StackOverflow occurs at the <code>package</code> phase on maven lifecycle for the project.</p>