maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r925767 [2/2] - in /maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype: mojos/ ui/
Date Sun, 21 Mar 2010 13:43:09 GMT
Modified: maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeSelectionQueryer.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeSelectionQueryer.java?rev=925767&r1=925766&r2=925767&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeSelectionQueryer.java
(original)
+++ maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeSelectionQueryer.java
Sun Mar 21 13:43:08 2010
@@ -37,14 +37,13 @@ public class DefaultArchetypeSelectionQu
     private Prompter prompter;
 
     public boolean confirmSelection( ArchetypeDefinition archetypeDefinition )
-        throws
-        PrompterException
+        throws PrompterException
     {
         String query =
-            "Confirm archetype selection: \n" + archetypeDefinition.getGroupId() + "/"
-                + archetypeDefinition.getName() + "\n";
+            "Confirm archetype selection: \n" + archetypeDefinition.getGroupId() + "/" +
archetypeDefinition.getName()
+                + "\n";
 
-        String answer = prompter.prompt( query, Arrays.asList( new String[]{"Y", "N"} ),
"Y" );
+        String answer = prompter.prompt( query, Arrays.asList( new String[] { "Y", "N" }
), "Y" );
 
         return "Y".equalsIgnoreCase( answer );
     }
@@ -55,11 +54,12 @@ public class DefaultArchetypeSelectionQu
         String query = "Choose archetype:\n";
         Map answerMap = new HashMap();
         List answers = new ArrayList();
-        Iterator archetypeIterator = archetypes.iterator();
         int counter = 1;
-        while ( archetypeIterator.hasNext() )
+
+        for ( Iterator archetypeIterator = archetypes.iterator(); archetypeIterator.hasNext();
)
         {
-            org.apache.maven.archetype.catalog.Archetype archetype = (org.apache.maven.archetype.catalog.Archetype)
archetypeIterator.next();
+            org.apache.maven.archetype.catalog.Archetype archetype =
+                (org.apache.maven.archetype.catalog.Archetype) archetypeIterator.next();
 
             answerMap.put( "" + counter, archetype );
             query +=
@@ -90,18 +90,20 @@ public class DefaultArchetypeSelectionQu
         Map reversedArchetypeAnswerMap = new HashMap();
         List answers = new ArrayList();
         List archetypeVersions;
-        Iterator catalogIterator = catalogs.keySet().iterator();
         int counter = 1;
         int defaultSelection = 0;
-        while ( catalogIterator.hasNext() )
+
+        for ( Iterator catalogIterator = catalogs.keySet().iterator(); catalogIterator.hasNext();
)
         {
             String catalog = (String) catalogIterator.next();
 
-            Iterator archetypeIterator = ( (List) catalogs.get( catalog ) ).iterator();
-            while ( archetypeIterator.hasNext() )
+            for ( Iterator archetypeIterator = ( (List) catalogs.get( catalog ) ).iterator();
+                archetypeIterator.hasNext(); )
             {
-                org.apache.maven.archetype.catalog.Archetype archetype = (org.apache.maven.archetype.catalog.Archetype)
archetypeIterator.next();
-                String mapKey = ""+counter;
+                org.apache.maven.archetype.catalog.Archetype archetype =
+                    (org.apache.maven.archetype.catalog.Archetype) archetypeIterator.next();
+
+                String mapKey = "" + counter;
                 String archetypeKey = archetype.getGroupId() + ":" + archetype.getArtifactId();
                 if ( reversedArchetypeAnswerMap.containsKey( archetypeKey ) )
                 {
@@ -119,8 +121,8 @@ public class DefaultArchetypeSelectionQu
                     answers.add( mapKey );
 
                     // the version is not tested. This is intentional.
-                    if ( defaultDefinition != null && archetype.getGroupId().equals(
defaultDefinition.getGroupId() ) &&
-                        archetype.getArtifactId().equals( defaultDefinition.getArtifactId()
) )
+                    if ( defaultDefinition != null && archetype.getGroupId().equals(
defaultDefinition.getGroupId() )
+                        && archetype.getArtifactId().equals( defaultDefinition.getArtifactId()
) )
                     {
                         defaultSelection = counter;
                     }
@@ -128,7 +130,6 @@ public class DefaultArchetypeSelectionQu
                     counter++;
                 }
                 archetypeVersions.add( archetype );
-
             }
 
         }
@@ -147,7 +148,7 @@ public class DefaultArchetypeSelectionQu
 
         archetypeVersions = (List) archetypeAnswerMap.get( answer );
 
-        if( archetypeVersions.size() == 1 )
+        if ( archetypeVersions.size() == 1 )
         {
             return (org.apache.maven.archetype.catalog.Archetype) archetypeVersions.get(
0 );
         }
@@ -156,28 +157,29 @@ public class DefaultArchetypeSelectionQu
             return selectVersion( archetypeVersions );
         }
     }
+
     private org.apache.maven.archetype.catalog.Archetype selectVersion( List archetypes )
-        throws
-        PrompterException
+        throws PrompterException
     {
         String query = "Choose version: \n";
         Map answerMap = new HashMap();
         List answers = new ArrayList();
 
-        Collections.sort(archetypes, new Comparator() {
-            public int compare( Object o1, Object o2 ) {
+        Collections.sort( archetypes, new Comparator()
+        {
+            public int compare( Object o1, Object o2 )
+            {
                 org.apache.maven.archetype.catalog.Archetype a1 = (org.apache.maven.archetype.catalog.Archetype)
o1;
                 org.apache.maven.archetype.catalog.Archetype a2 = (org.apache.maven.archetype.catalog.Archetype)
o2;
                 return a1.getVersion().compareTo( a2.getVersion() );
             }
-        });
+        } );
 
-        Iterator archetypeVersionsKeys = archetypes.iterator();
         int counter = 1;
-        org.apache.maven.archetype.catalog.Archetype archetype;
-        while ( archetypeVersionsKeys.hasNext() )
+        for ( Iterator archetypeVersionsKeys = archetypes.iterator(); archetypeVersionsKeys.hasNext();
)
         {
-            archetype = (org.apache.maven.archetype.catalog.Archetype) archetypeVersionsKeys.next();
+            org.apache.maven.archetype.catalog.Archetype archetype =
+                (org.apache.maven.archetype.catalog.Archetype) archetypeVersionsKeys.next();
             String archetypeVersion = archetype.getVersion();
 
             answerMap.put( "" + counter, archetype );

Modified: maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeSelector.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeSelector.java?rev=925767&r1=925766&r2=925767&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeSelector.java
(original)
+++ maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeSelector.java
Sun Mar 21 13:43:08 2010
@@ -54,14 +54,8 @@ public class DefaultArchetypeSelector
     /** @plexus.requirement */
     private org.apache.maven.archetype.Archetype archetype;
 
-    public void selectArchetype( ArchetypeGenerationRequest request,
-            Boolean interactiveMode, String catalogs )
-        throws
-        ArchetypeNotDefined,
-        UnknownArchetype,
-        UnknownGroup,
-        IOException,
-        PrompterException,
+    public void selectArchetype( ArchetypeGenerationRequest request, Boolean interactiveMode,
String catalogs )
+        throws ArchetypeNotDefined, UnknownArchetype, UnknownGroup, IOException, PrompterException,
         ArchetypeSelectionFailure
     {
         //This should be an internal class
@@ -73,34 +67,33 @@ public class DefaultArchetypeSelector
 
         Map archetypes = getArchetypesByCatalog( catalogs );
 
-        if ( definition.isDefined()
-            && StringUtils.isNotEmpty( request.getArchetypeRepository () )
-        )
+        if ( definition.isDefined() && StringUtils.isNotEmpty( request.getArchetypeRepository()
) )
         {
             getLogger().info( "Archetype defined by properties" );
         }
         else
         {
-            if ( definition.isDefined()
-                && StringUtils.isEmpty( request.getArchetypeRepository () )
-            )
+            if ( definition.isDefined() && StringUtils.isEmpty( request.getArchetypeRepository()
) )
             {
                 Iterator ca = new ArrayIterator( StringUtils.split ( catalogs, "," ) );
                 boolean found = false;
                 while ( !found && ca.hasNext() )
                 {
                     String catalogKey = (String) ca.next();
+
                     String[] keySplitted = catalogKey.split( "-", 2 );
+
                     List catalog = (List) archetypes.get( catalogKey );
+
                     Archetype example = new Archetype();
                     example.setGroupId( request.getArchetypeGroupId() );
                     example.setArtifactId( request.getArchetypeArtifactId() );
+
                     if ( catalog.contains( example ) )
                     {
                         found = true;
 
-                        Archetype foundArchetype =
-                            (Archetype) catalog.get( catalog.indexOf( example ) );
+                        Archetype foundArchetype = (Archetype) catalog.get( catalog.indexOf(
example ) );
                         definition.setName( foundArchetype.getArtifactId() );
                         if ( StringUtils.isNotEmpty( foundArchetype.getRepository() ) )
                         {
@@ -115,9 +108,8 @@ public class DefaultArchetypeSelector
                         }
 
                         getLogger().info(
-                            "Archetype repository missing. Using the one from " + foundArchetype
-                            + " found in catalog " + catalogKey
-                        );
+                                          "Archetype repository missing. Using the one from
" + foundArchetype
+                                              + " found in catalog " + catalogKey );
                     }
                 }
                 if ( !found )
@@ -135,11 +127,15 @@ public class DefaultArchetypeSelector
                 while ( !found && ca.hasNext() )
                 {
                     String catalogKey = (String) ca.next();
+
                     List catalog = (List) archetypes.get( catalogKey );
+
                     String[] keySplitted = catalogKey.split( ":", 2 );
+
                     Archetype example = new Archetype();
                     example.setGroupId( request.getArchetypeGroupId() );
                     example.setArtifactId( request.getArchetypeArtifactId() );
+
                     if ( catalog.contains ( example ) )
                     {
                         found = true;
@@ -149,6 +145,7 @@ public class DefaultArchetypeSelector
                         definition.setArtifactId( foundArchetype.getArtifactId() );
                         definition.setVersion( foundArchetype.getVersion() );
                         definition.setName( foundArchetype.getArtifactId() );
+
                         if ( StringUtils.isNotEmpty( foundArchetype.getRepository() ) )
                         {
                             definition.setRepository( foundArchetype.getRepository() );
@@ -164,10 +161,7 @@ public class DefaultArchetypeSelector
                         String goals = StringUtils.join( foundArchetype.getGoals().iterator(),
"," );
                         definition.setGoals( goals );
 
-                        getLogger().info(
-                            "Archetype " + foundArchetype
-                            + " found in catalog " + catalogKey
-                        );
+                        getLogger().info( "Archetype " + foundArchetype + " found in catalog
" + catalogKey );
                     }
                 }
                 if ( !found )
@@ -266,8 +260,7 @@ public class DefaultArchetypeSelector
 
         Map archetypes = new HashMap();
 
-        Iterator ca = new ArrayIterator( StringUtils.split( catalogs, "," ) );
-        while ( ca.hasNext() )
+        for ( Iterator ca = new ArrayIterator( StringUtils.split( catalogs, "," ) ); ca.hasNext();
)
         {
             String catalog = (String) ca.next();
 
@@ -312,8 +305,7 @@ public class DefaultArchetypeSelector
         return archetypes;
     }
 
-    private Properties getArchetypeDataSourceProperties( String sourceRoleHint,
-                                                         Properties archetypeCatalogProperties
)
+    private Properties getArchetypeDataSourceProperties( String sourceRoleHint, Properties
archetypeCatalogProperties )
     {
         Properties p = new Properties();
 



Mime
View raw message