Author: lcorneliussen
Date: Wed Apr 27 22:18:34 2011
New Revision: 1097262

URL: http://svn.apache.org/viewvc?rev=1097262&view=rev
Log:
[NPANDAY-377] Joined all PathHandling in PathUtil, and all writing of Settings 
in SettingsUtil. Also added a fallback to .m2/npanday-settings.xml whenever 
settings could not be loaded. Will now only return null, if the file doesn't 
exist - else fail. ITs pass.

Added:
    
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsException.java
    
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsUtil.java
Modified:
    
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/PathUtil.java
    
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/RepositoryRegistryImpl.java
    
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/StateMachineProcessorImpl.java
    
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoTransitionRuleFactory.java
    
incubator/npanday/trunk/plugins/maven-aspx-plugin/src/main/java/npanday/plugin/aspx/AspxCompilerMojo.java
    
incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/groovy/npanday/plugin/compile/CompileLifecycleMap.groovy
    
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

Modified: 
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/PathUtil.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/PathUtil.java?rev=1097262&r1=1097261&r2=1097262&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/PathUtil.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/PathUtil.java
 Wed Apr 27 22:18:34 2011
@@ -316,4 +316,17 @@ public final class PathUtil
 
         return false;
     }
+
+    public static File buildSettingsFilePath( String settingsPathOrFile )
+    {
+        if (settingsPathOrFile.endsWith( "xml" ))
+            return new File(settingsPathOrFile);
+
+        return new File( settingsPathOrFile, "npanday-settings.xml" );
+    }
+
+    public static String getHomeM2Folder()
+    {
+        return new File(System.getProperty( "user.home" ), 
".m2").getAbsolutePath();
+    }
 }

Modified: 
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/RepositoryRegistryImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/RepositoryRegistryImpl.java?rev=1097262&r1=1097261&r2=1097262&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/RepositoryRegistryImpl.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/RepositoryRegistryImpl.java
 Wed Apr 27 22:18:34 2011
@@ -32,6 +32,7 @@ import java.io.InputStream;
 import java.io.IOException;
 import java.io.FileInputStream;
 
+import org.apache.maven.settings.SettingsUtils;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
 import 
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
 

Added: 
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsException.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsException.java?rev=1097262&view=auto
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsException.java
 (added)
+++ 
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsException.java
 Wed Apr 27 22:18:34 2011
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package npanday.vendor;
+
+/**
+ *   Exception class thrown when there is trouble reading the NPanday-Settings.
+ *   @author Lars Corneliussen ([email protected])
+ */
+public class SettingsException
+    extends Throwable
+{
+    public SettingsException()
+    {
+    }
+
+    public SettingsException( String message )
+    {
+        super( message );
+    }
+
+    public SettingsException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+    public SettingsException( Throwable cause )
+    {
+        super( cause );
+    }
+}

Added: 
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsUtil.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsUtil.java?rev=1097262&view=auto
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsUtil.java
 (added)
+++ 
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsUtil.java
 Wed Apr 27 22:18:34 2011
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package npanday.vendor;
+
+import npanday.PathUtil;
+import npanday.registry.RepositoryRegistry;
+import npanday.registry.impl.StandardRepositoryLoader;
+import npanday.vendor.impl.SettingsRepository;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Hashtable;
+
+/**
+ *   Central handling of creation and retrieval of the SettingsRepository.
+ *   @author Lars Corneliussen ([email protected])
+ */
+public class SettingsUtil
+{
+    /**
+     * Return the registered settings, or create from default settings file 
location (.m2/npanday-settings.xml)
+     * @param repositoryRegistry The registry.
+     * @return The current, or just created SettingsRepository
+     * @throws SettingsException If anything goes wrong reading or registering 
the settings
+     */
+    public static SettingsRepository getOrPopulateSettingsRepository( 
RepositoryRegistry repositoryRegistry)
+        throws SettingsException
+    {
+          return getOrPopulateSettingsRepository(repositoryRegistry, 
PathUtil.getHomeM2Folder());
+    }
+
+    /**
+     * Return the registered settings, or creates them from the given path or 
file.
+     * @param repositoryRegistry The registry.
+     * @param settingsPathOrFile If a path, 'npanday-settings.xml' is added.
+     * @return The current, or just created SettingsRepository
+     * @throws SettingsException If anything goes wrong reading or registering 
the settings
+     */
+    public static SettingsRepository getOrPopulateSettingsRepository( 
RepositoryRegistry repositoryRegistry, String settingsPathOrFile )
+        throws SettingsException
+    {
+        SettingsRepository settingsRepository = (SettingsRepository) 
repositoryRegistry.find( "npanday-settings" );
+        if (settingsRepository == null){
+            return populateSettingsRepository( repositoryRegistry, 
settingsPathOrFile);
+        }
+        return settingsRepository;
+    }
+
+    /**
+     * Creates and registers the settings from the given path or file.
+     * @param repositoryRegistry The registry.
+     * @param settingsPathOrFile If a path, 'npanday-settings.xml' is added.
+     * @return The new Settings Repository.
+     * @throws SettingsException If anything goes wrong reading or registering 
the settings
+     */
+    public static SettingsRepository populateSettingsRepository( 
RepositoryRegistry repositoryRegistry, String settingsPathOrFile )
+        throws SettingsException
+    {
+        SettingsRepository settingsRepository;
+        try
+        {
+            settingsRepository = ( SettingsRepository) 
repositoryRegistry.find( "npanday-settings" );
+        }
+        catch ( Exception ex )
+        {
+            throw new SettingsException( "NPANDAY-108-001: Error finding 
npanday-settings in registry", ex );
+        }
+
+        if ( settingsRepository != null )
+        {
+            try
+            {
+                repositoryRegistry.removeRepository( "npanday-settings" );
+            }
+            catch ( Exception ex )
+            {
+                throw new SettingsException( "NPANDAY-108-002: Error removing 
npanday-settings from registry", ex );
+            }
+        }
+
+        File settingsFile = PathUtil.buildSettingsFilePath( settingsPathOrFile 
);
+
+        if (!settingsFile.exists())
+        {
+            return null;
+        }
+
+        try
+        {
+            StandardRepositoryLoader repoLoader = new 
StandardRepositoryLoader();
+            repoLoader.setRepositoryRegistry( repositoryRegistry );
+            settingsRepository = (SettingsRepository) 
repoLoader.loadRepository( settingsFile.getAbsolutePath(),
+                                                                               
  SettingsRepository.class.getName(),
+                                                                               
  new Hashtable() );
+            repositoryRegistry.addRepository( "npanday-settings", 
settingsRepository );
+            assert settingsRepository != null;
+
+            return settingsRepository;
+        }
+        catch ( IOException e )
+        {
+            throw new SettingsException( "NPANDAY-108-003: Error loading " + 
settingsFile.getAbsolutePath(), e );
+        }
+    }
+}

Modified: 
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/StateMachineProcessorImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/StateMachineProcessorImpl.java?rev=1097262&r1=1097261&r2=1097262&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/StateMachineProcessorImpl.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/StateMachineProcessorImpl.java
 Wed Apr 27 22:18:34 2011
@@ -74,6 +74,16 @@ public final class StateMachineProcessor
     public void initialize()
         throws InitializationException
     {
+        SettingsRepository settingsRepository;
+        try
+        {
+            settingsRepository = SettingsUtil.getOrPopulateSettingsRepository( 
repositoryRegistry );
+        }
+        catch ( SettingsException e )
+        {
+            throw new InitializationException( "NPANDAY-102-007: Could not get 
settings." , e);
+        }
+
         VendorInfoTransitionRuleFactory factory = new 
VendorInfoTransitionRuleFactory();
         transitionRules = new HashMap<VendorInfoState, 
VendorInfoTransitionRule>();
         transitionRules.put( VendorInfoState.MTT, 
factory.createVendorInfoSetterForMTT() );
@@ -81,11 +91,17 @@ public final class StateMachineProcessor
         transitionRules.put( VendorInfoState.MFT, 
factory.createVendorInfoSetterForMFT() );
         transitionRules.put( VendorInfoState.NTT, 
factory.createVendorInfoSetterForNTT() );
         transitionRules.put( VendorInfoState.POST_PROCESS, 
factory.createPostProcessRule() );
-        try
+
+        if ( settingsRepository != null )
         {
-            logger.debug( "NPANDAY-102-012: Initialized rule factory 
repositoryRegistry:" + repositoryRegistry );        
-            factory.init( repositoryRegistry, vendorInfoRepository, logger );
-            logger.debug( "NPANDAY-102-000: Initialized rule factory." );
+            try
+            {
+                factory.init( repositoryRegistry, vendorInfoRepository, logger 
);
+            }
+            catch ( npanday.InitializationException e )
+            {
+                throw new InitializationException( "NPANDAY-102-008: 
Initializing rule factory failed." , e);
+            }
             transitionRules.put( VendorInfoState.MFF, 
factory.createVendorInfoSetterForMFF() );
             transitionRules.put( VendorInfoState.FTF, 
factory.createVendorInfoSetterForFTF() );
             transitionRules.put( VendorInfoState.FFT, 
factory.createVendorInfoSetterForFFT() );
@@ -97,9 +113,9 @@ public final class StateMachineProcessor
             transitionRules.put( VendorInfoState.NFF, 
factory.createVendorInfoSetterForNFF() );
             transitionRules.put( VendorInfoState.GFF, 
factory.createVendorInfoSetterForGFF() );
         }
-        catch ( npanday.InitializationException e )
+        else
         {
-            logger.debug( "NPANDAY-102-001: Unable to initialize rule 
factory.", e );
+            logger.info( "NPANDAY-102-001: No NPanday settings available. 
Using Defaults." );
             transitionRules.put( VendorInfoState.MFF, 
factory.createVendorInfoSetterForMFF_NoSettings() );
             transitionRules.put( VendorInfoState.NFT, 
factory.createVendorInfoSetterForNFT_NoSettings() );
             transitionRules.put( VendorInfoState.NTF, 
factory.createVendorInfoSetterForNTF_NoSettings() );
@@ -127,14 +143,14 @@ public final class StateMachineProcessor
         }
         for ( VendorInfoState state = VendorInfoState.START; !state.equals( 
VendorInfoState.EXIT ); )
         {
-            logger.debug( "NPANDAY-102-002: Apply rule:" + rule );        
+            logger.debug( "NPANDAY-102-003: Apply rule:" + rule );
             state = rule.process( vendorInfo );
-            logger.debug( "NPANDAY-102-003: Vendor info after rule:" + 
vendorInfo );            
+            logger.debug( "NPANDAY-102-004: Vendor info after rule:" + 
vendorInfo );
             rule = transitionRules.get( state );
             if ( rule == null && !state.equals( VendorInfoState.EXIT ) )
             {
                 throw new IllegalStateException(
-                    "NPANDAY-102-003: Could not find rule for state: State = " 
+ state.name() );
+                    "NPANDAY-102-005: Could not find rule for state: State = " 
+ state.name() );
             }
         }
     }

Modified: 
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoTransitionRuleFactory.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoTransitionRuleFactory.java?rev=1097262&r1=1097261&r2=1097262&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoTransitionRuleFactory.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoTransitionRuleFactory.java
 Wed Apr 27 22:18:34 2011
@@ -93,8 +93,16 @@ final class VendorInfoTransitionRuleFact
             throw new InitializationException( "NPANDAY-103-000: Unable to 
find the repository registry" );
         }
         logger.debug( "NPANDAY-103-036.0: Respository registry: " + 
repositoryRegistry);
-        
-        SettingsRepository settingsRepository = (SettingsRepository) 
repositoryRegistry.find( "npanday-settings" );
+
+        SettingsRepository settingsRepository = null;
+        try
+        {
+            settingsRepository = SettingsUtil.getOrPopulateSettingsRepository( 
repositoryRegistry );
+        }
+        catch ( SettingsException e )
+        {
+            throw new InitializationException( "NPANDAY-103-067: Could not get 
settings." , e);
+        }
         if ( settingsRepository == null )
         {
             throw new InitializationException(
@@ -450,11 +458,11 @@ final class VendorInfoTransitionRuleFact
             public VendorInfoState process( VendorInfo vendorInfo )
             {
                 logger.debug( "NPANDAY-103-011: Entering State = FTF" );
-                logger.debug( "NPANDAY-103-050: Compare vendor version :" + 
defaultVendorVersion + ":width:" + vendorInfo.getVendorVersion());
+                logger.debug( "NPANDAY-103-067: Compare vendor version :" + 
defaultVendorVersion + ":width:" + vendorInfo.getVendorVersion());
 
                 if ( vendorInfo.getVendorVersion().equals( 
defaultVendorVersion ) )
                 {
-                    logger.debug( "NPANDAY-103-050: Set to default version:" + 
defaultFrameworkVersion);
+                    logger.debug( "NPANDAY-103-065: Set to default version:" + 
defaultFrameworkVersion);
 
                     vendorInfo.setFrameworkVersion( defaultFrameworkVersion );
                     vendorInfo.setVendor( defaultVendor );
@@ -478,11 +486,11 @@ final class VendorInfoTransitionRuleFact
                     {
                         for ( VendorInfo vi : v )
                         {
-                            logger.debug( "NPANDAY-103-050: Compare vendor 
version :" + vi.getVendorVersion() + ":width:" + vendorInfo.getVendorVersion());
+                            logger.debug( "NPANDAY-103-064: Compare vendor 
version :" + vi.getVendorVersion() + ":width:" + vendorInfo.getVendorVersion());
 
                             if ( vi.getVendorVersion().equals( 
vendorInfo.getVendorVersion() ) )
                             {
-                                logger.debug( "NPANDAY-103-050: Set framework 
version:" + vi.getFrameworkVersion());
+                                logger.debug( "NPANDAY-103-063: Set framework 
version:" + vi.getFrameworkVersion());
 
                                 vendorInfo.setFrameworkVersion( 
vi.getFrameworkVersion() );
                                 vendorInfo.setVendor( vi.getVendor() );
@@ -507,11 +515,11 @@ final class VendorInfoTransitionRuleFact
                         v = vendorInfoRepository.getVendorInfosFor( 
vendorInfo, false );
                         for ( VendorInfo vi : v )
                         {
-                            logger.debug( "NPANDAY-103-050: Compare vendor 
version :" + vi.getVendorVersion() + ":width:" + vendorInfo.getVendorVersion());
+                            logger.debug( "NPANDAY-103-062: Compare vendor 
version :" + vi.getVendorVersion() + ":width:" + vendorInfo.getVendorVersion());
                         
                             if ( vi.getVendorVersion().equals( 
vendorInfo.getVendorVersion() ) )
                             {
-                                logger.debug( "NPANDAY-103-050: Set framework 
version:" + vi.getFrameworkVersion());
+                                logger.debug( "NPANDAY-103-061: Set framework 
version:" + vi.getFrameworkVersion());
                             
                                 vendorInfo.setFrameworkVersion( 
vi.getFrameworkVersion() );
                                 vendorInfo.setVendor( vi.getVendor() );

Modified: 
incubator/npanday/trunk/plugins/maven-aspx-plugin/src/main/java/npanday/plugin/aspx/AspxCompilerMojo.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-aspx-plugin/src/main/java/npanday/plugin/aspx/AspxCompilerMojo.java?rev=1097262&r1=1097261&r2=1097262&view=diff
==============================================================================
--- 
incubator/npanday/trunk/plugins/maven-aspx-plugin/src/main/java/npanday/plugin/aspx/AspxCompilerMojo.java
 (original)
+++ 
incubator/npanday/trunk/plugins/maven-aspx-plugin/src/main/java/npanday/plugin/aspx/AspxCompilerMojo.java
 Wed Apr 27 22:18:34 2011
@@ -22,7 +22,6 @@ package npanday.plugin.aspx;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Hashtable;
 import java.util.List;
 
 import npanday.ArtifactType;
@@ -32,14 +31,13 @@ import npanday.executable.compiler.Compi
 import npanday.executable.compiler.CompilerExecutable;
 import npanday.executable.compiler.CompilerRequirement;
 import npanday.registry.RepositoryRegistry;
-import npanday.registry.impl.StandardRepositoryLoader;
+import npanday.vendor.SettingsException;
+import npanday.vendor.SettingsUtil;
 import npanday.vendor.VendorFactory;
-import npanday.vendor.impl.SettingsRepository;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.StringUtils;
 
 /**
  * Maven Mojo for precompiling ASPx files
@@ -161,9 +159,16 @@ public class AspxCompilerMojo
     {
         long startTime = System.currentTimeMillis();
 
-        populateSettingsRepository();
+        try
+        {
+            SettingsUtil.populateSettingsRepository( repositoryRegistry, 
settingsPath );
+        }
+        catch ( SettingsException e )
+        {
+            throw new MojoExecutionException( "NPANDAY-109-001: Error reading 
settings from " + settingsPath, e );
+        }
 
-        webSourceDirectory = new File( project.getBuild().getSourceDirectory() 
); 
+        webSourceDirectory = new File( project.getBuild().getSourceDirectory() 
);
 
         if ( profileAssemblyPath != null && !profileAssemblyPath.exists() )
         {
@@ -413,35 +418,4 @@ public class AspxCompilerMojo
             deleteDirectoryIfEmpty( directory.getParentFile() );
         }
     }
-    
-    protected void populateSettingsRepository()
-    {
-        File settingsFile = new File( settingsPath, "npanday-settings.xml" );
-
-        try
-        {
-            SettingsRepository settingsRepository = (SettingsRepository) 
repositoryRegistry.find( "npanday-settings" );
-
-            if ( settingsRepository != null )
-            {
-                repositoryRegistry.removeRepository( "npanday-settings" );
-            }
-            try
-            {
-                StandardRepositoryLoader repoLoader = new 
StandardRepositoryLoader();
-                repoLoader.setRepositoryRegistry( repositoryRegistry );
-                settingsRepository = (SettingsRepository) 
repoLoader.loadRepository( settingsFile.getAbsolutePath(), 
SettingsRepository.class.getName(), new Hashtable() );
-                repositoryRegistry.addRepository( "npanday-settings", 
settingsRepository );
-            }
-            catch ( IOException e )
-            {
-                getLog().error( e.getMessage(), e );            
-            }            
-        }
-        catch ( Exception ex )
-        {
-            getLog().error( ex.getMessage(), ex );
-        }
-    }
-    
 }

Modified: 
incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/groovy/npanday/plugin/compile/CompileLifecycleMap.groovy
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/groovy/npanday/plugin/compile/CompileLifecycleMap.groovy?rev=1097262&r1=1097261&r2=1097262&view=diff
==============================================================================
--- 
incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/groovy/npanday/plugin/compile/CompileLifecycleMap.groovy
 (original)
+++ 
incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/groovy/npanday/plugin/compile/CompileLifecycleMap.groovy
 Wed Apr 27 22:18:34 2011
@@ -39,7 +39,7 @@ class CompileLifecycleMap extends Lifecy
        def mv_deploy = "org.apache.maven.plugins:maven-deploy-plugin:deploy" 
        
        def np_generate_settings = 
"npanday.plugin:NPanday.Plugin.Settings.JavaBinding:generate-settings" 
-       def np_compile_init = "npanday.plugin:maven-compile-plugin:initialize" 
+       def np_compile_init = "npanday.plugin:maven-compile-plugin:initialize"
        def np_resolve = "npanday.plugin:maven-resolver-plugin:resolve" 
        def np_generate_assemblyinfo = 
"npanday.plugin:maven-compile-plugin:generate-assembly-info" 
        def np_compile_process_sources = 
"npanday.plugin:maven-compile-plugin:process-sources" 

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=1097262&r1=1097261&r2=1097262&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
 Wed Apr 27 22:18:34 2011
@@ -20,15 +20,16 @@
 package npanday.plugin.compile;
 
 import npanday.ArtifactTypeHelper;
+import npanday.PathUtil;
+import npanday.vendor.SettingsException;
+import npanday.vendor.SettingsUtil;
 import org.apache.maven.artifact.Artifact;
 import npanday.PlatformUnsupportedException;
 import npanday.executable.ExecutionException;
 import npanday.executable.compiler.CompilerConfig;
 import npanday.executable.compiler.CompilerExecutable;
 import npanday.executable.compiler.CompilerRequirement;
-import npanday.registry.impl.StandardRepositoryLoader;
 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;
@@ -46,16 +47,12 @@ import java.util.Set;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import org.w3c.dom.Document;
-import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 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.
@@ -1083,10 +1080,17 @@ public abstract class AbstractCompilerMo
                {
                
                }
-               
-        populateSettingsRepository();
-        
-               if (localRepository == null)
+
+        try
+        {
+            SettingsUtil.populateSettingsRepository( repositoryRegistry, 
settingsPath );
+        }
+        catch ( SettingsException e )
+        {
+            throw new MojoExecutionException( "NPANDAY-900-012: Error reading 
settings from " + settingsPath, e );
+        }
+
+        if (localRepository == null)
         {
             
                        localRepository = new 
File(System.getProperty("user.home"), ".m2/repository");
@@ -1183,7 +1187,7 @@ public abstract class AbstractCompilerMo
 
     protected boolean isUpToDateWithPomAndSettingsAndDependencies(File 
targetFile)
     {
-        File settingsFile = new File( settingsPath, "npanday-settings.xml" );
+        File settingsFile = PathUtil.buildSettingsFilePath(settingsPath);
         Artifact latestDependencyModification =
                 
this.getLatestDependencyModification(project.getDependencyArtifacts());
 
@@ -1233,41 +1237,4 @@ public abstract class AbstractCompilerMo
         return lastModArtifact;
     }
 
-
-    protected void populateSettingsRepository()
-    {
-        File settingsFile = new File( settingsPath, "npanday-settings.xml" );
-        
-        if (!settingsFile.exists())
-        {
-            return;
-        }
-
-        try
-        {
-            SettingsRepository settingsRepository = ( SettingsRepository) 
repositoryRegistry.find( "npanday-settings" );
-
-            if ( settingsRepository != null )
-            {
-                repositoryRegistry.removeRepository( "npanday-settings" );
-            }
-            try
-            {
-                StandardRepositoryLoader repoLoader = new 
StandardRepositoryLoader();
-                repoLoader.setRepositoryRegistry( repositoryRegistry );
-                settingsRepository = (SettingsRepository) 
repoLoader.loadRepository( settingsFile.getAbsolutePath(), 
SettingsRepository.class.getName(), new Hashtable() );
-                repositoryRegistry.addRepository( "npanday-settings", 
settingsRepository );
-            }
-            catch ( IOException e )
-            {
-                getLog().error( e.getMessage(), e );
-            }
-        }
-        catch ( Exception ex )
-        {
-            getLog().error( ex.getMessage(), ex );
-        }
-    }
-
-
 }

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=1097262&r1=1097261&r2=1097262&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
 Wed Apr 27 22:18:34 2011
@@ -19,9 +19,11 @@
 
  package NPanday.Plugin.Settings;
 
-import npanday.artifact.ArtifactContext;
+import npanday.PathUtil;
 import npanday.registry.RepositoryRegistry;
 import npanday.registry.impl.StandardRepositoryLoader;
+import npanday.vendor.SettingsException;
+import npanday.vendor.SettingsUtil;
 import npanday.vendor.impl.SettingsRepository;
 import npanday.plugin.FieldAnnotation;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -33,7 +35,6 @@ import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
-import java.io.FileReader;
 
 import java.io.File;
 import java.io.IOException;
@@ -41,9 +42,8 @@ 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.util.Hashtable;
-import java.io.*;
 
 /**
  * @phase validate
@@ -196,28 +196,24 @@ public class SettingsGeneratorMojo
     public boolean isFrameworkVersionExisting(String frameworkVersion)
         throws MojoExecutionException, IOException
     {
-        File file = new File( settingsPath, "npanday-settings.xml" );
+        File file = PathUtil.buildSettingsFilePath( settingsPath );
 
         if ( !file.exists() )
         {
             return false;
         }
 
-        SettingsRepository settingsRepository = ( SettingsRepository) 
repositoryRegistry.find( "npanday-settings" );
-
-        if ( settingsRepository != null )
+        try
         {
-            repositoryRegistry.removeRepository( "npanday-settings" );
+            SettingsUtil.populateSettingsRepository( repositoryRegistry, 
settingsPath );
+        }
+        catch ( SettingsException e )
+        {
+            throw new MojoExecutionException( "NPANDAY-112: Could not populate 
settings", e );
         }
 
         try
         {
-            // load npanday-settings and store in registry
-            StandardRepositoryLoader repoLoader = new 
StandardRepositoryLoader();
-            repoLoader.setRepositoryRegistry( repositoryRegistry );
-            settingsRepository = (SettingsRepository) 
repoLoader.loadRepository( file.getAbsolutePath(), 
SettingsRepository.class.getName(), new Hashtable() );
-            repositoryRegistry.addRepository( "npanday-settings", 
settingsRepository );
-
             // check if npanday-settings contains the framework
             DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
             DocumentBuilder db = dbf.newDocumentBuilder();


Reply via email to