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

Integration testing ignores default values

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      If we don't set in archetype.properties the parameters for which a default value was defined in archetype-metadata.xml, running mvn clean integration-test gives an error as a value is expected for all parameters in the template and the default value is not used.

      $ mvn clean integration-test
      [INFO] Scanning for projects...
      [INFO]
      [INFO] -----------------< com.archetype.test:test-archetype >------------------
      [INFO] Building test-archetype 0.0.1-SNAPSHOT
      [INFO] --------------------------[ maven-archetype ]---------------------------
      [INFO]
      [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ test-archetype ---
      [INFO] Deleting C:\Users\sdan\MSP\aa\test-archetype\target
      [INFO]
      [INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ test-archetype ---
      [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
      [INFO] Copying 3 resources
      [INFO]
      [INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ test-archetype ---
      [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
      [INFO] Copying 4 resources
      [INFO]
      [INFO] --- maven-archetype-plugin:3.1.1:jar (default-jar) @ test-archetype ---
      [INFO] Building archetype jar: C:\Users\sdan\MSP\aa\test-archetype\target\test-archetype-0.0.1-SNAPSHOT
      [INFO]
      [INFO] --- maven-archetype-plugin:3.1.1:integration-test (default-integration-test) @ test-archetype ---
      [INFO] Processing Archetype IT project: it1
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD FAILURE
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 1.252 s
      [INFO] Finished at: 2019-08-07T09:06:42+03:00
      [INFO] ------------------------------------------------------------------------
      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.1.1:integration-test (default-integration-test) on project test-archetype:
      [ERROR] Archetype IT 'it1' failed: Missing required properties in archetype.properties: service-name
      [ERROR] -> [Help 1]
      [ERROR]
      [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
      [ERROR] Re-run Maven using the -X switch to enable full debug logging.
      [ERROR]
      [ERROR] For more information about the errors and possible solutions, please read the following articles:
      [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
      
      

      test-archetype.zip

      After the fix people will still define all the parameters in archetype.properties but if they want to use the default value, they will give no value to the parameter. For example:

      parameter_X=

      Here is the pull request with the fix: https://github.com/apache/maven-archetype/pull/31/files

      Attached is also a working example with my fix. In archetype.properties the property service-name is not defined but has a default value in archetype-metadata.xml.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            sjaranowski Slawomir Jaranowski
            sorin86-dan Sorin Dan
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment