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/02/10 18:05:33 UTC
svn commit: r1069505 - in /incubator/npanday/trunk/components:
dotnet-executable/src/main/java/npanday/executable/compiler/impl/
dotnet-executable/src/main/java/npanday/executable/impl/
dotnet-vendor/src/main/java/npanday/vendor/ dotnet-vendor/src/main...
Author: lcorneliussen
Date: Thu Feb 10 18:05:33 2011
New Revision: 1069505
URL: http://svn.apache.org/viewvc?rev=1069505&view=rev
Log:
Refactored how executables paths are found. Also improved the logging.
Modified:
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/BaseCompiler.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultNetExecutable.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultRepositoryNetExecutable.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/NetExecutableFactoryImpl.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/ThreadedNetExecutable.java
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoRepository.java
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsRepository.java
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoRepositoryImpl.java
incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoTransitionRuleFactory.java
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/BaseCompiler.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/BaseCompiler.java?rev=1069505&r1=1069504&r2=1069505&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/BaseCompiler.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/BaseCompiler.java Thu Feb 10 18:05:33 2011
@@ -101,10 +101,12 @@ abstract class BaseCompiler implements C
File exe = new File( executablePath + File.separator + executable + ".exe");
if ( exe.exists() )
{
+ logger.info("NPANDAY-068-005: Choose executable path for " + executable + ".exe: " + executablePath);
return new File(executablePath);
}
}
}
+ logger.warn("NPANDAY-068-006: Did not find path for " + executable + ".exe in " + executablePaths);
return null;
}
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultNetExecutable.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultNetExecutable.java?rev=1069505&r1=1069504&r2=1069505&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultNetExecutable.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultNetExecutable.java Thu Feb 10 18:05:33 2011
@@ -79,10 +79,12 @@ public class DefaultNetExecutable
File exe = new File( executablePath + File.separator + executable );
if ( exe.exists() )
{
+ logger.info("NPANDAY-070-003: Choose executable path for " + executable + ": " + executablePath);
return new File( executablePath );
}
}
}
+ logger.warn("NPANDAY-070-004: Did not find path for " + executable + " in " + executablePaths);
return null;
}
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultRepositoryNetExecutable.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultRepositoryNetExecutable.java?rev=1069505&r1=1069504&r2=1069505&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultRepositoryNetExecutable.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultRepositoryNetExecutable.java Thu Feb 10 18:05:33 2011
@@ -74,10 +74,13 @@ public class DefaultRepositoryNetExecuta
File exe = new File( executablePath );
if ( exe.exists() )
{
+ logger.info("NPANDAY-068-005: Choose executable path's parent as execution path: "
+ + new File( executablePath ).getParentFile().getAbsolutePath());
return new File( executablePath ).getParentFile();
}
}
}
+ logger.warn("NPANDAY-068-006: Did not find any of " + executablePaths);
return null;
}
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/NetExecutableFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/NetExecutableFactoryImpl.java?rev=1069505&r1=1069504&r2=1069505&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/NetExecutableFactoryImpl.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/NetExecutableFactoryImpl.java Thu Feb 10 18:05:33 2011
@@ -114,49 +114,40 @@ public class NetExecutableFactoryImpl
compilerRequirement.setVendor( vendorInfo.getVendor() );
compilerRequirement.setVendorVersion( vendorInfo.getVendorVersion() );
compilerRequirement.setFrameworkVersion( vendorInfo.getFrameworkVersion() );
- List<String> executionPaths = ( compilerConfig.getExecutionPaths() == null ) ? new ArrayList<String>()
- : compilerConfig.getExecutionPaths();
- if ( vendorInfoRepository != null && vendorInfoRepository.exists() )
- {
- File sdkInstallRoot = null;
- try
- {
- sdkInstallRoot = vendorInfoRepository.getSdkInstallRootFor( vendorInfo );
- }
- catch ( PlatformUnsupportedException e )
- {
- logger.debug( "NPANDAY-066-017: Did not find an SDK install root: " + vendorInfo, e );
- }
- File installRoot = vendorInfoRepository.getInstallRootFor( vendorInfo );
-
- if ( installRoot != null )
- {
- executionPaths.add( installRoot.getAbsolutePath() );
- }
- if ( sdkInstallRoot != null )
- {
- executionPaths.add( sdkInstallRoot.getAbsolutePath() );
- }
- }
+ // init does not need the executable paths to be set
compilerContext.init( compilerRequirement, compilerConfig, project, capabilityMatcher );
+
if ( assemblyPath != null )
{
compilerContext.getCompilerCapability().setAssemblyPath( assemblyPath.getAbsolutePath() );
}
- String netDependencyId = compilerContext.getCompilerCapability().getNetDependencyId();
- if ( netDependencyId != null )
+ List<String> executionPaths = ( compilerConfig.getExecutionPaths() == null ) ? new ArrayList<String>()
+ : compilerConfig.getExecutionPaths();
+ if (executionPaths == null || executionPaths.size() == 0 )
{
- Artifact artifact = artifactContext.getArtifactByID( netDependencyId );
- if ( artifact != null )
+ for(File path : vendorInfo.getExecutablePaths()){
+ executionPaths.add(path.getAbsolutePath());
+ }
+
+
+ String netDependencyId = compilerContext.getCompilerCapability().getNetDependencyId();
+
+ if ( netDependencyId != null )
{
- File artifactPath =
- PathUtil.getPrivateApplicationBaseFileFor( artifact, compilerConfig.getLocalRepository() );
- executionPaths.add( artifactPath.getParentFile().getAbsolutePath() );
+ Artifact artifact = artifactContext.getArtifactByID( netDependencyId );
+ if ( artifact != null )
+ {
+ File artifactPath =
+ PathUtil.getPrivateApplicationBaseFileFor( artifact, compilerConfig.getLocalRepository() );
+ executionPaths.add( artifactPath.getParentFile().getAbsolutePath() );
+ }
}
+
+ compilerConfig.setExecutionPaths( executionPaths );
}
- compilerConfig.setExecutionPaths( executionPaths );
+
try
{
return compilerContext.getCompilerExecutable();
@@ -430,27 +421,27 @@ public class NetExecutableFactoryImpl
List<String> executablePaths = ( executableConfig.getExecutionPaths() == null ) ? new ArrayList<String>()
: executableConfig.getExecutionPaths();
- if ( netHome != null && netHome.exists() )
+ if ( netHome != null )
{
- logger.info( "NPANDAY-066-014: Found executable path from pom: Path = " + netHome.getAbsolutePath() );
+ logger.info( "NPANDAY-066-014: Found executable path in pom: Path = " + netHome.getAbsolutePath() );
executablePaths.add( netHome.getAbsolutePath() );
}
- else if ( vendorInfo.getExecutablePaths() != null )
+
+ // should not fallback, if there are explicit configures
+ if ( executablePaths.isEmpty() && vendorInfo.getExecutablePaths() != null )
{
for ( File path : vendorInfo.getExecutablePaths() )
{
- if ( path.exists() )
- {
- logger.debug( "NPANDAY-066-015: Found executable path: Path = " + path.getAbsolutePath() );
- executablePaths.add( path.getAbsolutePath() );
- }
+ executablePaths.add( path.getAbsolutePath() );
}
}
- else
+
+ if (executablePaths.isEmpty())
{
logger.info( "NPANDAY-066-016: Did not find executable path, will try system path" );
}
executableConfig.setExecutionPaths( executablePaths );
+
executableContext.init( executableRequirement, executableConfig, capabilityMatcher );
try
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/ThreadedNetExecutable.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/ThreadedNetExecutable.java?rev=1069505&r1=1069504&r2=1069505&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/ThreadedNetExecutable.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/ThreadedNetExecutable.java Thu Feb 10 18:05:33 2011
@@ -96,10 +96,12 @@ public class ThreadedNetExecutable
File exe = new File( executablePath + File.separator + executable );
if ( exe.exists() )
{
+ logger.info("NPANDAY-063-005: Choose executable path for " + executable + ": " + executablePath);
return new File( executablePath );
}
}
}
+ logger.warn("NPANDAY-063-006: Did not find path for " + executable + " in " + executablePaths);
return null;
}
Modified: incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoRepository.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoRepository.java?rev=1069505&r1=1069504&r2=1069505&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoRepository.java (original)
+++ incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfoRepository.java Thu Feb 10 18:05:33 2011
@@ -89,7 +89,9 @@ public interface VendorInfoRepository
* @return file pointing to the .NET framework installation root used for compiling artifacts
* @throws npanday.PlatformUnsupportedException
*
+ * @deprecated getExecutablePathsFor should do the job
*/
+ @Deprecated
File getInstallRootFor( VendorInfo vendorInfo )
throws PlatformUnsupportedException;
@@ -104,6 +106,16 @@ public interface VendorInfoRepository
throws PlatformUnsupportedException;
/**
+ * Returns a list of configured paths where executables for compiling, eg. are found.
+ *
+ * @param vendorInfo the vendor info
+ * @return file pointing to the .NET SDK installation root used for compiling artifacts
+ * @throws PlatformUnsupportedException
+ */
+ List<File> getExecutablePathsFor( VendorInfo vendorInfo )
+ 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
Modified: incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsRepository.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsRepository.java?rev=1069505&r1=1069504&r2=1069505&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsRepository.java (original)
+++ incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsRepository.java Thu Feb 10 18:05:33 2011
@@ -202,6 +202,36 @@ public final class SettingsRepository
", 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.
Modified: incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoRepositoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoRepositoryImpl.java?rev=1069505&r1=1069504&r2=1069505&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoRepositoryImpl.java (original)
+++ incubator/npanday/trunk/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoRepositoryImpl.java Thu Feb 10 18:05:33 2011
@@ -81,8 +81,9 @@ public class VendorInfoRepositoryImpl
}
/**
- * @see VendorInfoRepository#getInstallRootFor(npanday.vendor.VendorInfo)
+ * @deprecated getExecutablePathsFor should do the job
*/
+ @Deprecated
public File getInstallRootFor( VendorInfo vendorInfo )
throws PlatformUnsupportedException
{
@@ -100,6 +101,15 @@ public class VendorInfoRepositoryImpl
vendorInfo.getFrameworkVersion() );
}
+ public List<File> getExecutablePathsFor( VendorInfo vendorInfo )
+ throws PlatformUnsupportedException
+ {
+ SettingsRepository settingsRepository = (SettingsRepository) repositoryRegistry.find( "npanday-settings" );
+ return settingsRepository.getExecutablePathsFor( vendorInfo.getVendor().getVendorName(),
+ vendorInfo.getVendorVersion(),
+ vendorInfo.getFrameworkVersion() );
+ }
+
/**
* @see npanday.vendor.VendorInfoRepository#getVendorInfos()
*/
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=1069505&r1=1069504&r2=1069505&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 Thu Feb 10 18:05:33 2011
@@ -121,35 +121,26 @@ final class VendorInfoTransitionRuleFact
{
public VendorInfoState process( VendorInfo vendorInfo )
{
- logger.debug( "NPANDAY-103-034: Entering State = Post Process" );
+ logger.debug( "NPANDAY-103-034: Entering State = Post Process, applying executable paths" );
if ( ( vendorInfo.getExecutablePaths() == null || vendorInfo.getExecutablePaths().size() == 0 ) &&
vendorInfoRepository.exists() )
{
- File sdkInstallRoot = null;
- List<File> executablePaths = new ArrayList<File>();
try
{
- sdkInstallRoot = vendorInfoRepository.getSdkInstallRootFor( vendorInfo );
- }
- catch ( PlatformUnsupportedException e )
- {
- logger.debug( "NPANDAY-103-36: Failed to resolve install sdk root." );
- }
- try
- {
- executablePaths.add( vendorInfoRepository.getInstallRootFor( vendorInfo ) );
- vendorInfo.setExecutablePaths( executablePaths );
+ List<File> existingPaths = new ArrayList<File>();
+ for(File path : vendorInfoRepository.getExecutablePathsFor(vendorInfo)){
+ if (!path.exists()) {
+ logger.debug( "NPANDAY-103-61: Configured path does not exist and is therefore omitted: " + path );
+ }
+ else {
+ existingPaths.add(path);
+ }
+ }
+ vendorInfo.setExecutablePaths( existingPaths );
}
catch ( PlatformUnsupportedException e )
{
- logger.debug( "NPANDAY-103-35: Failed to resolve install root." );
- }
- finally
- {
- if ( sdkInstallRoot != null )
- {
- executablePaths.add( sdkInstallRoot );
- }
+ logger.debug( "NPANDAY-103-36: Failed to resolve configured executable paths." );
}
}
return VendorInfoState.EXIT;