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

Building a new 2.X archetype with JarMojo writes out a nonsensical warning

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 2.3
    • 2.4
    • Plugin

    Description

      When packaging a new style 2.0 custom archetype JAR with JarMojo, the build issues a counter-intuitive warning:

      [WARNING] Building an Old (1.x) Archetype: consider migrating it to current 2.x Archetype.
      

      I suppose that it is because of an inverted if condition in JarMojo.checkArchetypeFile(File file)

      JarMojo.java
      package org.apache.maven.archetype.mojos;
      //...
      /**
       * Build a JAR from the current Archetype project.
       *
       * @author rafale
       */
      @Mojo( name = "jar", defaultPhase = LifecyclePhase.PACKAGE, requiresProject = true )
      public class JarMojo extends AbstractMojo
      {
          //...
           private void checkArchetypeFile( File jarFile ) throws MojoExecutionException
           {
               try
               {
                   if ( archetypeArtifactManager.isFileSetArchetype( jarFile ) )
                   {
                       checkFileSetArchetypeFile( jarFile );
                   }
                   else if ( !archetypeArtifactManager.isOldArchetype( jarFile ) )
                   {
                       getLog().warn( "Building an Old (1.x) Archetype: consider migrating it to current 2.x Archetype." );
                   }
                   else
                   {
                       throw new MojoExecutionException( "The current project does not built an archetype" );
                   }
               }
               catch ( UnknownArchetype ua )
               {
                   throw new MojoExecutionException( ua.getMessage(), ua );
               }
      }    
          //...
      }
      

      The condition !archetypeArtifactManager.isOldArchetype( jarFile ) is negated, therefore it issues the warning if the jar is not an old archetype, which makes it downright confusing for new users trying to build a new archetype. On the other hand, when the archetype actually is old, it does not warn at all.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ZiziTheFirst Tomáš Zilvar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: