maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Hutchison (Jira)" <>
Subject [jira] [Created] (ARCHETYPE-612) Required property interactive prompt ordering incorrect when reassigning default for a "core" property
Date Sat, 03 Oct 2020 18:01:00 GMT
David Hutchison created ARCHETYPE-612:

             Summary: Required property interactive prompt ordering incorrect when reassigning
default for a "core" property
                 Key: ARCHETYPE-612
             Project: Maven Archetype
          Issue Type: Bug
          Components: Plugin
    Affects Versions: 3.2.0
            Reporter: David Hutchison

The interactive archetype project generation attempts to be smart in ordering required properties
so that when a default value for one property includes a reference to another, they are asked
for in the correct order. This also however tries to ask the "core" properties (groupId, archetypeId,
version, and package) in a fixed order, and any others in alphabetical order, if they do not
have dependencies. 


I was trying to setup an archetype with a couple of prompts which would be referenced in the
default values for groupId, archetypeId and package. Basically attempting to standardise the
setup for these based on the "application" and "database" the repository was for, so we would
 * groupId: `com.example.${application}.data`
 * archetypeId: `${database}`
 * package: `com.example.${application}.data.${database}`


When doing this however, the package is prompted for before the value it's default depends


This snippet from archetype-metadata.xml will trigger the issue as a test
    <requiredProperty key="a-prop"/>
    <requiredProperty key="groupId">
    <requiredProperty key="artifactId">
    <requiredProperty key="package">
    <requiredProperty key="z-prop"/>

Running this archetype interactively will output something like this:
$ mvn archetype:generate -DarchetypeArtifactId=archetype-test -DarchetypeGroupId=com.devwithimagination.archetypes

[INFO] Generating project in Interactive mode
[INFO] Archetype [com.devwithimagination.archetypes:archetype-test:1.0-SNAPSHOT] found in
catalog local
[INFO] Using property: groupId = com.devwithimagination
Define value for property 'version' 1.0-SNAPSHOT: : 
Define value for property 'package' com.devwithimagination.archetypes.archetype-test.${z-prop}:
Define value for property 'a-prop': 123
Define value for property 'artifactId' test-123: : 
Define value for property 'z-prop': 

So `package` was prompted for before `artifactId` and `z-prop` which it needed for the default
value. In typing this up I just noticed it used the `archetypeArtifactId` in the default value

I have got a failing test case for `RequiredPropertyComparatorTest` which shows the comparator
isn't performing the sort correctly. 

A possible solution for this could be what ARCHETYPE-443 proposed, and respect the property
order defined in the archetype metadata file. Any "core" required properties could still be
prompted for in their default order, unless the archetype author had also included them in
`archetype-metadata.xml`. With that change, it would be up to the archetype author to ensure
that properties are correctly ordered. ARCHETYPE-562 points to other issues with this sort.

I have been having a look at making the sort smarter, but so far I've not been able to keep
the name based ordering working while fixing the property dependency based sort. 


This message was sent by Atlassian Jira

View raw message