title: maven archetype: generate a default value for requiredProperty from a value of an existing property
body: <p>I want to set a default value for a requiredProperty in archetype-metadata.xml such that it is based on another property passed from command line. Say</p>
  
  <pre><code>&lt;requiredProperty key="customProperty"&gt;
          &lt;defaultValue&gt;${artifactId.toUpperCase()}&lt;/defaultValue&gt;
  &lt;/requiredProperty&gt;
  </code></pre>
  
  <p>However, when I use the resulting archetype to generate a new project, it is not the project's artifactId that gets uppercased, but rather the archetype's artifactId. Whereas when I change it to </p>
  
  <pre><code>&lt;requiredProperty key="customProperty"&gt;
          &lt;defaultValue&gt;${artifactId}&lt;/defaultValue&gt;
  &lt;/requiredProperty&gt;
  </code></pre>
  
  <p>I get the project's artifactId as one would expect.</p>
  
  <p>Is there a way to assign a default value for a custom property based on the value of another property?</p>
  
  <p><strong>Note: this happens only in interactive mode.</strong></p>
  
  <h2>How to reproduce:</h2>
  
  <pre><code>mvn -B archetype:generate -DartifactId=archet -DgroupId=com.example -Dversion=1.0-SNAPSHOT -DarchetypeArtifactId=maven-archetype-archetype
  </code></pre>
  
  <p>For some reason, archetype.xml gets generated. It is my understanding, it is an old format. Replaced it with archetype-metadata.xml (minimized for the sake of an example):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;archetype-descriptor name="basic"&gt;
  
      &lt;requiredProperties&gt;
          &lt;requiredProperty key="customPropertyUppercased"&gt;
              &lt;defaultValue&gt;${artifactId.toUpperCase()}&lt;/defaultValue&gt;
          &lt;/requiredProperty&gt;
          &lt;requiredProperty key="customProperty"&gt;
              &lt;defaultValue&gt;${artifactId}&lt;/defaultValue&gt;
          &lt;/requiredProperty&gt;
  
          &lt;!--JUnit version to use in generated project--&gt;
          &lt;requiredProperty key="junit-version"&gt;
              &lt;defaultValue&gt;4.12&lt;/defaultValue&gt;
          &lt;/requiredProperty&gt;
      &lt;/requiredProperties&gt;
  
      &lt;fileSets&gt;
          &lt;fileSet filtered="true" packaged="true"&gt;
              &lt;directory&gt;src/main/java&lt;/directory&gt;
          &lt;/fileSet&gt;
          &lt;fileSet filtered="true" packaged="true"&gt;
              &lt;directory&gt;src/test/java&lt;/directory&gt;
          &lt;/fileSet&gt;
      &lt;/fileSets&gt;
  
  &lt;/archetype-descriptor&gt;
  </code></pre>
  
  <p>A template at <code>./src/main/resources/archetype-resources/src/main/java/App.java:</code></p>
  
  <pre><code>package ${groupId}.${artifactId};
  
  /**
  
  ${customPropertyUppercased}
  
  ${customProperty}
  
  */
  public class App
  {
      public static void main( String[] args )
      {
          System.out.println( "Hello World!" );
      }
  }
  </code></pre>
  
  <p>Generating a new project using the resulting archetype</p>
  
  <pre><code>mvn archetype:generate -DgroupId=com.example -DartifactId=stacktest -DarchetypeArtifactId=archet -DarchetypeGroupId=com.example -DarchetypeCatalog=local
  </code></pre>
  
  <p>with all properties set to default produces <code>stacktest/src/main/java/com/example/App.java:</code></p>
  
  <pre><code>package com.example.stacktest;
  
  /**
  
  ARCHET
  
  stacktest
  
  */
  public class App
  {
      public static void main( String[] args )
      {
          System.out.println( "Hello World!" );
      }
  }
  </code></pre>
  
  <p>So, the customPropertyUppercased is based on the archetype's artifactId, while customProperty is based on the project's artifactId.</p>