Author: apadilla
Date: Tue Mar  8 11:26:56 2011
New Revision: 1079328

URL: http://svn.apache.org/viewvc?rev=1079328&view=rev
Log:
[NPANDAY-361] - allow location of npanday-settings.xml to be configurable
[NPANDAY-377] - fixed this intermittent issue by reloading the 
npanday-settings.xml once it's updated

Modified:
    
incubator/npanday/trunk/components/dotnet-artifact/src/main/java/npanday/artifact/impl/NetDependenciesRepositoryImpl.java
    
incubator/npanday/trunk/components/dotnet-assembler/src/main/java/npanday/assembler/impl/AssemblyPluginsRepository.java
    
incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/npanday/registry-config.xml
    
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerPluginsRepository.java
    
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/ExecutablePluginsRepository.java
    
incubator/npanday/trunk/components/dotnet-plugin/src/main/java/npanday/plugin/AbstractMojo.java
    
incubator/npanday/trunk/components/dotnet-plugin/src/main/java/npanday/plugin/impl/ConfigurationAppendersRepository.java
    
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/ConnectionsRepository.java
    
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/PropertyRepository.java
    
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/Repository.java
    
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/StandardRepositoryLoader.java
    
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsRepository.java
    
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoRepositoryImpl.java
    
incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
    
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/javabinding/src/main/java/NPanday/Plugin/Settings/SettingsGeneratorMojo.java
    
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/src/main/csharp/NPanday/Plugin/Settings/SettingsGeneratorMojo.cs

Modified: 
incubator/npanday/trunk/components/dotnet-artifact/src/main/java/npanday/artifact/impl/NetDependenciesRepositoryImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-artifact/src/main/java/npanday/artifact/impl/NetDependenciesRepositoryImpl.java?rev=1079328&r1=1079327&r2=1079328&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-artifact/src/main/java/npanday/artifact/impl/NetDependenciesRepositoryImpl.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-artifact/src/main/java/npanday/artifact/impl/NetDependenciesRepositoryImpl.java
 Tue Mar  8 11:26:56 2011
@@ -107,6 +107,22 @@ public class NetDependenciesRepositoryIm
     public void setRepositoryRegistry( RepositoryRegistry repositoryRegistry )
     {
     }
+    
+    /**
+     * @see Repository#setSourceUri(String)
+     */
+    public void setSourceUri( String fileUri )
+    {
+        // not supported
+    }
+
+    /**
+     * @see Repository#reload()
+     */
+    public void reload() throws IOException
+    {
+        // not supported
+    }
 
     /**
      * Returns a list of .NET dependencies as given within the net 
dependencies config file. This dependency list

Modified: 
incubator/npanday/trunk/components/dotnet-assembler/src/main/java/npanday/assembler/impl/AssemblyPluginsRepository.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-assembler/src/main/java/npanday/assembler/impl/AssemblyPluginsRepository.java?rev=1079328&r1=1079327&r2=1079328&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-assembler/src/main/java/npanday/assembler/impl/AssemblyPluginsRepository.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-assembler/src/main/java/npanday/assembler/impl/AssemblyPluginsRepository.java
 Tue Mar  8 11:26:56 2011
@@ -95,6 +95,22 @@ public final class AssemblyPluginsReposi
     }
 
     /**
+     * @see Repository#setSourceUri(String)
+     */
+    public void setSourceUri( String fileUri )
+    {
+        // not supported
+    }
+
+    /**
+     * @see Repository#reload()
+     */
+    public void reload() throws IOException
+    {
+        // not supported
+    }
+
+    /**
      * Returns all assembly plugins. This list is live and any modification 
will remain until the next time the application
      * starts.
      *

Modified: 
incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/npanday/registry-config.xml
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/npanday/registry-config.xml?rev=1079328&r1=1079327&r2=1079328&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/npanday/registry-config.xml
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/npanday/registry-config.xml
 Tue Mar  8 11:26:56 2011
@@ -29,15 +29,6 @@ under the License.
       </init-param>
     </repository>
     <repository>
-      <repository-name>npanday-settings</repository-name>
-      
<repository-class>npanday.vendor.impl.SettingsRepository</repository-class>
-      <repository-config>${npanday.settings}</repository-config>
-      <init-param>
-        <param-name>optional</param-name>
-        <param-value>true</param-value>
-      </init-param>
-    </repository>
-    <repository>
       <repository-name>compiler-plugins</repository-name>
       
<repository-class>npanday.executable.impl.CompilerPluginsRepository</repository-class>
       
<repository-config>/META-INF/npanday/compiler-plugins.xml</repository-config>

Modified: 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerPluginsRepository.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerPluginsRepository.java?rev=1079328&r1=1079327&r2=1079328&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerPluginsRepository.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerPluginsRepository.java
 Tue Mar  8 11:26:56 2011
@@ -81,6 +81,22 @@ public final class CompilerPluginsReposi
     }
 
     /**
+     * @see Repository#setSourceUri(String)
+     */
+    public void setSourceUri( String fileUri )
+    {
+        // not supported
+    }
+
+    /**
+     * @see Repository#reload()
+     */
+    public void reload() throws IOException
+    {
+        // not supported
+    }
+
+    /**
      * Returns config information as list of platform capabilities.
      *
      * @return config information as list of platform capabilities.

Modified: 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/ExecutablePluginsRepository.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/ExecutablePluginsRepository.java?rev=1079328&r1=1079327&r2=1079328&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/ExecutablePluginsRepository.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/ExecutablePluginsRepository.java
 Tue Mar  8 11:26:56 2011
@@ -81,6 +81,22 @@ public final class ExecutablePluginsRepo
     }
 
     /**
+     * @see Repository#setSourceUri(String)
+     */
+    public void setSourceUri( String fileUri )
+    {
+        // not supported
+    }
+
+    /**
+     * @see Repository#reload()
+     */
+    public void reload() throws IOException
+    {
+        // not supported
+    }
+
+    /**
      * Returns a list of executable capabilities as specified within the 
executable-plugins.xml file.
      *
      * @return a list of executable capabilities as specified within the 
executable-plugins.xml file

Modified: 
incubator/npanday/trunk/components/dotnet-plugin/src/main/java/npanday/plugin/AbstractMojo.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-plugin/src/main/java/npanday/plugin/AbstractMojo.java?rev=1079328&r1=1079327&r2=1079328&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-plugin/src/main/java/npanday/plugin/AbstractMojo.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-plugin/src/main/java/npanday/plugin/AbstractMojo.java
 Tue Mar  8 11:26:56 2011
@@ -72,7 +72,7 @@ public abstract class AbstractMojo
     extends org.apache.maven.plugin.AbstractMojo
     implements DotNetMojo, Contextualizable
 {
-    private PlexusContainer container;
+    protected PlexusContainer container;
     
      /**
      * Output directory
@@ -178,6 +178,8 @@ public abstract class AbstractMojo
         } catch (ComponentLookupException e) {
             throw new MojoExecutionException( "NPANDAY-xxx-000", e );
         }
+
+        postExecute();
     }
 
     private void resolveArtifact(Artifact artifact) throws 
ComponentLookupException, MojoExecutionException {
@@ -323,5 +325,11 @@ public abstract class AbstractMojo
     {
         return true;
     }
+    
+    public void postExecute()
+        throws MojoExecutionException, MojoFailureException
+    {
+
+    }
 
 }

Modified: 
incubator/npanday/trunk/components/dotnet-plugin/src/main/java/npanday/plugin/impl/ConfigurationAppendersRepository.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-plugin/src/main/java/npanday/plugin/impl/ConfigurationAppendersRepository.java?rev=1079328&r1=1079327&r2=1079328&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-plugin/src/main/java/npanday/plugin/impl/ConfigurationAppendersRepository.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-plugin/src/main/java/npanday/plugin/impl/ConfigurationAppendersRepository.java
 Tue Mar  8 11:26:56 2011
@@ -80,4 +80,20 @@ public class ConfigurationAppendersRepos
     {
 
     }
+    
+    /**
+     * @see Repository#setSourceUri(String)
+     */
+    public void setSourceUri( String fileUri )
+    {
+        // not supported
+    }
+
+    /**
+     * @see Repository#reload()
+     */
+    public void reload() throws IOException
+    {
+        // not supported
+    }
 }

Modified: 
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/ConnectionsRepository.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/ConnectionsRepository.java?rev=1079328&r1=1079327&r2=1079328&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/ConnectionsRepository.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/ConnectionsRepository.java
 Tue Mar  8 11:26:56 2011
@@ -135,6 +135,22 @@ public class ConnectionsRepository
     }
 
     /**
+     * @see Repository#setSourceUri(String)
+     */
+    public void setSourceUri( String fileUri )
+    {
+        // not supported
+    }
+
+    /**
+     * @see Repository#reload()
+     */
+    public void reload()
+    {
+        // not supported
+    }    
+
+    /**
      * Returns unmodifiable set of all data access objects.
      *
      * @return unmodifiable set of all data access objects

Modified: 
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/PropertyRepository.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/PropertyRepository.java?rev=1079328&r1=1079327&r2=1079328&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/PropertyRepository.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/PropertyRepository.java
 Tue Mar  8 11:26:56 2011
@@ -81,4 +81,20 @@ public class PropertyRepository
     {
         this.repositoryRegistry = repositoryRegistry;
     }
+
+    /**
+     * @see Repository#setSourceUri(String)
+     */
+    public void setSourceUri( String fileUri )
+    {
+        // not supported
+    }
+
+    /**
+     * @see Repository#reload()
+     */
+    public void reload() throws IOException
+    {
+        // not supported
+    }
 }

Modified: 
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/Repository.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/Repository.java?rev=1079328&r1=1079327&r2=1079328&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/Repository.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/Repository.java
 Tue Mar  8 11:26:56 2011
@@ -72,5 +72,16 @@ public interface Repository
      * @param repositoryRegistry
      */
     void setRepositoryRegistry( RepositoryRegistry repositoryRegistry );
+    
+    /**
+     * Sets the URI of the file used to initialize the repository.
+     * @param fileUri
+     */
+    void setSourceUri( String fileUri );
+
+    /**
+     * Reloads this repository based on the file uri.
+     */
+    void reload() throws IOException;
 
 }
\ No newline at end of file

Modified: 
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/StandardRepositoryLoader.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/StandardRepositoryLoader.java?rev=1079328&r1=1079327&r2=1079328&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/StandardRepositoryLoader.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/StandardRepositoryLoader.java
 Tue Mar  8 11:26:56 2011
@@ -99,7 +99,7 @@ public class StandardRepositoryLoader
             repository = (Repository) c.newInstance();
             repository.setRepositoryRegistry( repositoryRegistry );
             repository.load( stream, props );
-
+            repository.setSourceUri( fileUri );
         }
         catch ( IOException e )
         {

Modified: 
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsRepository.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsRepository.java?rev=1079328&r1=1079327&r2=1079328&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsRepository.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsRepository.java
 Tue Mar  8 11:26:56 2011
@@ -58,6 +58,12 @@ public final class SettingsRepository
      */
     private DefaultSetup defaultSetup;
 
+    private String fileUri;
+
+    private Hashtable props;
+
+    private boolean reloaded = false;
+
     /**
      * Constructor. This method is intended to be invoked by the 
<code>RepositoryRegistry<code>, not by the
      * application developer.
@@ -86,6 +92,7 @@ public final class SettingsRepository
         }
         vendors = settings.getVendors();
         defaultSetup = settings.getDefaultSetup();
+        props = properties;
     }
 
     /**
@@ -104,6 +111,74 @@ public final class SettingsRepository
     {
     }
 
+    public void setSourceUri( String fileUri )
+    {
+        this.fileUri = fileUri;
+    }
+
+    public void reload()
+        throws IOException
+    {
+
+        if ( fileUri == null || fileUri.trim().equals( "" ) )
+        {
+            throw new IOException( "NPANDAY-084-001: File uri must be 
provided." );
+        }
+
+        InputStream stream;
+
+        try
+        {
+            stream = new FileInputStream( fileUri );
+        }
+        catch ( IOException e )
+        {
+            stream = this.getClass().getResourceAsStream( fileUri );
+        }
+        String message =
+            "File Name = " + fileUri + ", Repository Class = " + 
this.getClass().getName() + ", Properties = " + props.toString();
+        boolean optional = ( props.containsKey( "optional" ) &&
+            ( (String) props.get( "optional" ) ).equalsIgnoreCase( "true" ) );
+        if ( stream == null )
+        {
+            if ( !optional )
+            {
+                throw new IOException( "NPANDAY-084-003: Unable to 
loadRegistry config file: " + message );
+            }
+        }
+        else
+        {
+            try
+            {
+                load( stream, props );
+            }
+            catch ( IOException e )
+            {
+                throw new IOException( "NPANDAY-084-004: " + e.toString() + " 
: " + message );
+            }
+            catch ( Exception e )
+            {
+                throw new IOException( "NPANDAY-084-005: " + e.toString() + " 
: " + message );
+            }
+            catch ( Error e )
+            {
+                throw new IOException( "NPANDAY-084-006: " + e.toString() + " 
: " + message );
+            }
+        }
+
+        reloaded = true;
+    }
+
+    public void setReloaded( boolean status )
+    {
+        this.reloaded = status;
+    }
+
+    public boolean isReloaded()
+    {
+        return this.reloaded;
+    }    
+
     File getSdkInstallRootFor( String vendor, String vendorVersion, String 
frameworkVersion )
         throws PlatformUnsupportedException
     {

Modified: 
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoRepositoryImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoRepositoryImpl.java?rev=1079328&r1=1079327&r2=1079328&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoRepositoryImpl.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoRepositoryImpl.java
 Tue Mar  8 11:26:56 2011
@@ -46,6 +46,7 @@ public class VendorInfoRepositoryImpl
 
     /**
      * A registry component of repository (config) files
+     * @component
      */
     private RepositoryRegistry repositoryRegistry;
 
@@ -82,6 +83,15 @@ public class VendorInfoRepositoryImpl
         return ( repositoryRegistry.find( "npanday-settings" ) != null );
     }
 
+    public void clearCache()
+    {
+        if ( cachedVendorInfos != null )
+        {
+            cachedVendorInfos.clear();
+            cachedVendorInfos = null;
+        }
+    }
+
     private File getInstallRootFor( VendorInfo vendorInfo )
         throws PlatformUnsupportedException
     {
@@ -121,8 +131,25 @@ public class VendorInfoRepositoryImpl
     {
         SettingsRepository settingsRepository = (SettingsRepository) 
repositoryRegistry.find( "npanday-settings" );
 
-        if (cachedVendorInfos != null)
-            return Collections.unmodifiableList( cachedVendorInfos );;
+        if ( settingsRepository.isReloaded() )
+        {
+            clearCache();
+            settingsRepository.setReloaded(false);
+        }
+
+        try
+        {
+            settingsRepository.reload();
+        }
+        catch(Exception e)
+        {
+            //e.printStackTrace();
+        }
+ 
+        if ( cachedVendorInfos != null && cachedVendorInfos.size() > 0 &&  
!settingsRepository.isReloaded() )
+        {
+            return Collections.unmodifiableList( cachedVendorInfos );
+        }
 
         cachedVendorInfos = new ArrayList<VendorInfo>();
 
@@ -154,6 +181,7 @@ public class VendorInfoRepositoryImpl
                 cachedVendorInfos.add( vendorInfo );
             }
         }
+        settingsRepository.setReloaded( false );
         return Collections.unmodifiableList( cachedVendorInfos );
     }
 

Modified: 
incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java?rev=1079328&r1=1079327&r2=1079328&view=diff
==============================================================================
--- 
incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
 (original)
+++ 
incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
 Tue Mar  8 11:26:56 2011
@@ -26,6 +26,8 @@ import npanday.executable.ExecutionExcep
 import npanday.executable.compiler.CompilerConfig;
 import npanday.executable.compiler.CompilerExecutable;
 import npanday.executable.compiler.CompilerRequirement;
+import npanday.registry.RepositoryRegistry;
+import npanday.vendor.impl.SettingsRepository;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
@@ -51,6 +53,8 @@ import java.util.List;
 import java.util.regex.Pattern;
 import java.util.regex.Matcher;
 import java.util.*;
+import java.util.Hashtable;
+import java.io.*;
 
 /**
  * Abstract Class for compile mojos for both test-compile and compile.
@@ -61,6 +65,10 @@ public abstract class AbstractCompilerMo
         extends AbstractMojo
 {
 
+    /**
+     * @parameter expression ="${npanday.settings}"
+     */
+    private String settingsPath;
 
     /**
      * Skips compiling of unit tests
@@ -699,7 +707,10 @@ public abstract class AbstractCompilerMo
      */
     protected String testNowarn;
 
-
+    /**
+     * @component
+     */
+    private RepositoryRegistry repositoryRegistry;
 
     /**
      * Compiles the class files.
@@ -1072,7 +1083,8 @@ public abstract class AbstractCompilerMo
                
                }
                
-               
+        getNPandaySettingsPath();
+        
                if (localRepository == null)
         {
             
@@ -1170,7 +1182,12 @@ public abstract class AbstractCompilerMo
 
     protected boolean isUpToDateWithPomAndSettingsAndDependencies(File 
targetFile)
     {
-        File settingsFile = new File(localRepository, 
".m2/npanday-settings.xml");
+        if ( settingsPath == null )
+        {
+            settingsPath = System.getProperty( "user.home" ) + "/.m2";
+        }
+                
+        File settingsFile = new File( settingsPath, "npanday-settings.xml" );
         Artifact latestDependencyModification =
                 
this.getLatestDependencyModification(project.getDependencyArtifacts());
 
@@ -1221,4 +1238,37 @@ public abstract class AbstractCompilerMo
     }
 
 
+    protected void getNPandaySettingsPath()
+    {
+        if ( settingsPath == null )
+        {
+            settingsPath = System.getProperty( "user.home" ) + "/.m2";
+        }
+                
+        File settingsFile = new File( settingsPath, "npanday-settings.xml" );
+        
+        try
+        {
+            SettingsRepository settingsRepository = ( SettingsRepository) 
repositoryRegistry.find( "npanday-settings" );
+
+            if ( settingsRepository != null )
+            {
+                System.out.println(  "Removing settingsRepository" );
+                repositoryRegistry.removeRepository( "npanday-settings" );
+            }
+            Hashtable props = new Hashtable();
+            InputStream stream = new FileInputStream( settingsFile );    
+            settingsRepository = new SettingsRepository();
+            settingsRepository.setSourceUri( settingsFile.getAbsolutePath() );
+            settingsRepository.setRepositoryRegistry( repositoryRegistry );
+            settingsRepository.load( stream, props );
+            repositoryRegistry.addRepository( "npanday-settings", 
settingsRepository );        
+        }   
+        catch ( Exception ex )
+        {
+            ex.printStackTrace();
+        }    
+    }
+
+    
 }

Modified: 
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/javabinding/src/main/java/NPanday/Plugin/Settings/SettingsGeneratorMojo.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/javabinding/src/main/java/NPanday/Plugin/Settings/SettingsGeneratorMojo.java?rev=1079328&r1=1079327&r2=1079328&view=diff
==============================================================================
--- 
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/javabinding/src/main/java/NPanday/Plugin/Settings/SettingsGeneratorMojo.java
 (original)
+++ 
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/javabinding/src/main/java/NPanday/Plugin/Settings/SettingsGeneratorMojo.java
 Tue Mar  8 11:26:56 2011
@@ -19,10 +19,15 @@
 
  package NPanday.Plugin.Settings;
 
+import npanday.artifact.ArtifactContext;
+import npanday.registry.RepositoryRegistry;
+import npanday.registry.impl.StandardRepositoryLoader;
+import npanday.vendor.impl.SettingsRepository;
 import npanday.plugin.FieldAnnotation;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 
+import 
org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
@@ -31,13 +36,14 @@ import javax.xml.parsers.DocumentBuilder
 import java.io.FileReader;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.List;
 import java.util.Iterator;
 import org.apache.maven.model.Plugin;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 import java.io.BufferedReader;
-import java.io.FileReader;
-
+import java.util.Hashtable;
+import java.io.*;
 
 /**
  * @phase validate
@@ -72,6 +78,11 @@ public class SettingsGeneratorMojo
      */
     private String frameworkVersion;
 
+    /**    
+     * @parameter default-value="false" 
+     */
+    private boolean skip;
+    
     /**
      * @component
      */
@@ -82,6 +93,17 @@ public class SettingsGeneratorMojo
      */
     private npanday.plugin.PluginContext pluginContext;
 
+    /**  
+     * @parameter expression ="${npanday.settings}"
+     */
+    private String settingsPath;
+    
+    /**
+     * @parameter expression = "${npanday.settings}"
+     */
+    @FieldAnnotation()
+    public java.lang.String npandaySettingsPath;    
+    
     public String getMojoArtifactId()
     {
         return "NPanday.Plugin.Settings";
@@ -132,8 +154,10 @@ public class SettingsGeneratorMojo
         return frameworkVersion;
     }
 
-    /** @parameter default-value="false" */
-    private boolean skip;
+    /**
+     * @component
+     */
+    private RepositoryRegistry repositoryRegistry;
 
     public boolean preExecute()
         throws MojoExecutionException, MojoFailureException
@@ -166,8 +190,12 @@ public class SettingsGeneratorMojo
         throws MojoExecutionException
     {
 
-        String npandaySettings = System.getProperty( "user.home" ) + 
File.separator + ".m2" + File.separator + "npanday-settings.xml";
-        File file = new File( npandaySettings );
+        if ( settingsPath == null )
+        {
+            settingsPath = System.getProperty( "user.home" ) + "/.m2";
+        }
+        
+        File file = new File( settingsPath, "npanday-settings.xml" );
 
         if ( !file.exists() )
         {
@@ -176,7 +204,19 @@ public class SettingsGeneratorMojo
 
         try
         {
-            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            SettingsRepository settingsRepository = ( SettingsRepository) 
repositoryRegistry.find( "npanday-settings" );
+
+            if ( settingsRepository != null )
+            {
+                repositoryRegistry.removeRepository( "npanday-settings" );
+            }
+            Hashtable props = new Hashtable();
+            InputStream stream = new FileInputStream( file );    
+            settingsRepository = new SettingsRepository();
+            settingsRepository.setSourceUri( file.getAbsolutePath() );
+            settingsRepository.setRepositoryRegistry( repositoryRegistry );
+            settingsRepository.load( stream, props );
+            repositoryRegistry.addRepository( "npanday-settings", 
settingsRepository );            DocumentBuilderFactory dbf = 
DocumentBuilderFactory.newInstance();
             DocumentBuilder db = dbf.newDocumentBuilder();
             Document doc = db.parse( file );
             doc.getDocumentElement().normalize();
@@ -231,4 +271,26 @@ public class SettingsGeneratorMojo
        return null;
     }
 
+    public void postExecute()
+        throws MojoExecutionException, MojoFailureException
+    {
+        try
+        {
+            RepositoryRegistry repositoryRegistry = (RepositoryRegistry) 
container.lookup( RepositoryRegistry.ROLE );
+            SettingsRepository settingsRepository = (SettingsRepository) 
repositoryRegistry.find( "npanday-settings" );
+            if ( settingsRepository != null )
+            {
+                settingsRepository.reload();
+            }
+        }
+        catch ( ComponentLookupException e )
+        {
+            e.printStackTrace();
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+
+    }
 }

Modified: 
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/src/main/csharp/NPanday/Plugin/Settings/SettingsGeneratorMojo.cs
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/src/main/csharp/NPanday/Plugin/Settings/SettingsGeneratorMojo.cs?rev=1079328&r1=1079327&r2=1079328&view=diff
==============================================================================
--- 
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/src/main/csharp/NPanday/Plugin/Settings/SettingsGeneratorMojo.cs
 (original)
+++ 
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/src/main/csharp/NPanday/Plugin/Settings/SettingsGeneratorMojo.cs
 Tue Mar  8 11:26:56 2011
@@ -33,6 +33,9 @@ namespace NPanday.Plugin.Settings
     {
         public SettingsGeneratorMojo() { }
 
+        [FieldAttribute("npandaySettingsPath", Expression = 
"${npanday.settings}", Type = "java.lang.String")]
+        public string npandaySettingsPath;
+
                public override Type GetMojoImplementationType()
                {
                        return this.GetType();
@@ -40,7 +43,16 @@ namespace NPanday.Plugin.Settings
 
         public override void Execute()
         {
-               string outputFile = 
Environment.GetEnvironmentVariable("USERPROFILE") + "/.m2/npanday-settings.xml";
+            string outputFile;
+            if (String.IsNullOrEmpty( npandaySettingsPath ))
+            {
+                outputFile = Environment.GetEnvironmentVariable("USERPROFILE") 
+ "/.m2/npanday-settings.xml";
+            }
+            else
+            {
+                outputFile = npandaySettingsPath + "/npanday-settings.xml";
+            }
+
             XmlSerializer serializer = new 
XmlSerializer(typeof(npandaySettings));
 
             npandaySettings  settings = new npandaySettings();


Reply via email to