You are viewing a plain text version of this content. The canonical link for it is here.
Posted to npanday-commits@incubator.apache.org by lc...@apache.org on 2011/12/07 09:18:47 UTC
svn commit: r1211347 [1/3] - in
/incubator/npanday/branches/1.5.0-azuresupport:
components/dotnet-core/src/main/resources/META-INF/npanday/
components/dotnet-executable/src/main/java/npanday/executable/
components/dotnet-executable/src/main/java/npanda...
Author: lcorneliussen
Date: Wed Dec 7 09:18:45 2011
New Revision: 1211347
URL: http://svn.apache.org/viewvc?rev=1211347&view=rev
Log:
[NPANDAY-499] Make configuration for compiler-plugins and executable-plugins more flexible
o Splitted up VendorInfo in VendorRequirement (class) and VendorInfo (interface) with appropriate implementations
o Introduced interface for SettingsRepository for easier testing
Added:
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsRepository.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorRequirement.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorRequirementState.java (contents, props changed)
- copied, changed from r1207095, incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoState.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorUnknownException.java (contents, props changed)
- copied, changed from r1207095, incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorUnsupportedException.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/FileBasedSettingsRepository.java
- copied, changed from r1210570, incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsRepository.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/MutableVendorInfo.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsBasedVendorInfo.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/VendorRequirementStateTest.java (contents, props changed)
- copied, changed from r1207095, incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/VendorInfoStateTest.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/impl/VendorInfoRepositoryTest.java (contents, props changed)
- copied, changed from r1207095, incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/impl/SettingsRepositoryTest.java
Removed:
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoState.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorUnsupportedException.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsRepository.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/VendorInfoStateTest.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/impl/SettingsRepositoryTest.java
Modified:
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-core/src/main/resources/META-INF/npanday/registry-config.xml
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/ExecutableRequirement.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/NetExecutableFactory.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerRequirement.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultRepositoryNetExecutable.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/impl/NetExecutableFactoryImpl.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-plugin/src/main/java/npanday/plugin/AbstractMojo.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-plugin/src/main/java/npanday/plugin/impl/ConfigurationAppendersRepository.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/RepositoryRegistryImpl.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsUtil.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/StateMachineProcessor.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/Vendor.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorFactory.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfo.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoRepository.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoTransitionRule.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/StateMachineProcessorImpl.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoRepositoryImpl.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoTransitionRuleFactory.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/VendorTestFactory.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/impl/MatchPolicyFactoryTest.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/impl/RepositoryRegistryTestStub.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/impl/VendorInfoRepositoryTestStub.java
incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/impl/VendorInfoTransitionRuleFactoryTest.java
incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-aspx-plugin/src/main/java/npanday/plugin/aspx/AspxCompilerMojo.java
incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AssemblyInfoGeneratorMojo.java
incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/CompilerMojo.java
incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/TestCompilerMojo.java
incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-ilmerge-plugin/src/main/java/npanday/plugin/ilmerge/AssemblyMerger.java
incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-mojo-generator-plugin/src/main/java/npanday/plugin/generator/MojoGeneratorMojo.java
incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-test-plugin/src/main/java/npanday/plugin/test/TesterMojo.java
incubator/npanday/branches/1.5.0-azuresupport/plugins/netplugins/NPanday.Plugin.Settings/javabinding/src/main/java/NPanday/Plugin/Settings/SettingsGeneratorMojo.java
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-core/src/main/resources/META-INF/npanday/registry-config.xml
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-core/src/main/resources/META-INF/npanday/registry-config.xml?rev=1211347&r1=1211346&r2=1211347&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-core/src/main/resources/META-INF/npanday/registry-config.xml (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-core/src/main/resources/META-INF/npanday/registry-config.xml Wed Dec 7 09:18:45 2011
@@ -21,7 +21,7 @@ under the License.
<repositories>
<repository>
<repository-name>npanday-settings</repository-name>
- <repository-class>npanday.vendor.impl.SettingsRepository</repository-class>
+ <repository-class>npanday.vendor.SettingsRepository</repository-class>
<!--dummy variable - not needed since it will be populated in the code during generation of npanday-settings.xml-->
<repository-config>*</repository-config>
<init-param>
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/ExecutableRequirement.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/ExecutableRequirement.java?rev=1211347&r1=1211346&r2=1211347&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/ExecutableRequirement.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/ExecutableRequirement.java Wed Dec 7 09:18:45 2011
@@ -19,6 +19,8 @@
package npanday.executable;
import npanday.vendor.Vendor;
+import npanday.vendor.VendorFactory;
+import npanday.vendor.VendorRequirement;
/**
* Requirements that the executable plugin must satisfy to be used in the build.
@@ -71,11 +73,21 @@ public interface ExecutableRequirement
*/
void setVendor( Vendor vendor );
+ /**
+ * Sets the vendor through its name.
+ */
+ void setVendor( String vendorName );
+
void setVendorVersion( String vendorVersion );
String getVendorVersion();
/**
+ * Copies the relevant properties to a new VendorRequirement
+ */
+ VendorRequirement toVendorRequirement();
+
+ /**
* Provides factory services for creating a default instance of the executable requirement.
*/
public static class Factory
@@ -110,6 +122,12 @@ public interface ExecutableRequirement
return vendorVersion;
}
+ public VendorRequirement toVendorRequirement()
+ {
+ return new VendorRequirement(vendor, vendorVersion, frameworkVersion);
+
+ }
+
public void setVendorVersion( String vendorVersion )
{
this.vendorVersion = vendorVersion;
@@ -135,6 +153,11 @@ public interface ExecutableRequirement
this.vendor = vendor;
}
+ public void setVendor( String vendorName )
+ {
+ setVendor( VendorFactory.createVendorFromName( vendorName ) );
+ }
+
public String getProfile()
{
return profile;
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/NetExecutableFactory.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/NetExecutableFactory.java?rev=1211347&r1=1211346&r2=1211347&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/NetExecutableFactory.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/NetExecutableFactory.java Wed Dec 7 09:18:45 2011
@@ -18,17 +18,16 @@
*/
package npanday.executable;
-import org.apache.maven.project.MavenProject;
-
-import java.util.List;
-import java.io.File;
-
-import npanday.vendor.VendorInfo;
-import npanday.executable.compiler.CompilerRequirement;
+import npanday.PlatformUnsupportedException;
import npanday.executable.compiler.CompilerConfig;
import npanday.executable.compiler.CompilerExecutable;
-import npanday.PlatformUnsupportedException;
+import npanday.executable.compiler.CompilerRequirement;
+import npanday.vendor.VendorRequirement;
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.project.MavenProject;
+
+import java.io.File;
+import java.util.List;
/**
* Provides services to obtain executables. This interface is intended to be used by <code>AbstractMojo</code>
@@ -65,30 +64,31 @@ public interface NetExecutableFactory
/**
* Returns an executable that resides within a maven repository. These are typically user-implemented executables.
*
+ *
* @param groupId the group ID of the executable artifact (as specified within the maven repo)
* @param artifactId the artifact ID of the executable artifact (as specified within the maven repo)
- * @param vendorInfo the additional vendor information used to decide how to execute the net executable
- * @param localRepository the local maven repository where the executable resides.
+ * @param vendorRequirement
+ *@param localRepository the local maven repository where the executable resides.
* @param isIsolatedAppDomain the executable can load up assemblies into an isolated application domain. This should
- * be set to true if the application needs to load up assemblies into another app domain
- * and to remotly invoke methods on classes in the other app domain, otherwise it should be
- * set to false.
- * @return the executable that resides within a maven repository.
+ * be set to true if the application needs to load up assemblies into another app domain
+ * and to remotly invoke methods on classes in the other app domain, otherwise it should be
+ * set to false. @return the executable that resides within a maven repository.
* @throws PlatformUnsupportedException if no executable is found
*/
- NetExecutable getNetExecutableFromRepository( String groupId, String artifactId, VendorInfo vendorInfo,
+ NetExecutable getNetExecutableFromRepository( String groupId, String artifactId, VendorRequirement vendorRequirement,
File localRepository, List<String> commands,
boolean isIsolatedAppDomain )
throws PlatformUnsupportedException;
/**
*
+ *
* @param vendorInfo
* @param commands
* @return
* @throws PlatformUnsupportedException
*/
- NetExecutable getJavaExecutableFromRepository( VendorInfo vendorInfo, List<String> commands )
+ NetExecutable getJavaExecutableFromRepository( VendorRequirement vendorInfo, List<String> commands )
throws PlatformUnsupportedException;
/**
@@ -110,20 +110,20 @@ public interface NetExecutableFactory
/**
* Returns a plugin loader for loading and executing a .NET plugin.
*
+ *
* @param groupId the group ID of the executable artifact (as specified within the maven repo)
* @param artifactId the artifact ID of the executable artifact (as specified within the maven repo)
- * @param vendorInfo the additional vendor information used to decide how to execute the net executable
- * @param localRepository the local maven repository where the executable resides.
+ * @param vendorRequirement
+ *@param localRepository the local maven repository where the executable resides.
* @param parameterFile the file containing parameter information to inject into the .NET plugin
- * @param mojoName the name of the .NET Mojo implementation
- * @return the plugin loader for executing a .NET plugin
+ * @param mojoName the name of the .NET Mojo implementation @return the plugin loader for executing a .NET plugin
* @throws PlatformUnsupportedException if no executable is found
*/
- NetExecutable getPluginLoaderFor( String groupId, String artifactId, VendorInfo vendorInfo, String localRepository,
+ NetExecutable getPluginLoaderFor( String groupId, String artifactId, VendorRequirement vendorRequirement, String localRepository,
File parameterFile, String mojoName )
throws PlatformUnsupportedException;
- NetExecutable getPluginLoaderFor(Artifact artifact, VendorInfo vendorInfo, String localRepository, File parameterFile, String mojoName) throws PlatformUnsupportedException;
+ NetExecutable getPluginLoaderFor(Artifact artifact, VendorRequirement vendorRequirement, String localRepository, File parameterFile, String mojoName) throws PlatformUnsupportedException;
Artifact getArtifactFor(String groupId, String artifactId) throws PlatformUnsupportedException;
}
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerRequirement.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerRequirement.java?rev=1211347&r1=1211346&r2=1211347&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerRequirement.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerRequirement.java Wed Dec 7 09:18:45 2011
@@ -20,6 +20,10 @@ package npanday.executable.compiler;
import npanday.vendor.Vendor;
import npanday.executable.ExecutableRequirement;
+import npanday.vendor.VendorFactory;
+import npanday.vendor.VendorRequirement;
+
+import static com.google.common.base.Strings.isNullOrEmpty;
/**
* Requirements that the compiler plugin must satisfy to be used in the build.
@@ -71,6 +75,14 @@ public interface CompilerRequirement
return vendorVersion;
}
+ /**
+ * Copies the relevant properties to a new VendorRequirement
+ */
+ public VendorRequirement toVendorRequirement()
+ {
+ return new VendorRequirement( vendor, vendorVersion, frameworkVersion );
+ }
+
public void setVendorVersion( String vendorVersion )
{
this.vendorVersion = vendorVersion;
@@ -106,6 +118,14 @@ public interface CompilerRequirement
this.vendor = vendor;
}
+ public void setVendor( String vendorName )
+ {
+ if ( !isNullOrEmpty( vendorName ) )
+ {
+ setVendor( VendorFactory.createVendorFromName( vendorName ) );
+ }
+ }
+
public String getProfile()
{
return profile;
@@ -115,6 +135,8 @@ public interface CompilerRequirement
{
this.profile = profile;
}
+
+
};
}
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultRepositoryNetExecutable.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultRepositoryNetExecutable.java?rev=1211347&r1=1211346&r2=1211347&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultRepositoryNetExecutable.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultRepositoryNetExecutable.java Wed Dec 7 09:18:45 2011
@@ -148,7 +148,7 @@ public class DefaultRepositoryNetExecuta
}
catch ( ExecutionException e )
{
- return Vendor.NULL;
+ return null;
}
}
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/impl/NetExecutableFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/impl/NetExecutableFactoryImpl.java?rev=1211347&r1=1211346&r2=1211347&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/impl/NetExecutableFactoryImpl.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-executable/src/main/java/npanday/executable/impl/NetExecutableFactoryImpl.java Wed Dec 7 09:18:45 2011
@@ -38,9 +38,9 @@ import npanday.registry.RepositoryRegist
import npanday.vendor.IllegalStateException;
import npanday.vendor.StateMachineProcessor;
import npanday.vendor.Vendor;
-import npanday.vendor.VendorFactory;
import npanday.vendor.VendorInfo;
import npanday.vendor.VendorInfoRepository;
+import npanday.vendor.VendorRequirement;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.logging.AbstractLogEnabled;
@@ -55,8 +55,7 @@ import java.util.List;
*
* @author Shane Isbell
* @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
- * @plexus.component
- * role="npanday.executable.NetExecutableFactory"
+ * @plexus.component role="npanday.executable.NetExecutableFactory"
*/
public class NetExecutableFactoryImpl
extends AbstractLogEnabled
@@ -115,14 +114,9 @@ public class NetExecutableFactoryImpl
{
VendorInfo vendorInfo = VendorInfo.Factory.createDefaultVendorInfo();
- vendorInfo.setVendorVersion( compilerRequirement.getVendorVersion() );
- vendorInfo.setFrameworkVersion( compilerRequirement.getFrameworkVersion() );
- vendorInfo.setVendor( compilerRequirement.getVendor() );
try
{
- getLogger().debug(
- "NPANDAY-066-025 - Try to find executable for vendor:" + vendorInfo + ":processor:" + processor );
- processor.process( vendorInfo );
+ vendorInfo = processor.process( compilerRequirement.toVendorRequirement() );
}
catch ( IllegalStateException e )
{
@@ -135,6 +129,7 @@ public class NetExecutableFactoryImpl
}
getLogger().info( "NPANDAY-066-013: Found Vendor = " + vendorInfo );
+
compilerRequirement.setVendor( vendorInfo.getVendor() );
compilerRequirement.setVendorVersion( vendorInfo.getVendorVersion() );
compilerRequirement.setFrameworkVersion( vendorInfo.getFrameworkVersion() );
@@ -187,17 +182,17 @@ public class NetExecutableFactoryImpl
}
/**
- * @see NetExecutableFactory#getPluginLoaderFor(String, String, npanday.vendor.VendorInfo, String, java.io.File, String)
+ * @see NetExecutableFactory#getPluginLoaderFor(String, String, npanday.vendor.VendorRequirement, String, java.io.File, String)
*/
- public NetExecutable getPluginLoaderFor( String groupId, String artifactId, VendorInfo vendorInfo,
+ public NetExecutable getPluginLoaderFor( String groupId, String artifactId, VendorRequirement vendorRequirement,
String localRepository, File parameterFile, String mojoName )
throws PlatformUnsupportedException
{
Artifact artifact = getArtifactFor( groupId, artifactId );
- return getPluginLoaderFor( artifact, vendorInfo, localRepository, parameterFile, mojoName );
+ return getPluginLoaderFor( artifact, vendorRequirement, localRepository, parameterFile, mojoName );
}
- public NetExecutable getPluginLoaderFor( Artifact artifact, VendorInfo vendorInfo, String localRepository,
+ public NetExecutable getPluginLoaderFor( Artifact artifact, VendorRequirement vendorRequirement, String localRepository,
File parameterFile, String mojoName )
throws PlatformUnsupportedException
{
@@ -215,7 +210,7 @@ public class NetExecutableFactoryImpl
artifactPath = PathUtil.getPrivateApplicationBaseFileFor( pluginLoaderArtifact, new File( localRepository ) );
commands.add( "startProcessAssembly=" + artifactPath.getAbsolutePath() );
- return getNetExecutableFromRepository( "org.apache.npanday.plugins", "NPanday.Plugin.Runner", vendorInfo,
+ return getNetExecutableFromRepository( "org.apache.npanday.plugins", "NPanday.Plugin.Runner", vendorRequirement,
new File( localRepository ), commands, false );
}
@@ -239,9 +234,9 @@ public class NetExecutableFactoryImpl
return artifact;
}
- public NetExecutable getNetExecutableFromRepository( String groupId, String artifactId, VendorInfo vendorInfo,
- File localRepository, List<String> commands,
- boolean isIsolatedAppDomain )
+ public NetExecutable getNetExecutableFromRepository( String groupId, String artifactId,
+ VendorRequirement vendorRequirement, File localRepository,
+ List<String> commands, boolean isIsolatedAppDomain )
throws PlatformUnsupportedException
{
if ( isIsolatedAppDomain )
@@ -270,8 +265,8 @@ public class NetExecutableFactoryImpl
localRepository ).getAbsolutePath();
commands.add( "pluginArtifactPath=" + pluginArtifactPath );
- return getNetExecutableFromRepository( "org.apache.npanday.plugins", "NPanday.Plugin.Runner", vendorInfo,
- localRepository, commands, false );
+ return getNetExecutableFromRepository( "org.apache.npanday.plugins", "NPanday.Plugin.Runner",
+ vendorRequirement, localRepository, commands, false );
}
if ( commands == null )
@@ -279,13 +274,15 @@ public class NetExecutableFactoryImpl
commands = new ArrayList<String>();
}
+ VendorInfo vendorInfo;
try
{
- processor.process( vendorInfo );
+ vendorInfo = processor.process( vendorRequirement );
}
catch ( IllegalStateException e )
{
- throw new PlatformUnsupportedException( "NPANDAY-066-010: Illegal State: Vendor Info = " + vendorInfo, e );
+ throw new PlatformUnsupportedException(
+ "NPANDAY-066-010: Illegal State: Vendor Info = " + vendorRequirement, e );
}
if ( vendorInfo.getVendor() == null || vendorInfo.getFrameworkVersion() == null )
@@ -366,7 +363,7 @@ public class NetExecutableFactoryImpl
}
}
- public NetExecutable getJavaExecutableFromRepository( VendorInfo vendorInfo, List<String> commands )
+ public NetExecutable getJavaExecutableFromRepository( VendorRequirement vendorRequirement, List<String> commands )
throws PlatformUnsupportedException
{
@@ -375,19 +372,15 @@ public class NetExecutableFactoryImpl
commands = new ArrayList<String>();
}
+ VendorInfo vendorInfo;
try
{
- processor.process( vendorInfo );
+ vendorInfo = processor.process( vendorRequirement );
}
catch ( IllegalStateException e )
{
- throw new PlatformUnsupportedException( "NPANDAY-066-010: Illegal State: Vendor Info = " + vendorInfo, e );
- }
-
- if ( vendorInfo.getVendor() == null || vendorInfo.getFrameworkVersion() == null
- || vendorInfo.getVendorVersion() == null )
- {
- throw new PlatformUnsupportedException( "NPANDAY-066-018: Missing Vendor Information: " + vendorInfo );
+ throw new PlatformUnsupportedException(
+ "NPANDAY-066-010: Illegal State: Vendor Info = " + vendorRequirement, e );
}
ExecutableRequirement executableRequirement =
@@ -420,27 +413,17 @@ public class NetExecutableFactoryImpl
List<String> commands, File netHome )
throws PlatformUnsupportedException
{
+ //TODO: why is the vendorVersion not of interest here?
+ final VendorRequirement vendorRequirement = new VendorRequirement( vendor, null, frameworkVersion );
- VendorInfo vendorInfo = VendorInfo.Factory.createDefaultVendorInfo();
- vendorInfo.setVendorVersion( "" );
- vendorInfo.setFrameworkVersion( frameworkVersion );
- if ( vendor != null )
- {
- vendorInfo.setVendor( VendorFactory.createVendorFromName( vendor ) );
- }
-
+ VendorInfo vendorInfo;
try
{
- processor.process( vendorInfo );
+ vendorInfo = processor.process( vendorRequirement );
}
catch ( IllegalStateException e )
{
- throw new PlatformUnsupportedException( "NPANDAY-066-010: Illegal State: Vendor Info = " + vendorInfo, e );
- }
-
- if ( vendorInfo.getVendor() == null || vendorInfo.getFrameworkVersion() == null )
- {
- throw new PlatformUnsupportedException( "NPANDAY-066-019: Missing Vendor Information: " + vendorInfo );
+ throw new PlatformUnsupportedException( "NPANDAY-066-010: Illegal State: Vendor Info = " + vendorRequirement, e );
}
getLogger().debug( "NPANDAY-066-003: Found Vendor: " + vendorInfo );
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-plugin/src/main/java/npanday/plugin/AbstractMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-plugin/src/main/java/npanday/plugin/AbstractMojo.java?rev=1211347&r1=1211346&r2=1211347&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-plugin/src/main/java/npanday/plugin/AbstractMojo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-plugin/src/main/java/npanday/plugin/AbstractMojo.java Wed Dec 7 09:18:45 2011
@@ -18,23 +18,22 @@
*/
package npanday.plugin;
+import npanday.PathUtil;
+import npanday.PlatformUnsupportedException;
+import npanday.artifact.ArtifactContext;
+import npanday.artifact.AssemblyResolver;
import npanday.artifact.NPandayArtifactResolutionException;
-import npanday.dao.ProjectDao;
import npanday.dao.Project;
+import npanday.dao.ProjectDao;
import npanday.dao.ProjectDaoException;
-import npanday.dao.ProjectFactory;
import npanday.dao.ProjectDependency;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import npanday.PlatformUnsupportedException;
-import npanday.PathUtil;
-import npanday.artifact.ArtifactContext;
-import npanday.artifact.AssemblyResolver;
+import npanday.dao.ProjectFactory;
import npanday.executable.ExecutionException;
import npanday.executable.NetExecutableFactory;
import npanday.registry.DataAccessObjectRegistry;
-import npanday.vendor.VendorFactory;
-import npanday.vendor.VendorInfo;
+import npanday.vendor.VendorRequirement;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
@@ -62,7 +61,11 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Field;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
/**
* The base class for plugins that execute a .NET plugin. Classes that extend this class are only expected to provide
@@ -110,7 +113,7 @@ public abstract class AbstractMojo
}
catch ( ParserConfigurationException e )
{
- throw new MojoExecutionException( "NPANDAY-xxx-000", e );
+ throw new MojoExecutionException( "NPANDAY-115-000", e );
}
Document document = builder.newDocument();
@@ -123,7 +126,7 @@ public abstract class AbstractMojo
}
catch ( IOException e )
{
- throw new MojoExecutionException( "NPANDAY-xxx-000", e );
+ throw new MojoExecutionException( "NPANDAY-115-001", e );
}
StreamResult result = new StreamResult();
@@ -135,12 +138,12 @@ public abstract class AbstractMojo
}
catch ( TransformerConfigurationException e )
{
- throw new MojoExecutionException( "NPANDAY-xxx-000", e );
+ throw new MojoExecutionException( "NPANDAY-115-002", e );
}
catch ( TransformerException e )
{
- throw new MojoExecutionException( "NPANDAY-xxx-000", e );
+ throw new MojoExecutionException( "NPANDAY-115-003", e );
}
finally
{
@@ -150,33 +153,27 @@ public abstract class AbstractMojo
}
catch ( IOException e )
{
- throw new MojoExecutionException( "NPANDAY-xxx-000: Unable to write file", e );
+ throw new MojoExecutionException( "NPANDAY-115-004: Unable to write file", e );
}
}
try
{
- VendorInfo vendorInfo = VendorInfo.Factory.createDefaultVendorInfo();
- if ( getVendor() != null )
- {
- vendorInfo.setVendor( VendorFactory.createVendorFromName( getVendor() ) );
- }
- vendorInfo.setFrameworkVersion( getFrameworkVersion() );
- vendorInfo.setVendorVersion( getVendorVersion() );
+ VendorRequirement vendorRequirement = new VendorRequirement( getVendor(), getVendorVersion(), getFrameworkVersion());
Artifact artifact = getNetExecutableFactory().getArtifactFor(getMojoGroupId(), getMojoArtifactId());
resolveArtifact(artifact);
- getNetExecutableFactory().getPluginLoaderFor( artifact, vendorInfo,
+ getNetExecutableFactory().getPluginLoaderFor( artifact, vendorRequirement,
getLocalRepository(), paramFile,
getClassName() ).execute();
}
catch ( PlatformUnsupportedException e )
{
- throw new MojoExecutionException( "NPANDAY-xxx-000", e );
+ throw new MojoExecutionException( "NPANDAY-115-005", e );
}
catch ( ExecutionException e )
{
- throw new MojoExecutionException( "NPANDAY-xxx-000", e );
+ throw new MojoExecutionException( "NPANDAY-115-006", e );
} catch (ComponentLookupException e) {
throw new MojoExecutionException( "NPANDAY-xxx-000", e );
}
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-plugin/src/main/java/npanday/plugin/impl/ConfigurationAppendersRepository.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-plugin/src/main/java/npanday/plugin/impl/ConfigurationAppendersRepository.java?rev=1211347&r1=1211346&r2=1211347&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-plugin/src/main/java/npanday/plugin/impl/ConfigurationAppendersRepository.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-plugin/src/main/java/npanday/plugin/impl/ConfigurationAppendersRepository.java Wed Dec 7 09:18:45 2011
@@ -36,6 +36,7 @@ import java.util.Set;
/**
* @author Shane Isbell
* @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
+ *
* @plexus.component
* role="npanday.plugin.impl.ConfigurationAppendersRepository"
*/
@@ -68,7 +69,7 @@ public class ConfigurationAppendersRepos
}
catch ( ClassNotFoundException e )
{
- throw new NPandayRepositoryException("NPANDAY-xxx-000: Could not load class appender: Name = " + appender.getName(), e );
+ throw new NPandayRepositoryException("NPANDAY-115-000: Could not load class appender: Name = " + appender.getName(), e );
}
}
}
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/RepositoryRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/RepositoryRegistryImpl.java?rev=1211347&r1=1211346&r2=1211347&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/RepositoryRegistryImpl.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/RepositoryRegistryImpl.java Wed Dec 7 09:18:45 2011
@@ -60,15 +60,6 @@ public class RepositoryRegistryImpl
public RepositoryRegistryImpl(){
instance = instanceCounter++;
-
- try{
- throw new RuntimeException("Stacktrace");
- }
- catch(RuntimeException ex)
- {
- System.out.println("NPANDAY-082-010: Instantiating RepositoryRegistry #" + instance);
- ex.printStackTrace();
- }
}
/**
@@ -77,14 +68,7 @@ public class RepositoryRegistryImpl
public void initialize()
throws InitializationException
{
-
- try{
- throw new RuntimeException("Stacktrace");
- }
- catch(RuntimeException ex)
- {
- getLogger().debug( "NPANDAY-082-011: Initializing RepositoryRegistry #" + instance, ex );
- }
+ getLogger().debug( "NPANDAY-082-011: Initializing RepositoryRegistry #" + instance );
try
{
Added: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsRepository.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsRepository.java?rev=1211347&view=auto
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsRepository.java (added)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsRepository.java Wed Dec 7 09:18:45 2011
@@ -0,0 +1,20 @@
+package npanday.vendor;
+
+import npanday.model.settings.DefaultSetup;
+import npanday.model.settings.Vendor;
+import npanday.registry.Repository;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
+ */
+public interface SettingsRepository
+ extends Repository
+{
+ List<Vendor> getVendors();
+ DefaultSetup getDefaultSetup();
+ boolean isEmpty();
+
+ int getContentVersion();
+}
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsUtil.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsUtil.java?rev=1211347&r1=1211346&r2=1211347&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsUtil.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsUtil.java Wed Dec 7 09:18:45 2011
@@ -22,7 +22,7 @@ package npanday.vendor;
import npanday.PathUtil;
import npanday.registry.NPandayRepositoryException;
import npanday.registry.RepositoryRegistry;
-import npanday.vendor.impl.SettingsRepository;
+import npanday.vendor.SettingsRepository;
import org.codehaus.plexus.util.StringUtils;
import javax.naming.OperationNotSupportedException;
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/StateMachineProcessor.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/StateMachineProcessor.java?rev=1211347&r1=1211346&r2=1211347&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/StateMachineProcessor.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/StateMachineProcessor.java Wed Dec 7 09:18:45 2011
@@ -18,6 +18,8 @@
*/
package npanday.vendor;
+import npanday.PlatformUnsupportedException;
+
/**
* Provides services for filling in missing vendor info according to its state of completion. An implementation of this
* class can use various <code>VendorInfoTransitionRule</code> instances to transition states during processing.
@@ -36,10 +38,10 @@ public interface StateMachineProcessor
/**
* Processes the specified vendor info by filling in missing information.
*
- * @param vendorInfo the vendor info to fill in
- * @throws IllegalStateException if the state of the specified vendor info is illegal or cannot be determined
+ *
+ * @param vendorRequirement@throws IllegalStateException if the state of the specified vendor info is illegal or cannot be determined
*/
- void process( VendorInfo vendorInfo )
- throws IllegalStateException;
+ VendorInfo process( VendorRequirement vendorRequirement )
+ throws IllegalStateException, PlatformUnsupportedException;
}
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/Vendor.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/Vendor.java?rev=1211347&r1=1211346&r2=1211347&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/Vendor.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/Vendor.java Wed Dec 7 09:18:45 2011
@@ -32,10 +32,7 @@ public enum Vendor
MONO( "MONO" ),
/**DotGNU Vendor*/
- DOTGNU( "DotGNU" ),
-
- /**NULL Vendor*/
- NULL("NULL");
+ DOTGNU( "DotGNU" );
/**
* The vendor name
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorFactory.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorFactory.java?rev=1211347&r1=1211346&r2=1211347&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorFactory.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorFactory.java Wed Dec 7 09:18:45 2011
@@ -55,11 +55,11 @@ public final class VendorFactory
*
* @param vendorName the name of a vendor
* @return a vendor instance for the given vendor name: MICROSOFT, DotGNU, MONO
- * @throws VendorUnsupportedException if the vendor is not known
+ * @throws VendorUnknownException if the vendor is not known
* @throws NullPointerException if the vendor name parameter is null
*/
public static synchronized Vendor createVendorFromName( String vendorName )
- throws VendorUnsupportedException
+ throws VendorUnknownException
{
if ( vendorName.toLowerCase().trim().equals( "microsoft" ) )
{
@@ -75,7 +75,7 @@ public final class VendorFactory
}
else
{
- throw new VendorUnsupportedException( "NPANDAY-100-000: Unknown vendor: Name = " + vendorName );
+ throw new VendorUnknownException( "NPANDAY-100-000: Unknown vendor: Name = " + vendorName );
}
}
}
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfo.java?rev=1211347&r1=1211346&r2=1211347&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfo.java Wed Dec 7 09:18:45 2011
@@ -18,6 +18,8 @@
*/
package npanday.vendor;
+import npanday.vendor.impl.MutableVendorInfo;
+
import java.io.File;
import java.util.List;
@@ -28,62 +30,37 @@ import java.util.List;
*/
public interface VendorInfo
{
-
/**
- * Returns vendor
- *
- * @return vendor
+ * Returns the vendor, for example {@link Vendor#MONO} or {@link Vendor#MICROSOFT}
*/
Vendor getVendor();
/**
- * @param vendor
- */
- void setVendor( Vendor vendor );
-
- /**
- * Returns vendor version.
+ * Returns vendor version, in order to define or determine which tools to use
+ * exactly. This is corresponding to 'tools version' in MSBuild or the CSharp compiler.
*
- * @return vendor version
+ * Note that you could use a newer vendor to target an older framework version.
*/
String getVendorVersion();
/**
- * Sets vendor version
- *
- * @param vendorVersion the vendor version
- */
- void setVendorVersion( String vendorVersion );
-
- /**
- * Returns framework version of the executable
+ * Returns the framework version, which actually is the version of the .NET framework
+ * to compile against. This will also be the default CLR version, the compiled results
+ * would run on by default.
*
* @return the framework version of the executable
*/
String getFrameworkVersion();
/**
- * Sets the framework version of the executable
- *
- * @param frameworkVersion
- */
- void setFrameworkVersion( String frameworkVersion );
-
- /**
- * Returns the path where the executable lives.
+ * Returns all paths where executable for the specified vendor and version are located. Given a particular
+ * exectuable, NPanday will scan the paths and find the first matching one.
*
* @return the path where the executable lives
*/
List<File> getExecutablePaths();
/**
- * Sets the path where the executable lives.
- *
- * @param executablePaths the path where the executable lives
- */
- void setExecutablePaths( List<File> executablePaths );
-
- /**
* If the vendor information is the default (or preferred) value for a given vendor, returns true,
* otherwise returns false. This allows the vendor matching framework to choose a specific version of the
* compiler vendor (such as MONO 1.1.13.8 vs 1.1.18) if such a version is not specified within the pom.
@@ -93,12 +70,9 @@ public interface VendorInfo
*/
boolean isDefault();
- /**
- * Set to true if the vendor information is the default, otherwise set to false.
- *
- * @param isDefault
- */
- void setDefault( boolean isDefault );
+ File getSdkInstallRoot();
+
+ File getInstallRoot();
/**
* Provides factory services for creating a default instance of vendor info.
@@ -106,89 +80,14 @@ public interface VendorInfo
public static class Factory
{
/**
- * Default constructor
- */
- private Factory()
- {
- }
-
- /**
- * Creates a default implementation of vendor info.
+ * Creates a mutable implementation of vendor info.
*
* @return a default implementation of vendor info
*/
- public static VendorInfo createDefaultVendorInfo()
+ public static MutableVendorInfo createDefaultVendorInfo()
{
- return new VendorInfo()
- {
- private Vendor vendor;
-
- private String vendorVersion;
-
- private String frameworkVersion;
-
- private List<File> executablePaths;
-
- private boolean isDefault;
-
- public boolean isDefault()
- {
- return isDefault;
- }
-
- public void setDefault( boolean aDefault )
- {
- isDefault = aDefault;
- }
-
- public List<File> getExecutablePaths()
- {
- return executablePaths;
- }
-
- public void setExecutablePaths( List<File> executablePaths )
- {
- this.executablePaths = executablePaths;
- }
-
- public Vendor getVendor()
- {
- return vendor;
- }
-
- public void setVendor( Vendor vendor )
- {
- this.vendor = vendor;
- }
-
- public String getVendorVersion()
- {
- return vendorVersion;
- }
-
- public void setVendorVersion( String vendorVersion )
- {
- this.vendorVersion = vendorVersion;
- }
-
- public String getFrameworkVersion()
- {
- return frameworkVersion;
- }
-
- public void setFrameworkVersion( String frameworkVersion )
- {
- this.frameworkVersion = frameworkVersion;
- }
-
- public String toString()
- {
- return "Vendor = " + vendor + ", Vendor Version = " + vendorVersion + ", Framework Version = " +
- frameworkVersion + ", Executable Paths = " +
- ( ( executablePaths != null ) ? executablePaths : "" );
- }
- };
+ return new MutableVendorInfo();
}
}
-
}
+
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoRepository.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoRepository.java?rev=1211347&r1=1211346&r2=1211347&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoRepository.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoRepository.java Wed Dec 7 09:18:45 2011
@@ -57,12 +57,12 @@ public interface VendorInfoRepository
* <code>getVendorInfosFor(String, String, String, boolean)</code>. This method allows the use
* of a vendor info parameter directly.
*
- * @param vendorInfo the vendor info to match. This value may be incomplete, in which case, this method will return
- * all possible vendor infos that could match.
+ *
+ * @param vendorRequirement
* @param isDefault if true, this method will filter out vendor info entries that do not have a default field
* @return a list of vendor infos for the specified vendorInfo
*/
- List<VendorInfo> getVendorInfosFor( VendorInfo vendorInfo, boolean isDefault );
+ List<VendorInfo> getVendorInfosFor( VendorRequirement vendorRequirement, boolean isDefault );
/**
* Returns the maximum version of the given set of versions.
@@ -78,21 +78,14 @@ public interface VendorInfoRepository
* Finds a configured matching vendor info. This will then include details about
* if it is the default, and on which paths executables are found.
*
- * @param vendorInfoExample Source for the search criteria.
- * @return VendorInfo as it is configured.
+ *
+ * @param vendorRequirement@return VendorInfo as it is configured.
* @throws PlatformUnsupportedException
*/
- VendorInfo getConfiguredVendorInfoByExample(VendorInfo vendorInfoExample)
+ VendorInfo getSingleVendorInfoByRequirement( VendorRequirement vendorRequirement )
throws PlatformUnsupportedException;
/**
- * Returns true if this repository exists (and can be used), otherwise returns false.
- *
- * @return true if this repository exists (and can be used), otherwise returns false
- */
- boolean exists();
-
- /**
*
*
* @param vendor
@@ -104,4 +97,9 @@ public interface VendorInfoRepository
File getGlobalAssemblyCacheDirectoryFor( Vendor vendor, String frameworkVersion, String artifactType )
throws PlatformUnsupportedException;
+ /**
+ * Determines, if the repository is empty. This happens, if the configuration couldn't be read, because no file was
+ * available, or when the underlying SettingsRepository wasn't initialized properly.
+ */
+ boolean isEmpty();
}
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoTransitionRule.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoTransitionRule.java?rev=1211347&r1=1211346&r2=1211347&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoTransitionRule.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoTransitionRule.java Wed Dec 7 09:18:45 2011
@@ -19,7 +19,7 @@
package npanday.vendor;
/**
- * Provides a service for filling in (or processing) vendor information and transitioning its state. The
+ * Provides a service for filling in (or processing) vendor information requirements and transitioning its state. The
* <code>StateMachineProcessor</code> is responsible for processing each transition rule within the framework.
*
* @author Shane Isbell
@@ -31,8 +31,8 @@ public interface VendorInfoTransitionRul
/**
* Fills in some or all of the specified vendor info object and returns the new state.
*
- * @param vendorInfo the vendor info to fill in
+ * @param vendorRequirement the vendor info to fill in
* @return the new state of the vendor info parameter
*/
- VendorInfoState process( VendorInfo vendorInfo );
+ VendorRequirementState process( VendorRequirement vendorRequirement );
}
Added: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorRequirement.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorRequirement.java?rev=1211347&view=auto
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorRequirement.java (added)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorRequirement.java Wed Dec 7 09:18:45 2011
@@ -0,0 +1,117 @@
+package npanday.vendor;
+
+import java.io.Serializable;
+
+import static com.google.common.base.Strings.isNullOrEmpty;
+
+/**
+ * Specifies the requirements for a vendor to be used.
+ *
+ * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
+ */
+public class VendorRequirement
+{
+ Vendor vendor;
+
+ String vendorVersion;
+
+ String frameworkVersion;
+
+ public VendorRequirement( String vendorName, String vendorVersion, String frameworkVersion )
+ {
+ if (!isNullOrEmpty(vendorName))
+ {
+ setVendor( VendorFactory.createVendorFromName( vendorName ) );
+ }
+ setVendorVersion( vendorVersion );
+ setFrameworkVersion( frameworkVersion );
+ }
+
+ public VendorRequirement( Vendor vendor, String vendorVersion, String frameworkVersion )
+ {
+ setVendor( vendor );
+ setVendorVersion( vendorVersion );
+ setFrameworkVersion( frameworkVersion );
+ }
+
+ /**
+ * @see npanday.vendor.VendorInfo#getVendor()
+ */
+ public Vendor getVendor()
+ {
+ return vendor;
+ }
+
+ /**
+ * @see npanday.vendor.VendorInfo#getVendor()
+ */
+ public void setVendor( Vendor vendor )
+ {
+ this.vendor = vendor;
+ }
+
+ /**
+ * @see npanday.vendor.VendorInfo#getVendorVersion()
+ */
+ public String getVendorVersion()
+ {
+ return vendorVersion;
+ }
+
+ /**
+ * @see npanday.vendor.VendorInfo#getVendorVersion()
+ */
+ public void setVendorVersion( String vendorVersion )
+ {
+ if ( "".equals( vendorVersion ) )
+ {
+ throw new IllegalArgumentException(
+ "Given frameworkVersion must be a value or null; empty is not allowed." );
+ }
+
+ this.vendorVersion = vendorVersion;
+ }
+
+ /**
+ * @see npanday.vendor.VendorInfo#getFrameworkVersion()
+ */
+ public String getFrameworkVersion()
+ {
+ return frameworkVersion;
+ }
+
+ /**
+ * @see npanday.vendor.VendorInfo#getFrameworkVersion()
+ */
+ public void setFrameworkVersion( String frameworkVersion )
+ {
+ if ( "".equals( frameworkVersion ) )
+ {
+ throw new IllegalArgumentException(
+ "Given frameworkVersion must be a value or null; empty is not allowed." );
+ }
+
+ this.frameworkVersion = frameworkVersion;
+ }
+
+ /**
+ * Determines, if the requirement is completed, hence, if vendor,
+ * vendorVersion and frameworkVersion is filled in.
+ */
+ public boolean isComplete()
+ {
+ return vendor != null && vendorVersion != null && frameworkVersion != null;
+ }
+
+ public String toString()
+ {
+ return "[Vendor Requirement for vendor " + visibleNullString( vendor ) + " version "
+ + visibleNullString(getVendorVersion()) + ", Framework Version = "
+ + visibleNullString(getFrameworkVersion()) + "]";
+ }
+
+ private Serializable visibleNullString( Object obj )
+ {
+ return ( obj == null ? "NULL" : obj.toString() );
+ }
+}
Copied: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorRequirementState.java (from r1207095, incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoState.java)
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorRequirementState.java?p2=incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorRequirementState.java&p1=incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoState.java&r1=1207095&r2=1211347&rev=1211347&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoState.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorRequirementState.java Wed Dec 7 09:18:45 2011
@@ -23,7 +23,7 @@ package npanday.vendor;
*
* @author Shane Isbell
*/
-public enum VendorInfoState
+public enum VendorRequirementState
{
/**
* State of VendorInfo object: Vendor is Microsoft, vendor version exists, framework version exists
@@ -118,41 +118,26 @@ public enum VendorInfoState
/**
* Null state of VendorInfo object
*/
- NULL,
-
- /**
- * Post processing state
- */
- POST_PROCESS;
+ NULL;
/**
* Returns the completion state of the specified vendor info
*
- * @param vendorInfo the vendor info to determine the state of completion
+ * @param vendorRequirement the vendor info to determine the state of completion
* @return the state of the specified vendor info
*/
- public VendorInfoState getState( VendorInfo vendorInfo )
+ public VendorRequirementState getState( VendorRequirement vendorRequirement )
{
- if ( vendorInfo == null )
+ if ( vendorRequirement == null )
{
return NULL;
}
- if ( vendorInfo.getVendorVersion() != null && vendorInfo.getVendorVersion().trim().equals( "" ) )
- {
- vendorInfo.setVendorVersion( null );
- }
-
- if ( vendorInfo.getFrameworkVersion() != null && vendorInfo.getFrameworkVersion().trim().equals( "" ) )
- {
- vendorInfo.setFrameworkVersion( null );
- }
-
- if ( vendorInfo.getVendor() == null )
+ if ( vendorRequirement.getVendor() == null )
{
- if ( vendorInfo.getVendorVersion() == null )
+ if ( vendorRequirement.getVendorVersion() == null )
{
- if ( vendorInfo.getFrameworkVersion() == null )
+ if ( vendorRequirement.getFrameworkVersion() == null )
{
return FFF;
}
@@ -163,7 +148,7 @@ public enum VendorInfoState
}
else
{
- if ( vendorInfo.getFrameworkVersion() == null )
+ if ( vendorRequirement.getFrameworkVersion() == null )
{
return FTF;
}
@@ -173,11 +158,11 @@ public enum VendorInfoState
}
}
}
- else if ( vendorInfo.getVendor().equals( Vendor.MICROSOFT ) )
+ else if ( vendorRequirement.getVendor().equals( Vendor.MICROSOFT ) )
{
- if ( vendorInfo.getVendorVersion() == null )
+ if ( vendorRequirement.getVendorVersion() == null )
{
- if ( vendorInfo.getFrameworkVersion() == null )
+ if ( vendorRequirement.getFrameworkVersion() == null )
{
return MFF;
}
@@ -188,7 +173,7 @@ public enum VendorInfoState
}
else
{
- if ( vendorInfo.getFrameworkVersion() == null )
+ if ( vendorRequirement.getFrameworkVersion() == null )
{
return MTF;
}
@@ -198,11 +183,11 @@ public enum VendorInfoState
}
}
}
- else if ( vendorInfo.getVendor().equals( Vendor.MONO ) )
+ else if ( vendorRequirement.getVendor().equals( Vendor.MONO ) )
{
- if ( vendorInfo.getVendorVersion() == null )
+ if ( vendorRequirement.getVendorVersion() == null )
{
- if ( vendorInfo.getFrameworkVersion() == null )
+ if ( vendorRequirement.getFrameworkVersion() == null )
{
return NFF;
}
@@ -213,7 +198,7 @@ public enum VendorInfoState
}
else
{
- if ( vendorInfo.getFrameworkVersion() == null )
+ if ( vendorRequirement.getFrameworkVersion() == null )
{
return NTF;
}
@@ -223,11 +208,11 @@ public enum VendorInfoState
}
}
}
- else if ( vendorInfo.getVendor().equals( Vendor.DOTGNU ) )
+ else if ( vendorRequirement.getVendor().equals( Vendor.DOTGNU ) )
{
- if ( vendorInfo.getVendorVersion() == null )
+ if ( vendorRequirement.getVendorVersion() == null )
{
- if ( vendorInfo.getFrameworkVersion() == null )
+ if ( vendorRequirement.getFrameworkVersion() == null )
{
return GFF;
}
@@ -238,7 +223,7 @@ public enum VendorInfoState
}
else
{
- if ( vendorInfo.getFrameworkVersion() == null )
+ if ( vendorRequirement.getFrameworkVersion() == null )
{
return GTF;
}
Propchange: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorRequirementState.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorUnknownException.java (from r1207095, incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorUnsupportedException.java)
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorUnknownException.java?p2=incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorUnknownException.java&p1=incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorUnsupportedException.java&r1=1207095&r2=1211347&rev=1211347&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorUnsupportedException.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorUnknownException.java Wed Dec 7 09:18:45 2011
@@ -18,54 +18,52 @@
*/
package npanday.vendor;
-import npanday.PlatformUnsupportedException;
-
/**
- * Exception thrown when the vendor is not recognized or is not valid for a specific platform or language.
+ * Exception thrown when the vendor is not recognized.
*
* @author Shane Isbell
*/
-public class VendorUnsupportedException
- extends PlatformUnsupportedException
+public class VendorUnknownException
+ extends RuntimeException
{
static final long serialVersionUID = -72946723034227L;
/**
- * Constructs an <code>VendorUnsupportedException</code> with no exception message.
+ * Constructs an <code>VendorUnknownException</code> with no exception message.
*/
- public VendorUnsupportedException()
+ public VendorUnknownException()
{
super();
}
/**
- * Constructs an <code>VendorUnsupportedException</code> with the specified exception message.
+ * Constructs an <code>VendorUnknownException</code> with the specified exception message.
*
* @param message the exception message
*/
- public VendorUnsupportedException( String message )
+ public VendorUnknownException( String message )
{
super( message );
}
/**
- * Constructs an <code>VendorUnsupportedException</code> with the specified exception message and cause of the exception.
+ * Constructs an <code>VendorUnknownException</code> with the specified exception message and cause of the exception.
*
* @param message the exception message
* @param cause the cause of the exception
*/
- public VendorUnsupportedException( String message, Throwable cause )
+ public VendorUnknownException( String message, Throwable cause )
{
super( message, cause );
}
/**
- * Constructs an <code>VendorUnsupportedException</code> with the cause of the exception.
+ * Constructs an <code>VendorUnknownException</code> with the cause of the exception.
*
* @param cause the cause of the exception
*/
- public VendorUnsupportedException( Throwable cause )
+ public VendorUnknownException( Throwable cause )
{
super( cause );
}
Propchange: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorUnknownException.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/FileBasedSettingsRepository.java (from r1210570, incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsRepository.java)
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/FileBasedSettingsRepository.java?p2=incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/FileBasedSettingsRepository.java&p1=incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsRepository.java&r1=1210570&r2=1211347&rev=1211347&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsRepository.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/FileBasedSettingsRepository.java Wed Dec 7 09:18:45 2011
@@ -1,231 +1,209 @@
-/*
- * 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.impl;
-
-import npanday.PlatformUnsupportedException;
-import npanday.model.settings.DefaultSetup;
-import npanday.model.settings.Framework;
-import npanday.model.settings.NPandaySettings;
-import npanday.model.settings.Vendor;
-import npanday.model.settings.io.xpp3.NPandaySettingsXpp3Reader;
-import npanday.registry.NPandayRepositoryException;
-import npanday.registry.Repository;
-import npanday.registry.impl.AbstractMultisourceRepository;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Hashtable;
-import java.util.List;
-
-/**
- * Provides methods for loading and reading the npanday-settings config file.
- *
- * @author Shane Isbell
- * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
- * @plexus.component
- * role="npanday.vendor.impl.SettingsRepository"
- */
-public final class SettingsRepository
- extends AbstractMultisourceRepository<NPandaySettings>
- implements Repository
-{
- /**
- * List of all vendors from the various sources. The <code>Vendor</code> is the raw model type.
- */
- private List<Vendor> vendors = new ArrayList<Vendor>();
-
- /**
- * The default setup: framework version, vendor, vendor version. If no information is provided by the user, then
- * this information will be used to choose the environment. It may also be used for partial matches, if appropriate.
- */
- private DefaultSetup defaultSetup;
-
- /**
- * Constructor. This method is intended to be invoked by the <code>RepositoryRegistry<code>, not by the
- * application developer.
- */
- public SettingsRepository()
- {
- }
-
- @Override
- protected NPandaySettings loadFromReader( Reader reader, Hashtable properties )
- throws IOException, XmlPullParserException
- {
- NPandaySettingsXpp3Reader xpp3Reader = new NPandaySettingsXpp3Reader();
- return xpp3Reader.read( reader );
- }
-
- @Override
- protected void mergeLoadedModel( NPandaySettings settings )
- throws NPandayRepositoryException
- {
- vendors.addAll( settings.getVendors() );
-
- final DefaultSetup currentDefaultSetup = settings.getDefaultSetup();
-
- if ( currentDefaultSetup != null && defaultSetup != null )
- {
- getLogger().warn(
- "NPANDAY-104-006: The default setup was already defined, got overridden by a subsequent source, was: "
- + defaultSetup + ", is now " + currentDefaultSetup );
- }
-
- defaultSetup = currentDefaultSetup;
- }
-
- @Override
- protected void clear()
- {
- vendors.clear();
- defaultSetup = null;
- }
-
- /**
- * Gets the raw configured model.
- *
- * @return Unmodifiable list.
- */
- public List<Vendor> getVendors()
- {
- return Collections.unmodifiableList( vendors );
- }
-
- File getSdkInstallRootFor( String vendor, String vendorVersion, String frameworkVersion )
- throws PlatformUnsupportedException
- {
- if ( vendor == null || vendorVersion == null || frameworkVersion == null )
- {
- throw new PlatformUnsupportedException(
- "NPANDAY-104-004: One of more of the parameters is null: Vendor = " + vendor + ", Vendor Version = "
- + vendorVersion + ", Framework Version = " + frameworkVersion );
- }
- for ( Vendor v : vendors )
- {
- if ( vendor.equals( v.getVendorName().trim() ) && vendorVersion.equals( v.getVendorVersion().trim() ) )
- {
- List<Framework> frameworks = v.getFrameworks();
- for ( Framework framework : frameworks )
- {
- if ( frameworkVersion.equals( framework.getFrameworkVersion().trim() ) )
- {
- String sdkRoot = framework.getSdkInstallRoot();
- if ( sdkRoot != null )
- {
- return new File( sdkRoot );
- }
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Returns the install root for the .NET framework for the specified parameters. None of the parameter values
- * should be null.
- *
- * @param vendor the vendor name
- * @param vendorVersion the vendor version
- * @param frameworkVersion the .NET framework version
- * @return the install root for the .NET framework
- * @throws npanday.PlatformUnsupportedException
- * if there is no install root found for the specified parameters
- */
- public File getInstallRootFor( String vendor, String vendorVersion, String frameworkVersion )
- throws PlatformUnsupportedException
- {
- if ( vendor == null || vendorVersion == null || frameworkVersion == null )
- {
- throw new PlatformUnsupportedException(
- "NPANDAY-104-001: One of more of the parameters is null: Vendor = " + vendor + ", Vendor Version = "
- + vendorVersion + ", Framework Version = " + frameworkVersion );
- }
- for ( Vendor v : vendors )
- {
- if ( vendor.equals( v.getVendorName().trim() ) && vendorVersion.equals( v.getVendorVersion().trim() ) )
- {
- List<Framework> frameworks = v.getFrameworks();
-
- for ( Framework framework : frameworks )
- {
- if ( frameworkVersion.equals( framework.getFrameworkVersion().trim() ) )
- {
- return new File( framework.getInstallRoot() );
- }
- }
- }
- }
- throw new PlatformUnsupportedException(
- "NPANDAY-104-002: Unable to find install root: Vendor = " + vendor + ", Vendor Version = " + vendorVersion
- + ", Framework Version = " + frameworkVersion );
- }
-
- List<File> getExecutablePathsFor( String vendor, String vendorVersion, String frameworkVersion )
- throws PlatformUnsupportedException
- {
- List<File> executablePaths = new ArrayList<File>();
- if ( vendor == null || vendorVersion == null || frameworkVersion == null )
- {
- throw new PlatformUnsupportedException(
- "NPANDAY-104-006: One of more of the parameters is null: Vendor = " + vendor + ", Vendor Version = "
- + vendorVersion + ", Framework Version = " + frameworkVersion );
- }
- for ( Vendor v : vendors )
- {
- if ( vendor.equals( v.getVendorName().trim() ) && vendorVersion.equals( v.getVendorVersion().trim() ) )
- {
- List<Framework> frameworks = v.getFrameworks();
- for ( Framework framework : frameworks )
- {
- if ( frameworkVersion.equals( framework.getFrameworkVersion().trim() ) )
- {
- List paths = framework.getExecutablePaths();
- for ( Object path : paths )
- {
- executablePaths.add( new File( (String) path ) );
- }
- }
- }
- }
- }
- return executablePaths;
- }
-
- /**
- * Returns the default setup: framework version, vendor, vendor version. If no information is provided by the user, then
- * this information will be used to choose the environment. It may also be used for partial matches, if appropriate.
- *
- * @return the default setup: framework version, vendor, vendor version
- */
- DefaultSetup getDefaultSetup()
- {
- return defaultSetup;
- }
-
- public boolean isEmpty()
- {
- return getVendors().size() == 0 && defaultSetup == null;
- }
-}
-
+/*
+ * 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.impl;
+
+import npanday.PlatformUnsupportedException;
+import npanday.model.settings.DefaultSetup;
+import npanday.model.settings.Framework;
+import npanday.model.settings.NPandaySettings;
+import npanday.model.settings.Vendor;
+import npanday.model.settings.io.xpp3.NPandaySettingsXpp3Reader;
+import npanday.registry.NPandayRepositoryException;
+import npanday.registry.impl.AbstractMultisourceRepository;
+import npanday.vendor.SettingsRepository;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.List;
+
+/**
+ * Provides methods for loading and reading the npanday-settings config file.
+ *
+ * @author Shane Isbell
+ * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
+ *
+ * @plexus.component
+ * role="npanday.vendor.SettingsRepository"
+ */
+public final class FileBasedSettingsRepository
+ extends AbstractMultisourceRepository<NPandaySettings>
+ implements SettingsRepository
+{
+ /**
+ * List of all vendors from the various sources. The <code>Vendor</code> is the raw model type.
+ */
+ private List<Vendor> vendors = new ArrayList<Vendor>();
+
+ /**
+ * The default setup: framework version, vendor, vendor version. If no information is provided by the user, then
+ * this information will be used to choose the environment. It may also be used for partial matches, if appropriate.
+ */
+ private DefaultSetup defaultSetup;
+
+ /**
+ * Constructor. This method is intended to be invoked by the <code>RepositoryRegistry<code>, not by the
+ * application developer.
+ */
+ public FileBasedSettingsRepository()
+ {
+ }
+
+ @Override
+ protected NPandaySettings loadFromReader( Reader reader, Hashtable properties )
+ throws IOException, XmlPullParserException
+ {
+ NPandaySettingsXpp3Reader xpp3Reader = new NPandaySettingsXpp3Reader();
+ return xpp3Reader.read( reader );
+ }
+
+ @Override
+ protected void mergeLoadedModel( NPandaySettings settings )
+ throws NPandayRepositoryException
+ {
+ vendors.addAll( settings.getVendors() );
+
+ final DefaultSetup currentDefaultSetup = settings.getDefaultSetup();
+
+ if ( currentDefaultSetup != null && defaultSetup != null )
+ {
+ getLogger().warn(
+ "NPANDAY-104-006: The default setup was already defined, got overridden by a subsequent source, was: "
+ + defaultSetup + ", is now " + currentDefaultSetup );
+ }
+
+ defaultSetup = currentDefaultSetup;
+ }
+
+ @Override
+ protected void clear()
+ {
+ vendors.clear();
+ defaultSetup = null;
+ }
+
+ /**
+ * Gets the raw configured model.
+ *
+ * @return Unmodifiable list.
+ */
+ public List<Vendor> getVendors()
+ {
+ return Collections.unmodifiableList( vendors );
+ }
+
+ /**
+ * Returns the install root for the .NET framework for the specified parameters. None of the parameter values
+ * should be null.
+ *
+ * @param vendor the vendor name
+ * @param vendorVersion the vendor version
+ * @param frameworkVersion the .NET framework version
+ * @return the install root for the .NET framework
+ * @throws npanday.PlatformUnsupportedException
+ * if there is no install root found for the specified parameters
+ */
+ public File getInstallRootFor( String vendor, String vendorVersion, String frameworkVersion )
+ throws PlatformUnsupportedException
+ {
+ if ( vendor == null || vendorVersion == null || frameworkVersion == null )
+ {
+ throw new PlatformUnsupportedException(
+ "NPANDAY-104-001: One of more of the parameters is null: Vendor = " + vendor + ", Vendor Version = "
+ + vendorVersion + ", Framework Version = " + frameworkVersion );
+ }
+ for ( Vendor v : vendors )
+ {
+ if ( vendor.equals( v.getVendorName().trim() ) && vendorVersion.equals( v.getVendorVersion().trim() ) )
+ {
+ List<Framework> frameworks = v.getFrameworks();
+
+ for ( Framework framework : frameworks )
+ {
+ if ( frameworkVersion.equals( framework.getFrameworkVersion().trim() ) )
+ {
+ return new File( framework.getInstallRoot() );
+ }
+ }
+ }
+ }
+ throw new PlatformUnsupportedException(
+ "NPANDAY-104-002: Unable to find install root: Vendor = " + vendor + ", Vendor Version = " + vendorVersion
+ + ", Framework Version = " + frameworkVersion );
+ }
+
+ List<File> getExecutablePathsFor( String vendor, String vendorVersion, String frameworkVersion )
+ throws PlatformUnsupportedException
+ {
+ List<File> executablePaths = new ArrayList<File>();
+ if ( vendor == null || vendorVersion == null || frameworkVersion == null )
+ {
+ throw new PlatformUnsupportedException(
+ "NPANDAY-104-006: One of more of the parameters is null: Vendor = " + vendor + ", Vendor Version = "
+ + vendorVersion + ", Framework Version = " + frameworkVersion );
+ }
+ for ( Vendor v : vendors )
+ {
+ if ( vendor.equals( v.getVendorName().trim() ) && vendorVersion.equals( v.getVendorVersion().trim() ) )
+ {
+ List<Framework> frameworks = v.getFrameworks();
+ for ( Framework framework : frameworks )
+ {
+ if ( frameworkVersion.equals( framework.getFrameworkVersion().trim() ) )
+ {
+ List paths = framework.getExecutablePaths();
+ for ( Object path : paths )
+ {
+ executablePaths.add( new File( (String) path ) );
+ }
+ }
+ }
+ }
+ }
+ return executablePaths;
+ }
+
+ /**
+ * Returns the default setup: framework version, vendor, vendor version. If no information is provided by the user, then
+ * this information will be used to choose the environment. It may also be used for partial matches, if appropriate.
+ *
+ * @return the default setup: framework version, vendor, vendor version
+ */
+ public DefaultSetup getDefaultSetup()
+ {
+ return defaultSetup;
+ }
+
+ public boolean isEmpty()
+ {
+ return getVendors().size() == 0 && defaultSetup == null;
+ }
+
+ public void initialize()
+ throws InitializationException
+ {
+
+ }
+}
+