maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r748942 - in /maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui: DefaultArchetypeFactory.java DefaultArchetypeGenerationConfigurator.java
Date Sun, 01 Mar 2009 00:25:35 GMT
Author: hboutemy
Date: Sun Mar  1 00:25:34 2009
New Revision: 748942

URL: http://svn.apache.org/viewvc?rev=748942&view=rev
Log:
o restored JDK 1.4 compatibility
o coding style

Modified:
    maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeFactory.java
    maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeGenerationConfigurator.java

Modified: maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeFactory.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeFactory.java?rev=748942&r1=748941&r2=748942&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeFactory.java
(original)
+++ maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeFactory.java
Sun Mar  1 00:25:34 2009
@@ -47,10 +47,10 @@
         configuration.setVersion( archetypeDefinition.getVersion() );
 
         Iterator propertiesIterator = properties.keySet().iterator();
-        while( propertiesIterator.hasNext() )
+        while ( propertiesIterator.hasNext() )
         {
             String property = (String) propertiesIterator.next();
-            if( !Constants.ARCHETYPE_GROUP_ID.equals( property ) && !Constants.ARCHETYPE_ARTIFACT_ID.equals(
property )
+            if ( !Constants.ARCHETYPE_GROUP_ID.equals( property ) && !Constants.ARCHETYPE_ARTIFACT_ID.equals(
property )
                 && !Constants.ARCHETYPE_VERSION.equals( property ) )
             {
                 configuration.addRequiredProperty( property );
@@ -80,7 +80,7 @@
 
         configuration.addRequiredProperty( Constants.GROUP_ID );
         getLogger().debug( "Adding requiredProperty " + Constants.GROUP_ID );
-        if( null != properties.getProperty( Constants.GROUP_ID ) )
+        if ( null != properties.getProperty( Constants.GROUP_ID ) )
         {
             configuration.setProperty( Constants.GROUP_ID, properties.getProperty( Constants.GROUP_ID
) );
             configuration.setDefaultProperty( Constants.GROUP_ID, configuration.getProperty(
Constants.GROUP_ID ) );
@@ -90,7 +90,7 @@
 
         configuration.addRequiredProperty( Constants.ARTIFACT_ID );
         getLogger().debug( "Adding requiredProperty " + Constants.ARTIFACT_ID );
-        if( null != properties.getProperty( Constants.ARTIFACT_ID ) )
+        if ( null != properties.getProperty( Constants.ARTIFACT_ID ) )
         {
             configuration.setProperty( Constants.ARTIFACT_ID, properties.getProperty( Constants.ARTIFACT_ID
) );
             configuration.setDefaultProperty( Constants.ARTIFACT_ID,
@@ -101,7 +101,7 @@
 
         configuration.addRequiredProperty( Constants.VERSION );
         getLogger().debug( "Adding requiredProperty " + Constants.VERSION );
-        if( null != properties.getProperty( Constants.VERSION ) )
+        if ( null != properties.getProperty( Constants.VERSION ) )
         {
             configuration.setProperty( Constants.VERSION, properties.getProperty( Constants.VERSION
) );
             configuration.setDefaultProperty( Constants.VERSION, configuration.getProperty(
Constants.VERSION ) );
@@ -115,12 +115,12 @@
 
         configuration.addRequiredProperty( Constants.PACKAGE );
         getLogger().debug( "Adding requiredProperty " + Constants.PACKAGE );
-        if( null != properties.getProperty( Constants.PACKAGE ) )
+        if ( null != properties.getProperty( Constants.PACKAGE ) )
         {
             configuration.setProperty( Constants.PACKAGE, properties.getProperty( Constants.PACKAGE
) );
             configuration.setDefaultProperty( Constants.PACKAGE, configuration.getProperty(
Constants.PACKAGE ) );
         }
-        else if( null != configuration.getProperty( Constants.GROUP_ID ) )
+        else if ( null != configuration.getProperty( Constants.GROUP_ID ) )
         {
             configuration.setProperty( Constants.PACKAGE, configuration.getProperty( Constants.GROUP_ID
) );
             configuration.setDefaultProperty( Constants.PACKAGE, configuration.getProperty(
Constants.PACKAGE ) );
@@ -145,7 +145,7 @@
 
         Iterator requiredProperties = archetypeDescriptor.getRequiredProperties().iterator();
 
-        while( requiredProperties.hasNext() )
+        while ( requiredProperties.hasNext() )
         {
             org.apache.maven.archetype.metadata.RequiredProperty requiredProperty =
                 (org.apache.maven.archetype.metadata.RequiredProperty) requiredProperties.next();
@@ -153,15 +153,15 @@
             configuration.addRequiredProperty( requiredProperty.getKey() );
             getLogger().debug( "Adding requiredProperty " + requiredProperty.getKey() );
 
-            if( null != properties.getProperty( requiredProperty.getKey(), requiredProperty.getDefaultValue()
) &&
-                !containsInnerProperty(requiredProperty.getDefaultValue()) )
+            if ( null != properties.getProperty( requiredProperty.getKey(), requiredProperty.getDefaultValue()
)
+                && !containsInnerProperty(requiredProperty.getDefaultValue()) )
             {
                 configuration.setProperty( requiredProperty.getKey(),
                     properties.getProperty( requiredProperty.getKey(), requiredProperty.getDefaultValue()
) );
                 getLogger().debug( "Setting property " + requiredProperty.getKey() + "="
                     + configuration.getProperty( requiredProperty.getKey() ) );
             }
-            if( null != requiredProperty.getDefaultValue() )
+            if ( null != requiredProperty.getDefaultValue() )
             {
                 configuration.setDefaultProperty( requiredProperty.getKey(), requiredProperty.getDefaultValue()
);
                 getLogger().debug( "Setting defaultProperty " + requiredProperty.getKey()
+ "="
@@ -169,13 +169,14 @@
             }
         } // end while
 
-        if( !configuration.isConfigured( Constants.GROUP_ID )&&null==configuration.getDefaultValue(
Constants.GROUP_ID ) )
+        if ( !configuration.isConfigured( Constants.GROUP_ID )
+                        && null == configuration.getDefaultValue( Constants.GROUP_ID
) )
         {
             configuration.addRequiredProperty( Constants.GROUP_ID );
             getLogger().debug( "Adding requiredProperty " + Constants.GROUP_ID );
-            if( null
-                != properties.getProperty( Constants.GROUP_ID, configuration.getDefaultValue(
Constants.GROUP_ID ) ) &&
-                !containsInnerProperty(configuration.getDefaultValue( Constants.GROUP_ID
)))
+            if ( null
+                != properties.getProperty( Constants.GROUP_ID, configuration.getDefaultValue(
Constants.GROUP_ID ) )
+                && !containsInnerProperty( configuration.getDefaultValue( Constants.GROUP_ID
) ) )
             {
                 configuration.setProperty( Constants.GROUP_ID,
                     properties.getProperty( Constants.GROUP_ID, configuration.getDefaultValue(
Constants.GROUP_ID ) ) );
@@ -184,14 +185,15 @@
             getLogger().debug( "Setting property " + Constants.GROUP_ID + "="
                 + configuration.getProperty( Constants.GROUP_ID ) );
         }
-        if( !configuration.isConfigured( Constants.ARTIFACT_ID )&&null==configuration.getDefaultValue(
Constants.ARTIFACT_ID ) )
+        if ( !configuration.isConfigured( Constants.ARTIFACT_ID )
+                        && null == configuration.getDefaultValue( Constants.ARTIFACT_ID
) )
         {
             configuration.addRequiredProperty( Constants.ARTIFACT_ID );
             getLogger().debug( "Adding requiredProperty " + Constants.ARTIFACT_ID );
-            if( null
+            if ( null
                 != properties.getProperty( Constants.ARTIFACT_ID,
-                    configuration.getDefaultValue( Constants.ARTIFACT_ID ) ) &&
-                !containsInnerProperty(configuration.getDefaultValue( Constants.ARTIFACT_ID
)))
+                    configuration.getDefaultValue( Constants.ARTIFACT_ID ) )
+                && !containsInnerProperty( configuration.getDefaultValue( Constants.ARTIFACT_ID
) ) )
             {
                 configuration.setProperty( Constants.ARTIFACT_ID, properties.getProperty(
Constants.ARTIFACT_ID ) );
                 configuration.setDefaultProperty( Constants.ARTIFACT_ID,
@@ -200,13 +202,14 @@
             getLogger().debug( "Setting property " + Constants.ARTIFACT_ID + "="
                 + configuration.getProperty( Constants.ARTIFACT_ID ) );
         }
-        if( !configuration.isConfigured( Constants.VERSION )&&null==configuration.getDefaultValue(
Constants.VERSION ) )
+        if ( !configuration.isConfigured( Constants.VERSION )
+                        && null == configuration.getDefaultValue( Constants.VERSION
) )
         {
             configuration.addRequiredProperty( Constants.VERSION );
             getLogger().debug( "Adding requiredProperty " + Constants.VERSION );
-            if( null != properties.getProperty( Constants.VERSION,
-                    configuration.getDefaultValue( Constants.VERSION ) )&&
-                !containsInnerProperty(configuration.getDefaultValue( Constants.VERSION ))
)
+            if ( null != properties.getProperty( Constants.VERSION,
+                    configuration.getDefaultValue( Constants.VERSION ) )
+                && !containsInnerProperty( configuration.getDefaultValue( Constants.VERSION
) ) )
             {
                 configuration.setProperty( Constants.VERSION,
                     properties.getProperty( Constants.VERSION, configuration.getDefaultValue(
Constants.VERSION ) ) );
@@ -219,20 +222,21 @@
             getLogger().debug( "Setting property " + Constants.VERSION + "="
                 + configuration.getProperty( Constants.VERSION ) );
         }
-        if( !configuration.isConfigured( Constants.PACKAGE )&&null==configuration.getDefaultValue(
Constants.PACKAGE ) )
+        if ( !configuration.isConfigured( Constants.PACKAGE )
+                        && null == configuration.getDefaultValue( Constants.PACKAGE
) )
         {
             configuration.addRequiredProperty( Constants.PACKAGE );
             getLogger().debug( "Adding requiredProperty " + Constants.PACKAGE );
-            if( null != properties.getProperty( Constants.PACKAGE,
-                    configuration.getDefaultValue( Constants.PACKAGE ) )&&
-                !containsInnerProperty(configuration.getDefaultValue( Constants.PACKAGE )
) )
+            if ( null != properties.getProperty( Constants.PACKAGE,
+                    configuration.getDefaultValue( Constants.PACKAGE ) )
+                && !containsInnerProperty(configuration.getDefaultValue( Constants.PACKAGE
) ) )
             {
                 configuration.setProperty( Constants.PACKAGE,
                     properties.getProperty( Constants.PACKAGE, configuration.getDefaultValue(
Constants.PACKAGE ) ) );
                 configuration.setDefaultProperty( Constants.PACKAGE, configuration.getProperty(
Constants.PACKAGE ) );
             }
-            else if( null != configuration.getProperty( Constants.GROUP_ID )&&
-                !containsInnerProperty(configuration.getDefaultValue( Constants.PACKAGE )
) )
+            else if ( null != configuration.getProperty( Constants.GROUP_ID )
+                && !containsInnerProperty(configuration.getDefaultValue( Constants.PACKAGE
) ) )
             {
                 configuration.setProperty( Constants.PACKAGE, configuration.getProperty(
Constants.GROUP_ID ) );
                 configuration.setDefaultProperty( Constants.PACKAGE, configuration.getProperty(
Constants.PACKAGE ) );
@@ -241,7 +245,7 @@
                 + configuration.getProperty( Constants.PACKAGE ) );
         }
 
-        if( null != properties.getProperty( Constants.ARCHETYPE_POST_GENERATION_GOALS ) )
+        if ( null != properties.getProperty( Constants.ARCHETYPE_POST_GENERATION_GOALS )
)
         {
             configuration.setProperty( Constants.ARCHETYPE_POST_GENERATION_GOALS,
                 properties.getProperty( Constants.ARCHETYPE_POST_GENERATION_GOALS ) );
@@ -262,11 +266,11 @@
 
         Iterator requiredProperties = properties.keySet().iterator();
 
-        while( requiredProperties.hasNext() )
+        while ( requiredProperties.hasNext() )
         {
             String requiredProperty = (String) requiredProperties.next();
 
-            if( requiredProperty.indexOf( "." ) < 0 )
+            if ( requiredProperty.indexOf( "." ) < 0 )
             {
                 configuration.addRequiredProperty( requiredProperty );
                 getLogger().debug( "Adding requiredProperty " + requiredProperty );
@@ -279,7 +283,7 @@
         configuration.addRequiredProperty( Constants.GROUP_ID );
         getLogger().debug( "Adding requiredProperty " + Constants.GROUP_ID );
         configuration.setDefaultProperty( Constants.GROUP_ID, project.getGroupId() );
-        if( null != properties.getProperty( Constants.GROUP_ID, null ) )
+        if ( null != properties.getProperty( Constants.GROUP_ID, null ) )
         {
             configuration.setProperty( Constants.GROUP_ID, properties.getProperty( Constants.GROUP_ID
) );
             getLogger().debug( "Setting property " + Constants.GROUP_ID + "="
@@ -289,7 +293,7 @@
         configuration.addRequiredProperty( Constants.ARTIFACT_ID );
         getLogger().debug( "Adding requiredProperty " + Constants.ARTIFACT_ID );
         configuration.setDefaultProperty( Constants.ARTIFACT_ID, project.getArtifactId()
);
-        if( null != properties.getProperty( Constants.ARTIFACT_ID, null ) )
+        if ( null != properties.getProperty( Constants.ARTIFACT_ID, null ) )
         {
             configuration.setProperty( Constants.ARTIFACT_ID, properties.getProperty( Constants.ARTIFACT_ID
) );
             getLogger().debug( "Setting property " + Constants.ARTIFACT_ID + "="
@@ -299,7 +303,7 @@
         configuration.addRequiredProperty( Constants.VERSION );
         getLogger().debug( "Adding requiredProperty " + Constants.VERSION );
         configuration.setDefaultProperty( Constants.VERSION, project.getVersion() );
-        if( null != properties.getProperty( Constants.VERSION, null ) )
+        if ( null != properties.getProperty( Constants.VERSION, null ) )
         {
             configuration.setProperty( Constants.VERSION, properties.getProperty( Constants.VERSION
) );
             getLogger().debug( "Setting property " + Constants.VERSION + "="
@@ -308,7 +312,7 @@
 
         configuration.addRequiredProperty( Constants.PACKAGE );
         getLogger().debug( "Adding requiredProperty " + Constants.PACKAGE );
-        if( null != properties.getProperty( Constants.PACKAGE ) )
+        if ( null != properties.getProperty( Constants.PACKAGE ) )
         {
             configuration.setProperty( Constants.PACKAGE, properties.getProperty( Constants.PACKAGE
) );
 
@@ -316,17 +320,17 @@
                 + configuration.getProperty( Constants.PACKAGE ) );
         }
 
-        if( null != properties.getProperty( Constants.ARCHETYPE_GROUP_ID, null ) )
+        if ( null != properties.getProperty( Constants.ARCHETYPE_GROUP_ID, null ) )
         {
             configuration.setProperty( Constants.ARCHETYPE_GROUP_ID, properties.getProperty(
Constants.ARCHETYPE_GROUP_ID ) );
         }
 
-        if( null != properties.getProperty( Constants.ARCHETYPE_ARTIFACT_ID, null ) )
+        if ( null != properties.getProperty( Constants.ARCHETYPE_ARTIFACT_ID, null ) )
         {
             configuration.setProperty( Constants.ARCHETYPE_ARTIFACT_ID, properties.getProperty(
Constants.ARCHETYPE_ARTIFACT_ID ) );
         }
 
-        if( null != properties.getProperty( Constants.ARCHETYPE_VERSION, null ) )
+        if ( null != properties.getProperty( Constants.ARCHETYPE_VERSION, null ) )
         {
             configuration.setProperty( Constants.ARCHETYPE_VERSION, properties.getProperty(
Constants.ARCHETYPE_VERSION ) );
         }
@@ -358,14 +362,10 @@
 
     private boolean containsInnerProperty(String defaultValue)
     {
-        if (null == defaultValue)
+        if ( null == defaultValue )
         {
             return false;
         }
-        if (defaultValue.contains("${") && defaultValue.contains("}"))
-        {
-            return true;
-        }
-        return false;
+        return ( defaultValue.indexOf( "${" ) >= 0 ) && ( defaultValue.indexOf(
"}" ) >= 0 );
     }
 }

Modified: maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeGenerationConfigurator.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeGenerationConfigurator.java?rev=748942&r1=748941&r2=748942&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeGenerationConfigurator.java
(original)
+++ maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeGenerationConfigurator.java
Sun Mar  1 00:25:34 2009
@@ -38,7 +38,6 @@
 import java.io.IOException;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Iterator;
@@ -109,9 +108,9 @@
 
         ad.setVersion( request.getArchetypeVersion() );
 
-        if( !ad.isDefined() )
+        if ( !ad.isDefined() )
         {
-            if( !interactiveMode.booleanValue() )
+            if ( !interactiveMode.booleanValue() )
             {
                 throw new ArchetypeNotDefined( "No archetype was chosen" );
             }
@@ -120,19 +119,19 @@
                 throw new ArchetypeNotDefined( "The archetype is not defined" );
             }
         }
-        if( request.getArchetypeRepository() != null )
+        if ( request.getArchetypeRepository() != null )
         {
             archetypeRepository = archetypeRegistryManager.createRepository( request.getArchetypeRepository(),
                     ad.getArtifactId() + "-repo" );
             repositories.add( archetypeRepository );
         }
-        if( request.getRemoteArtifactRepositories() != null )
+        if ( request.getRemoteArtifactRepositories() != null )
         {
             repositories.addAll( request.getRemoteArtifactRepositories() );
         }
 
-        if( !archetypeArtifactManager.exists( ad.getGroupId(), ad.getArtifactId(), ad.getVersion(),
archetypeRepository,
-                localRepository, repositories ) )
+        if ( !archetypeArtifactManager.exists( ad.getGroupId(), ad.getArtifactId(), ad.getVersion(),
+                                               archetypeRepository, localRepository, repositories
) )
         {
             throw new UnknownArchetype( "The desired archetype does not exist (" + ad.getGroupId()
+ ":"
                 + ad.getArtifactId() + ":" + ad.getVersion() + ")" );
@@ -142,7 +141,7 @@
 
         ArchetypeConfiguration archetypeConfiguration;
 
-        if( archetypeArtifactManager.isFileSetArchetype( ad.getGroupId(), ad.getArtifactId(),
ad.getVersion(),
+        if ( archetypeArtifactManager.isFileSetArchetype( ad.getGroupId(), ad.getArtifactId(),
ad.getVersion(),
                 archetypeRepository, localRepository, repositories ) )
         {
             org.apache.maven.archetype.metadata.ArchetypeDescriptor archetypeDescriptor =
archetypeArtifactManager
@@ -151,7 +150,7 @@
 
             archetypeConfiguration = archetypeFactory.createArchetypeConfiguration( archetypeDescriptor,
properties );
         }
-        else if( archetypeArtifactManager.isOldArchetype( ad.getGroupId(), ad.getArtifactId(),
ad.getVersion(),
+        else if ( archetypeArtifactManager.isOldArchetype( ad.getGroupId(), ad.getArtifactId(),
ad.getVersion(),
                 archetypeRepository, localRepository, repositories ) )
         {
             org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor archetypeDescriptor
= archetypeArtifactManager
@@ -165,64 +164,67 @@
             throw new ArchetypeGenerationConfigurationFailure( "The defined artifact is not
an archetype" );
         }
 
-        if( interactiveMode.booleanValue() )
+        if ( interactiveMode.booleanValue() )
         {
             boolean confirmed = false;
 
-            while( !confirmed )
+            while ( !confirmed )
             {
                 List propertiesRequired = archetypeConfiguration.getRequiredProperties();
-                getLogger().debug("Required properties before content sort: "+propertiesRequired);
-                Collections.sort(propertiesRequired, new RequiredPropertyComparator(archetypeConfiguration));
-                getLogger().debug("Required properties after content sort: "+propertiesRequired);
+                getLogger().debug( "Required properties before content sort: " + propertiesRequired
);
+                Collections.sort( propertiesRequired, new RequiredPropertyComparator( archetypeConfiguration
) );
+                getLogger().debug( "Required properties after content sort: " + propertiesRequired
);
                     Iterator requiredProperties = propertiesRequired.iterator();
-                if( !archetypeConfiguration.isConfigured() )
+                if ( !archetypeConfiguration.isConfigured() )
                 {
-                    while( requiredProperties.hasNext() )
+                    while ( requiredProperties.hasNext() )
                     {
                         String requiredProperty = (String) requiredProperties.next();
 
-                        if( !archetypeConfiguration.isConfigured( requiredProperty ) )
+                        if ( !archetypeConfiguration.isConfigured( requiredProperty ) )
                         {
-                            if( "package".equals(requiredProperty) ) {
+                            if ( "package".equals(requiredProperty) )
+                            {
                                 // if the asked property is 'package', then
                                 // use its default and if not defined,
                                 // use the 'groupId' property value.
                                 String packageDefault = archetypeConfiguration.getDefaultValue(
requiredProperty );
-                                packageDefault = (null == packageDefault || "".equals(packageDefault))?
-                                    archetypeConfiguration.getProperty( "groupId" ):
+                                packageDefault = ( null == packageDefault || "".equals( packageDefault
) ) ?
+                                    archetypeConfiguration.getProperty( "groupId" ) :
                                     archetypeConfiguration.getDefaultValue( requiredProperty
);
-                                
+
                                 archetypeConfiguration.setProperty( requiredProperty,
                                     archetypeGenerationQueryer.getPropertyValue( requiredProperty,
                                         getTransitiveDefaultValue(packageDefault, archetypeConfiguration)
) );
-                            } else {
+                            }
+                            else
+                            {
                                 archetypeConfiguration.setProperty( requiredProperty,
                                     archetypeGenerationQueryer.getPropertyValue( requiredProperty,
-                                        getTransitiveDefaultValue(archetypeConfiguration.getDefaultValue(
requiredProperty ), archetypeConfiguration )) );
+                                        getTransitiveDefaultValue( archetypeConfiguration.getDefaultValue(
requiredProperty ), archetypeConfiguration ) ) );
                             }
                         }
                         else
                         {
-                            getLogger().info("Using property: "+requiredProperty+" = "+archetypeConfiguration.getProperty(
requiredProperty));
+                            getLogger().info( "Using property: " + requiredProperty + " =
" + archetypeConfiguration.getProperty( requiredProperty) );
                         }
                     }
                 }
                 else
                 {
 
-                    while( requiredProperties.hasNext() )
+                    while ( requiredProperties.hasNext() )
                     {
                         String requiredProperty = (String) requiredProperties.next();
-                        getLogger().info("Using property: "+requiredProperty+" = "+archetypeConfiguration.getProperty(
requiredProperty));
+                        getLogger().info( "Using property: " + requiredProperty + " = " +
archetypeConfiguration.getProperty( requiredProperty) );
                     }
                 }
 
-                if( !archetypeConfiguration.isConfigured() )
+                if ( !archetypeConfiguration.isConfigured() )
                 {
                     getLogger().warn( "Archetype is not fully configured" );
                 }
-                else if( !archetypeGenerationQueryer.confirmConfiguration( archetypeConfiguration
) )
+                else if ( !archetypeGenerationQueryer.confirmConfiguration( archetypeConfiguration
) )
                 {
                     getLogger().debug( "Archetype generation configuration not confirmed"
);
                     archetypeConfiguration.reset();
@@ -238,15 +240,15 @@
         }
         else
         {
-            if( !archetypeConfiguration.isConfigured() )
+            if ( !archetypeConfiguration.isConfigured() )
             {
                 Iterator requiredProperties = archetypeConfiguration.getRequiredProperties().iterator();
 
-                while( requiredProperties.hasNext() )
+                while ( requiredProperties.hasNext() )
                 {
                     String requiredProperty = (String) requiredProperties.next();
 
-                    if( !archetypeConfiguration.isConfigured( requiredProperty )
+                    if ( !archetypeConfiguration.isConfigured( requiredProperty )
                         && ( archetypeConfiguration.getDefaultValue( requiredProperty
) != null ) )
                     {
                         archetypeConfiguration.setProperty( requiredProperty,
@@ -255,33 +257,33 @@
                 }
 
                 // in batch mode, we assume the defaults, and if still not configured fail
-                if( !archetypeConfiguration.isConfigured() )
+                if ( !archetypeConfiguration.isConfigured() )
                 {
                     StringBuffer exceptionMessage = new StringBuffer();
-                    exceptionMessage.append("Archetype " );
+                    exceptionMessage.append( "Archetype " );
                     exceptionMessage.append( request.getArchetypeGroupId() );
                     exceptionMessage.append( ":" );
                     exceptionMessage.append( request.getArchetypeArtifactId() );
                     exceptionMessage.append( ":" );
                     exceptionMessage.append( request.getArchetypeVersion() );
                     exceptionMessage.append( " is not configured" );
-                    
+
                     List missingProperties = new ArrayList( 0 );
                     requiredProperties = archetypeConfiguration.getRequiredProperties().iterator();
-                    while( requiredProperties.hasNext() )
+                    while ( requiredProperties.hasNext() )
                     {
                         String requiredProperty = (String)requiredProperties.next();
-                        if (!archetypeConfiguration.isConfigured( requiredProperty ))
+                        if ( !archetypeConfiguration.isConfigured( requiredProperty ) )
                         {
                             exceptionMessage.append( "\n\tProperty " );
                             exceptionMessage.append( requiredProperty );
                             missingProperties.add( requiredProperty );
                             exceptionMessage.append( " is missing." );
-                            getLogger().warn( "Property " + requiredProperty + 
-                                " is missing. Add -D" + requiredProperty + "=someValue" );
+                            getLogger().warn( "Property " + requiredProperty
+                                + " is missing. Add -D" + requiredProperty + "=someValue"
);
                         }
                     }
-                    
+
                     throw new ArchetypeNotConfigured( exceptionMessage.toString(), missingProperties
);
                 }
             }
@@ -300,16 +302,21 @@
         request.setProperties( properties );
     }
 
-    private String getTransitiveDefaultValue(String defaultValue, ArchetypeConfiguration
archetypeConfiguration) {
+    private String getTransitiveDefaultValue( String defaultValue, ArchetypeConfiguration
archetypeConfiguration )
+    {
         String result = defaultValue;
-        if(null==result) return null;
+        if ( null == result )
+        {
+            return null;
+        }
         Iterator requiredProperties = archetypeConfiguration.getRequiredProperties().iterator();
-        while(requiredProperties.hasNext())
+        while ( requiredProperties.hasNext() )
         {
             String property = (String) requiredProperties.next();
-            if(result.contains("${"+property+"}"))
+            if ( result.indexOf( "${" + property + "}" ) >= 0 )
             {
-                result = StringUtils.replace(result, "${"+property+"}", archetypeConfiguration.getProperty(property));
+                result = StringUtils.replace( result, "${" + property + "}",
+                                              archetypeConfiguration.getProperty(property)
);
             }
         }
         return result;
@@ -321,10 +328,10 @@
         getLogger().debug( "Restoring command line properties" );
 
         Iterator properties = archetypeConfiguration.getRequiredProperties().iterator();
-        while( properties.hasNext() )
+        while ( properties.hasNext() )
         {
             String property = (String) properties.next();
-            if( executionProperties.containsKey( property ) )
+            if ( executionProperties.containsKey( property ) )
             {
                 archetypeConfiguration.setProperty( property, executionProperties.getProperty(
property ) );
                 getLogger().debug( "Restored " + property + "=" + archetypeConfiguration.getProperty(
property ) );
@@ -336,50 +343,75 @@
     {
         private final ArchetypeConfiguration archetypeConfiguration;
 
-        public RequiredPropertyComparator(ArchetypeConfiguration archetypeConfiguration)
+        public RequiredPropertyComparator( ArchetypeConfiguration archetypeConfiguration
)
         {
             this.archetypeConfiguration = archetypeConfiguration;
         }
 
-        public int compare(Object left, Object right)
+        public int compare( Object left, Object right )
         {
-            if (!(left instanceof String) || !(right instanceof String))
+            if ( !( left instanceof String ) || !( right instanceof String ) )
             {
                 return 0;
             }
             else
             {
-                String leftDefault = archetypeConfiguration.getDefaultValue((String)left);
-                String rightDefault = archetypeConfiguration.getDefaultValue((String)right);
-                if(null == leftDefault ||null==rightDefault)
+                String leftDefault = archetypeConfiguration.getDefaultValue( (String) left
);
+                String rightDefault = archetypeConfiguration.getDefaultValue( (String) right
);
+                if ( null == leftDefault || null == rightDefault )
                 {
-                    return comparePropertyName((String)left, (String)right);
+                    return comparePropertyName( (String) left, (String) right );
                 }
-                else if (leftDefault.indexOf("${"+right+"}")>=0)
+                else if ( leftDefault.indexOf( "${" + right + "}" ) >= 0 )
                 {//left contains right
                     return 1;
                 }
-                else if(rightDefault.indexOf("${"+left+"}")>=0)
+                else if ( rightDefault.indexOf( "${" + left + "}" ) >= 0 )
                 {//right contains left
                     return -1;
                 }
                 else
                 {
-                    return comparePropertyName((String)left, (String)right);
+                    return comparePropertyName( (String) left, (String) right );
                 }
             }
         }
 
-        private int comparePropertyName(String left, String right) {
-            if("groupId".equals(left)) return -1;
-            if("groupId".equals(right)) return 1;
-            if("artifactId".equals(left)) return -1;
-            if("artifactId".equals(right)) return 1;
-            if("version".equals(left)) return -1;
-            if("version".equals(right)) return 1;
-            if("package".equals(left)) return -1;
-            if("package".equals(right)) return 1;
-            return left.compareTo(right);
+        private int comparePropertyName( String left, String right )
+        {
+            if ( "groupId".equals( left ) )
+            {
+                return -1;
+            }
+            if ( "groupId".equals( right ) )
+            {
+                return 1;
+            }
+            if ( "artifactId".equals( left ) )
+            {
+                return -1;
+            }
+            if ( "artifactId".equals( right ) )
+            {
+                return 1;
+            }
+            if ( "version".equals( left ) )
+            {
+                return -1;
+            }
+            if ( "version".equals( right ) )
+            {
+                return 1;
+            }
+            if ( "package".equals( left ) )
+            {
+                return -1;
+            }
+            if ( "package".equals( right ) )
+            {
+                return 1;
+            }
+            return left.compareTo( right );
         }
     }
 }



Mime
View raw message