You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2021/07/06 17:02:24 UTC

[GitHub] [maven-archetype] mbenson commented on a change in pull request #64: [ARCHETYPE-406][ARCHETYPE-558][ARCHETYPE-562] Support full Velocity default value expressions for required properties; properly handle ordering among same

mbenson commented on a change in pull request #64:
URL: https://github.com/apache/maven-archetype/pull/64#discussion_r664731952



##########
File path: maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeGenerationConfigurator.java
##########
@@ -313,46 +311,23 @@ else if ( !archetypeGenerationQueryer.confirmConfiguration( archetypeConfigurati
         request.setProperties( properties );
     }
 
-    private String getTransitiveDefaultValue( String defaultValue, ArchetypeConfiguration archetypeConfiguration,
-                                              String requiredProperty, Context context )
+    private String getTransitiveDefaultValue( String defaultValue, String requiredProperty, Context context )
     {
-        String result = defaultValue;
-        if ( null == result )
+        if ( StringUtils.contains( defaultValue, "${" ) )
         {
-            return null;
-        }
-        for ( String property : archetypeConfiguration.getRequiredProperties() )
-        {
-            if ( result.indexOf( "${" + property + "}" ) >= 0 )
+            try ( StringWriter stringWriter = new StringWriter() )
             {
-
-                result = StringUtils.replace( result, "${" + property + "}",
-                                              archetypeConfiguration.getProperty( property ) );
+                Velocity.evaluate( context, stringWriter, requiredProperty, defaultValue );

Review comment:
       This is the default value of some required property of the archetype, which in this context has been determined to appear to contain expansion syntax (`${`) indicative of the whole being intended to be interpreted as a Velocity expression. Does that make sense?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org