maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raf...@apache.org
Subject svn commit: r598446 - in /maven/sandbox/trunk/archetypeng/archetypeng-plugin/src/main/java/org/apache/maven/archetype: mojos/ ui/
Date Mon, 26 Nov 2007 21:55:04 GMT
Author: rafale
Date: Mon Nov 26 13:55:03 2007
New Revision: 598446

URL: http://svn.apache.org/viewvc?rev=598446&view=rev
Log:
Removed property manager

Removed:
    maven/sandbox/trunk/archetypeng/archetypeng-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypePropertiesManager.java
    maven/sandbox/trunk/archetypeng/archetypeng-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypePropertiesManager.java
Modified:
    maven/sandbox/trunk/archetypeng/archetypeng-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateArchetypeFromProjectMojo.java
    maven/sandbox/trunk/archetypeng/archetypeng-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateProjectFromArchetypeMojo.java
    maven/sandbox/trunk/archetypeng/archetypeng-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeCreationConfigurator.java

Modified: maven/sandbox/trunk/archetypeng/archetypeng-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateArchetypeFromProjectMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateArchetypeFromProjectMojo.java?rev=598446&r1=598445&r2=598446&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateArchetypeFromProjectMojo.java
(original)
+++ maven/sandbox/trunk/archetypeng/archetypeng-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateArchetypeFromProjectMojo.java
Mon Nov 26 13:55:03 2007
@@ -22,7 +22,6 @@
 import org.apache.maven.archetype.ArchetypeCreationRequest;
 import org.apache.maven.archetype.ArchetypeCreationResult;
 import org.apache.maven.archetype.Archetype;
-import org.apache.maven.archetype.ui.ArchetypePropertiesManager;
 import org.apache.maven.archetype.common.ArchetypeRegistryManager;
 import org.apache.maven.archetype.ui.ArchetypeCreationConfigurator;
 import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -60,9 +59,6 @@
 
     /** @component */
     Archetype archetype;
-
-    /** @component */
-    private ArchetypePropertiesManager propertiesManager;
 
     /**
      * File extensions which are checked for project's text files (vs binary files).

Modified: maven/sandbox/trunk/archetypeng/archetypeng-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateProjectFromArchetypeMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateProjectFromArchetypeMojo.java?rev=598446&r1=598445&r2=598446&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateProjectFromArchetypeMojo.java
(original)
+++ maven/sandbox/trunk/archetypeng/archetypeng-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateProjectFromArchetypeMojo.java
Mon Nov 26 13:55:03 2007
@@ -22,7 +22,6 @@
 import org.apache.maven.archetype.ArchetypeGenerationRequest;
 import org.apache.maven.archetype.ArchetypeGenerationResult;
 import org.apache.maven.archetype.Archetype;
-import org.apache.maven.archetype.ui.ArchetypePropertiesManager;
 import org.apache.maven.archetype.common.ArchetypeRegistryManager;
 import org.apache.maven.archetype.generator.ArchetypeGenerator;
 import org.apache.maven.archetype.ui.ArchetypeGenerationConfigurator;
@@ -124,9 +123,6 @@
      * @parameter expression="${goals}"
      */
     private String goals;
-
-    /** @component */
-    private ArchetypePropertiesManager propertiesManager;
 
     public void execute()
         throws MojoExecutionException, MojoFailureException

Modified: maven/sandbox/trunk/archetypeng/archetypeng-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeCreationConfigurator.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeCreationConfigurator.java?rev=598446&r1=598445&r2=598446&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeCreationConfigurator.java
(original)
+++ maven/sandbox/trunk/archetypeng/archetypeng-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeCreationConfigurator.java
Mon Nov 26 13:55:03 2007
@@ -22,7 +22,6 @@
 import org.apache.maven.archetype.common.ArchetypeConfiguration;
 import org.apache.maven.archetype.common.ArchetypeDefinition;
 import org.apache.maven.archetype.common.ArchetypeFilesResolver;
-import org.apache.maven.archetype.ui.ArchetypePropertiesManager;
 import org.apache.maven.archetype.common.Constants;
 import org.apache.maven.archetype.exception.ArchetypeNotConfigured;
 import org.apache.maven.archetype.exception.ArchetypeNotDefined;
@@ -33,12 +32,17 @@
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
+import org.codehaus.plexus.util.IOUtil;
 
 /** @plexus.component */
 public class DefaultArchetypeCreationConfigurator
@@ -54,9 +58,6 @@
     /** @plexus.requirement */
     private ArchetypeFilesResolver archetypeFilesResolver;
 
-    /** @plexus.requirement */
-    private ArchetypePropertiesManager archetypePropertiesManager;
-
     public void configureArchetypeCreation(
         MavenProject project,
         Boolean interactiveMode,
@@ -239,7 +240,7 @@
             }
         } // end if
 
-        archetypePropertiesManager.writeProperties(
+        writeProperties(
             archetypeConfiguration.toProperties(),
             propertyFile
         );
@@ -324,6 +325,65 @@
             );
     }
 
+    public void readProperties( Properties properties,
+                                File propertyFile )
+        throws
+        IOException
+    {
+        getLogger().debug( "Reading property file " + propertyFile );
+
+        InputStream is = new FileInputStream( propertyFile );
+
+        try
+        {
+            properties.load( is );
+
+            getLogger().debug( "Read " + properties.size() + " properties" );
+        }
+        finally
+        {
+            IOUtil.close( is );
+        }
+    }
+
+    public void writeProperties( Properties properties,
+                                 File propertyFile )
+        throws
+        IOException
+    {
+        Properties storedProperties = new Properties();
+        try
+        {
+            readProperties( storedProperties, propertyFile );
+        }
+        catch ( FileNotFoundException ex )
+        {
+            getLogger().debug( "Property file not found. Creating a new one" );
+        }
+
+        getLogger().debug( "Adding " + properties.size() + " properties" );
+
+        Iterator propertiesIterator = properties.keySet().iterator();
+        while ( propertiesIterator.hasNext() )
+        {
+            String propertyKey = (String) propertiesIterator.next();
+            storedProperties.setProperty( propertyKey, properties.getProperty( propertyKey
) );
+        }
+
+        OutputStream os = new FileOutputStream( propertyFile );
+
+        try
+        {
+            storedProperties.store( os, "" );
+
+            getLogger().debug( "Stored " + storedProperties.size() + " properties" );
+        }
+        finally
+        {
+            IOUtil.close( os );
+        }
+    }
+    
     private Properties initialiseArchetypeProperties(
         Properties commandLineProperties,
         File propertyFile
@@ -335,7 +395,7 @@
 
         try
         {
-            archetypePropertiesManager.readProperties( properties, propertyFile );
+            readProperties( properties, propertyFile );
         }
         catch ( FileNotFoundException ex )
         {



Mime
View raw message