Uploaded image for project: 'Maven Archetype'
  1. Maven Archetype
  2. ARCHETYPE-487

Input validation for required properties defined in artifact descriptor

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0.0
    • Component/s: Archetypes, Generator, Plugin
    • Labels:
      None

      Description

      Add the possibility to define validation regular expressions for required properties in artifact descriptors.
      Use the regular expressions to validate user input (and ask the user to try again if the expression doesn't match)

      here's an example of a property that is required by the archetype to be only lower case alphabet characters:

      — in archetype-metadata.xml :
      <requiredProperty key="username">
      <validationRegex>^[a-z]*$</validationRegex>
      </requiredProperty>

      — at prompt :
      Define value for property 'username' (should match expression '^[a-z]*$'): John
      Value does not match the expression, please try again: john
      Define value for property...

        Issue Links

          Activity

          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user mryan43 closed the pull request at:

          https://github.com/apache/maven-archetype/pull/7

          Show
          githubbot ASF GitHub Bot added a comment - Github user mryan43 closed the pull request at: https://github.com/apache/maven-archetype/pull/7
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user mryan43 commented on the issue:

          https://github.com/apache/maven-archetype/pull/7

          thx

          Show
          githubbot ASF GitHub Bot added a comment - Github user mryan43 commented on the issue: https://github.com/apache/maven-archetype/pull/7 thx
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user michael-o commented on the issue:

          https://github.com/apache/maven-archetype/pull/7

          @mryan43 Please close.

          Show
          githubbot ASF GitHub Bot added a comment - Github user michael-o commented on the issue: https://github.com/apache/maven-archetype/pull/7 @mryan43 Please close.
          Hide
          michael-o Michael Osipov added a comment -
          Show
          michael-o Michael Osipov added a comment - Fixed with 147ff3dc6086e947faf8bead6b8ee70c584da1b5 .
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user michael-o commented on the issue:

          https://github.com/apache/maven-archetype/pull/7

          @ptahchiev Thanks for pinping, this got lost on my desk. I will have a look later this day.

          Show
          githubbot ASF GitHub Bot added a comment - Github user michael-o commented on the issue: https://github.com/apache/maven-archetype/pull/7 @ptahchiev Thanks for pinping, this got lost on my desk. I will have a look later this day.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user ptahchiev commented on the issue:

          https://github.com/apache/maven-archetype/pull/7

          @michael-o Michael, are you happy with the squash? Let's move this forward I want to plan a release of the archetype.

          Show
          githubbot ASF GitHub Bot added a comment - Github user ptahchiev commented on the issue: https://github.com/apache/maven-archetype/pull/7 @michael-o Michael, are you happy with the squash? Let's move this forward I want to plan a release of the archetype.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user mryan43 commented on the issue:

          https://github.com/apache/maven-archetype/pull/7

          squashed

          Show
          githubbot ASF GitHub Bot added a comment - Github user mryan43 commented on the issue: https://github.com/apache/maven-archetype/pull/7 squashed
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user michael-o commented on the issue:

          https://github.com/apache/maven-archetype/pull/7

          @mryan43 Looks way better now. Please squash, I will test and pull.

          Show
          githubbot ASF GitHub Bot added a comment - Github user michael-o commented on the issue: https://github.com/apache/maven-archetype/pull/7 @mryan43 Looks way better now. Please squash, I will test and pull.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user michael-o commented on a diff in the pull request:

          https://github.com/apache/maven-archetype/pull/7#discussion_r65342854

          — Diff: maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeConfiguration.java —
          @@ -19,12 +19,15 @@

          • under the License.
            */

          +import org.apache.maven.archetype.common.Constants;
          +import org.codehaus.plexus.util.StringUtils;
          — End diff –

          Yes, though it was the right thing to do. It is still unrelated to this PR. Code improvements are always welcome and shall be made with separate PRs.

          Thank you!

          Show
          githubbot ASF GitHub Bot added a comment - Github user michael-o commented on a diff in the pull request: https://github.com/apache/maven-archetype/pull/7#discussion_r65342854 — Diff: maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeConfiguration.java — @@ -19,12 +19,15 @@ under the License. */ +import org.apache.maven.archetype.common.Constants; +import org.codehaus.plexus.util.StringUtils; — End diff – Yes, though it was the right thing to do. It is still unrelated to this PR. Code improvements are always welcome and shall be made with separate PRs. Thank you!
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user mryan43 commented on a diff in the pull request:

          https://github.com/apache/maven-archetype/pull/7#discussion_r65342161

          — Diff: maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeConfiguration.java —
          @@ -19,12 +19,15 @@

          • under the License.
            */

          +import org.apache.maven.archetype.common.Constants;
          +import org.codehaus.plexus.util.StringUtils;
          — End diff –

          okay, I'll put it back to the wrong place (it's the only file where the org.* imports are after the java.* imports)

          Show
          githubbot ASF GitHub Bot added a comment - Github user mryan43 commented on a diff in the pull request: https://github.com/apache/maven-archetype/pull/7#discussion_r65342161 — Diff: maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeConfiguration.java — @@ -19,12 +19,15 @@ under the License. */ +import org.apache.maven.archetype.common.Constants; +import org.codehaus.plexus.util.StringUtils; — End diff – okay, I'll put it back to the wrong place (it's the only file where the org.* imports are after the java.* imports)
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user michael-o commented on a diff in the pull request:

          https://github.com/apache/maven-archetype/pull/7#discussion_r65337809

          — Diff: maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeConfiguration.java —
          @@ -19,12 +19,15 @@

          • under the License.
            */

          +import org.apache.maven.archetype.common.Constants;
          +import org.codehaus.plexus.util.StringUtils;
          — End diff –

          This is still an unrelated change because those imports are already present a few lines below and have been moved to this position. An unrelated change for me.

          Show
          githubbot ASF GitHub Bot added a comment - Github user michael-o commented on a diff in the pull request: https://github.com/apache/maven-archetype/pull/7#discussion_r65337809 — Diff: maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeConfiguration.java — @@ -19,12 +19,15 @@ under the License. */ +import org.apache.maven.archetype.common.Constants; +import org.codehaus.plexus.util.StringUtils; — End diff – This is still an unrelated change because those imports are already present a few lines below and have been moved to this position. An unrelated change for me.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user mryan43 commented on the pull request:

          https://github.com/apache/maven-archetype/pull/7

          Hi @stain, I have integrated the feedback from @michael-o, let me know if you need anything else.

          Show
          githubbot ASF GitHub Bot added a comment - Github user mryan43 commented on the pull request: https://github.com/apache/maven-archetype/pull/7 Hi @stain, I have integrated the feedback from @michael-o, let me know if you need anything else.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user mryan43 commented on a diff in the pull request:

          https://github.com/apache/maven-archetype/pull/7#discussion_r65317792

          — Diff: maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeConfiguration.java —
          @@ -19,12 +19,15 @@

          • under the License.
            */

          +import org.apache.maven.archetype.common.Constants;
          +import org.codehaus.plexus.util.StringUtils;
          — End diff –

          Dropping this breaks compilation...

          Show
          githubbot ASF GitHub Bot added a comment - Github user mryan43 commented on a diff in the pull request: https://github.com/apache/maven-archetype/pull/7#discussion_r65317792 — Diff: maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeConfiguration.java — @@ -19,12 +19,15 @@ under the License. */ +import org.apache.maven.archetype.common.Constants; +import org.codehaus.plexus.util.StringUtils; — End diff – Dropping this breaks compilation...
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user michael-o commented on the pull request:

          https://github.com/apache/maven-archetype/pull/7

          @stain I did already in April and wrote how to improve the PR. Nothing has happened.

          Show
          githubbot ASF GitHub Bot added a comment - Github user michael-o commented on the pull request: https://github.com/apache/maven-archetype/pull/7 @stain I did already in April and wrote how to improve the PR. Nothing has happened.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user stain commented on the pull request:

          https://github.com/apache/maven-archetype/pull/7

          Hi, @mryan43, have you had a chance to review @michael-o's comments on this PR?

          Show
          githubbot ASF GitHub Bot added a comment - Github user stain commented on the pull request: https://github.com/apache/maven-archetype/pull/7 Hi, @mryan43, have you had a chance to review @michael-o's comments on this PR?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user michael-o commented on the pull request:

          https://github.com/apache/maven-archetype/pull/7#issuecomment-208408173

          Just added a few comments. When they are resolved, I will merge.

          Show
          githubbot ASF GitHub Bot added a comment - Github user michael-o commented on the pull request: https://github.com/apache/maven-archetype/pull/7#issuecomment-208408173 Just added a few comments. When they are resolved, I will merge.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user michael-o commented on a diff in the pull request:

          https://github.com/apache/maven-archetype/pull/7#discussion_r59226880

          — Diff: maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeGenerationConfigurator.java —
          @@ -197,7 +197,11 @@ else if ( archetypeArtifactManager.isOldArchetype( ad.getGroupId(), ad.getArtifa
          value = getTransitiveDefaultValue( value, archetypeConfiguration, requiredProperty,
          context );

          • value = archetypeGenerationQueryer.getPropertyValue( requiredProperty, value );
            + value = archetypeGenerationQueryer.getPropertyValue(
            + requiredProperty,
            + value,
            + archetypeConfiguration.getPropertyValidationRegex( requiredProperty )
            + );
              • End diff –

          Condense in two lines please.

          Show
          githubbot ASF GitHub Bot added a comment - Github user michael-o commented on a diff in the pull request: https://github.com/apache/maven-archetype/pull/7#discussion_r59226880 — Diff: maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeGenerationConfigurator.java — @@ -197,7 +197,11 @@ else if ( archetypeArtifactManager.isOldArchetype( ad.getGroupId(), ad.getArtifa value = getTransitiveDefaultValue( value, archetypeConfiguration, requiredProperty, context ); value = archetypeGenerationQueryer.getPropertyValue( requiredProperty, value ); + value = archetypeGenerationQueryer.getPropertyValue( + requiredProperty, + value, + archetypeConfiguration.getPropertyValidationRegex( requiredProperty ) + ); End diff – Condense in two lines please.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user michael-o commented on a diff in the pull request:

          https://github.com/apache/maven-archetype/pull/7#discussion_r59226728

          — Diff: maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeFactory.java —
          @@ -216,8 +220,8 @@ public ArchetypeConfiguration createArchetypeConfiguration( MavenProject project
          configuration.addRequiredProperty( requiredProperty );

          configuration.setProperty( requiredProperty, properties.getProperty( requiredProperty ) );

          • getLogger().debug( "Setting property " + requiredProperty + "="
          • + configuration.getProperty( requiredProperty ) );
            + getLogger().debug(
            + "Setting property " + requiredProperty + "=" + configuration.getProperty( requiredProperty ) );
              • End diff –

          Unrelated change, please drop.

          Show
          githubbot ASF GitHub Bot added a comment - Github user michael-o commented on a diff in the pull request: https://github.com/apache/maven-archetype/pull/7#discussion_r59226728 — Diff: maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeFactory.java — @@ -216,8 +220,8 @@ public ArchetypeConfiguration createArchetypeConfiguration( MavenProject project configuration.addRequiredProperty( requiredProperty ); configuration.setProperty( requiredProperty, properties.getProperty( requiredProperty ) ); getLogger().debug( "Setting property " + requiredProperty + "=" + configuration.getProperty( requiredProperty ) ); + getLogger().debug( + "Setting property " + requiredProperty + "=" + configuration.getProperty( requiredProperty ) ); End diff – Unrelated change, please drop.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user michael-o commented on a diff in the pull request:

          https://github.com/apache/maven-archetype/pull/7#discussion_r59226707

          — Diff: maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeFactory.java —
          @@ -110,9 +108,8 @@ private void addRequiredProperty( ArchetypeConfiguration configuration, Properti
          }
          }

          • @SuppressWarnings( "checkstyle:linelength" )
          • public ArchetypeConfiguration createArchetypeConfiguration( org.apache.maven.archetype.metadata.ArchetypeDescriptor archetypeDescriptor,
          • Properties properties )
            + public ArchetypeConfiguration createArchetypeConfiguration(
            + org.apache.maven.archetype.metadata.ArchetypeDescriptor archetypeDescriptor, Properties properties )
              • End diff –

          Unrelated change, please drop.

          Show
          githubbot ASF GitHub Bot added a comment - Github user michael-o commented on a diff in the pull request: https://github.com/apache/maven-archetype/pull/7#discussion_r59226707 — Diff: maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeFactory.java — @@ -110,9 +108,8 @@ private void addRequiredProperty( ArchetypeConfiguration configuration, Properti } } @SuppressWarnings( "checkstyle:linelength" ) public ArchetypeConfiguration createArchetypeConfiguration( org.apache.maven.archetype.metadata.ArchetypeDescriptor archetypeDescriptor, Properties properties ) + public ArchetypeConfiguration createArchetypeConfiguration( + org.apache.maven.archetype.metadata.ArchetypeDescriptor archetypeDescriptor, Properties properties ) End diff – Unrelated change, please drop.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user michael-o commented on a diff in the pull request:

          https://github.com/apache/maven-archetype/pull/7#discussion_r59226693

          — Diff: maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeFactory.java —
          @@ -79,9 +78,8 @@ else if ( defaultValue != null )
          getLogger().debug( "Setting property " + key + "=" + configuration.getProperty( key ) );
          }

          • @SuppressWarnings( "checkstyle:linelength" )
          • public ArchetypeConfiguration createArchetypeConfiguration( org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor archetypeDescriptor,
          • Properties properties )
            + public ArchetypeConfiguration createArchetypeConfiguration(
            + org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor archetypeDescriptor, Properties properties )
              • End diff –

          Unrelated change, please drop.

          Show
          githubbot ASF GitHub Bot added a comment - Github user michael-o commented on a diff in the pull request: https://github.com/apache/maven-archetype/pull/7#discussion_r59226693 — Diff: maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeFactory.java — @@ -79,9 +78,8 @@ else if ( defaultValue != null ) getLogger().debug( "Setting property " + key + "=" + configuration.getProperty( key ) ); } @SuppressWarnings( "checkstyle:linelength" ) public ArchetypeConfiguration createArchetypeConfiguration( org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor archetypeDescriptor, Properties properties ) + public ArchetypeConfiguration createArchetypeConfiguration( + org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor archetypeDescriptor, Properties properties ) End diff – Unrelated change, please drop.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user michael-o commented on a diff in the pull request:

          https://github.com/apache/maven-archetype/pull/7#discussion_r59225929

          — Diff: maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeConfiguration.java —
          @@ -19,12 +19,15 @@

          • under the License.
            */

          +import org.apache.maven.archetype.common.Constants;
          +import org.codehaus.plexus.util.StringUtils;
          — End diff –

          Unrelated change, please drop.

          Show
          githubbot ASF GitHub Bot added a comment - Github user michael-o commented on a diff in the pull request: https://github.com/apache/maven-archetype/pull/7#discussion_r59225929 — Diff: maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeConfiguration.java — @@ -19,12 +19,15 @@ under the License. */ +import org.apache.maven.archetype.common.Constants; +import org.codehaus.plexus.util.StringUtils; — End diff – Unrelated change, please drop.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user LIttleAncientForestKami commented on the pull request:

          https://github.com/apache/maven-archetype/pull/7#issuecomment-208083355

          Hiya, @michael-o, can anything be done here to help?

          Show
          githubbot ASF GitHub Bot added a comment - Github user LIttleAncientForestKami commented on the pull request: https://github.com/apache/maven-archetype/pull/7#issuecomment-208083355 Hiya, @michael-o, can anything be done here to help?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user mryan43 commented on the pull request:

          https://github.com/apache/maven-archetype/pull/7#issuecomment-149202034

          Any news on this one ?

          Show
          githubbot ASF GitHub Bot added a comment - Github user mryan43 commented on the pull request: https://github.com/apache/maven-archetype/pull/7#issuecomment-149202034 Any news on this one ?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user michael-o commented on the pull request:

          https://github.com/apache/maven-archetype/pull/7#issuecomment-143424312

          There hasn't much activity lately. Ping me again next week and I'll review and merge your PR.

          Show
          githubbot ASF GitHub Bot added a comment - Github user michael-o commented on the pull request: https://github.com/apache/maven-archetype/pull/7#issuecomment-143424312 There hasn't much activity lately. Ping me again next week and I'll review and merge your PR.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user mryan43 commented on the pull request:

          https://github.com/apache/maven-archetype/pull/7#issuecomment-143346538

          21 days and nobody replied... is this project dead ?

          Show
          githubbot ASF GitHub Bot added a comment - Github user mryan43 commented on the pull request: https://github.com/apache/maven-archetype/pull/7#issuecomment-143346538 21 days and nobody replied... is this project dead ?
          Show
          mryan Manuel Ryan added a comment - Here are two Stackoverflow questions to highligh the value of this feature : http://stackoverflow.com/questions/15649065/validate-maven-archetype-properties/ http://stackoverflow.com/questions/14101681/maven-archetype-required-property-number
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user m-ryan opened a pull request:

          https://github.com/apache/maven-archetype/pull/7

          ARCHETYPE-487 Add input validation for required properties defined in…

          This pull request implements the following new feature : https://issues.apache.org/jira/browse/ARCHETYPE-487

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/m-ryan/maven-archetype master

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/maven-archetype/pull/7.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #7


          commit 178dc478b801067bcda386d2a44d097bf89e15f4
          Author: Manuel Ryan <ryan@shamu.ch>
          Date: 2015-09-04T11:47:43Z

          ARCHETYPE-487 Add input validation for required properties defined in artifact descriptor


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user m-ryan opened a pull request: https://github.com/apache/maven-archetype/pull/7 ARCHETYPE-487 Add input validation for required properties defined in… This pull request implements the following new feature : https://issues.apache.org/jira/browse/ARCHETYPE-487 You can merge this pull request into a Git repository by running: $ git pull https://github.com/m-ryan/maven-archetype master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/maven-archetype/pull/7.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #7 commit 178dc478b801067bcda386d2a44d097bf89e15f4 Author: Manuel Ryan <ryan@shamu.ch> Date: 2015-09-04T11:47:43Z ARCHETYPE-487 Add input validation for required properties defined in artifact descriptor

            People

            • Assignee:
              michael-o Michael Osipov
              Reporter:
              mryan Manuel Ryan
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development