Author: brett Date: Fri Aug 22 07:26:51 2014 New Revision: 1619693 URL: http://svn.apache.org/r1619693 Log: [NPANDAY-585] support any version of Azure SDK
Use a version range for executable version matching, and then construct the probingPath directly using the registry key and executable version Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/MatchPolicyFactory.java incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/npanday/plugin/azure/AbstractCSPackDeployMojo.java incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/MatchPolicyFactory.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/MatchPolicyFactory.java?rev=1619693&r1=1619692&r2=1619693&view=diff ============================================================================== --- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/MatchPolicyFactory.java (original) +++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/MatchPolicyFactory.java Fri Aug 22 07:26:51 2014 @@ -22,6 +22,9 @@ package npanday.executable.impl; import npanday.executable.ExecutableCapability; import npanday.executable.ExecutableMatchPolicy; import npanday.executable.compiler.CompilerCapability; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; +import org.apache.maven.artifact.versioning.VersionRange; import static com.google.common.base.Strings.isNullOrEmpty; @@ -123,14 +126,21 @@ final class MatchPolicyFactory if (isNullOrEmpty(requiredExecutableVersion)) return true; - final String offeredExecutableVersion = executableCapability.getExecutableVersion(); + String offeredExecutableVersion = executableCapability.getExecutableVersion(); // if not specified, it is valid for all versions! if (isNullOrEmpty( offeredExecutableVersion )) return true; - // TODO: NPANDAY-499 this should support version range expressions - return requiredExecutableVersion.toLowerCase().trim().equals( offeredExecutableVersion.toLowerCase().trim() ); + String required = requiredExecutableVersion.toLowerCase().trim(); + offeredExecutableVersion = offeredExecutableVersion.toLowerCase().trim(); + try { + VersionRange range = VersionRange.createFromVersionSpec( offeredExecutableVersion ); + return range.containsVersion( new DefaultArtifactVersion( required ) ); + } catch (InvalidVersionSpecificationException e) { + // fallback to just matching version if not a valid range + return required.equals(offeredExecutableVersion); + } } public String toString() Modified: incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/npanday/plugin/azure/AbstractCSPackDeployMojo.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/npanday/plugin/azure/AbstractCSPackDeployMojo.java?rev=1619693&r1=1619692&r2=1619693&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/npanday/plugin/azure/AbstractCSPackDeployMojo.java (original) +++ incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/npanday/plugin/azure/AbstractCSPackDeployMojo.java Fri Aug 22 07:26:51 2014 @@ -23,9 +23,12 @@ import npanday.PlatformUnsupportedExcept import npanday.executable.ExecutableRequirement; import npanday.executable.ExecutionException; import npanday.executable.NetExecutable; +import npanday.registry.impl.WinRegistry; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import java.io.File; +import java.lang.reflect.InvocationTargetException; import java.util.List; @@ -67,12 +70,26 @@ public abstract class AbstractCSPackDepl try { - // TODO: confusion of 'identifier' and 'profile' / align to new NPANDAY-499 + File sdkHome = null; + try { + String azureSdkInstallPath = WinRegistry.readString(WinRegistry.HKEY_LOCAL_MACHINE, + "SOFTWARE\\Microsoft\\Microsoft SDKs\\ServiceHosting\\v" + executableVersion, "InstallPath"); + if ( azureSdkInstallPath != null ) + { + sdkHome = new File(azureSdkInstallPath, "bin"); + } + } catch (IllegalAccessException e) { + getLog().warn("Error looking up Azure SDK location from registry: " + e.getLocalizedMessage() + " - will rely on PATH"); + } catch (InvocationTargetException e) { + getLog().warn("Error looking up Azure SDK location from registry: " + e.getLocalizedMessage() + " - will rely on PATH"); + } + + // TODO: confusion of 'identifier' and 'profile' / align to new NPANDAY-499 final NetExecutable executable = netExecutableFactory.getExecutable( new ExecutableRequirement( vendor, vendorVersion, frameworkVersion, executableIdentifier, executableVersion /*, executableProfile*/ - ), getCommands(), null + ), getCommands(), sdkHome ); executable.execute(); } Modified: incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml?rev=1619693&r1=1619692&r2=1619693&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml (original) +++ incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml Fri Aug 22 07:26:51 2014 @@ -23,7 +23,7 @@ <pluginClass>npanday.executable.impl.DefaultNetExecutable</pluginClass> <executable>cspack</executable> - <executableVersion>1.6</executableVersion> + <executableVersion>[1.6,)</executableVersion> <vendor>MICROSOFT</vendor> @@ -34,90 +34,11 @@ <frameworkVersion>3.5</frameworkVersion> </frameworkVersions> + <!-- Paths are supplied in the mojo, so it can lookup the one matching the version used <probingPaths> <probingPath>${HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\ServiceHosting\v1.6@InstallPath}\bin</probingPath> </probingPaths> - - <platforms> - <platform> - <operatingSystem>Windows</operatingSystem> - </platform> - </platforms> - - </executablePlugin> - <executablePlugin> - <profile>CSPACK</profile> - <pluginClass>npanday.executable.impl.DefaultNetExecutable</pluginClass> - - <executable>cspack</executable> - <executableVersion>1.7</executableVersion> - - <vendor>MICROSOFT</vendor> - - <frameworkVersions> - <frameworkVersion>4.5.1</frameworkVersion> - <frameworkVersion>4.5</frameworkVersion> - <frameworkVersion>4.0</frameworkVersion> - <frameworkVersion>3.5</frameworkVersion> - </frameworkVersions> - - <probingPaths> - <probingPath>${HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\ServiceHosting\v1.7@InstallPath}\bin</probingPath> - </probingPaths> - - <platforms> - <platform> - <operatingSystem>Windows</operatingSystem> - </platform> - </platforms> - - </executablePlugin> - <executablePlugin> - <profile>CSPACK</profile> - <pluginClass>npanday.executable.impl.DefaultNetExecutable</pluginClass> - - <executable>cspack</executable> - <executableVersion>1.8</executableVersion> - - <vendor>MICROSOFT</vendor> - - <frameworkVersions> - <frameworkVersion>4.5.1</frameworkVersion> - <frameworkVersion>4.5</frameworkVersion> - <frameworkVersion>4.0</frameworkVersion> - <frameworkVersion>3.5</frameworkVersion> - </frameworkVersions> - - <probingPaths> - <probingPath>${HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\ServiceHosting\v1.8@InstallPath}\bin</probingPath> - </probingPaths> - - <platforms> - <platform> - <operatingSystem>Windows</operatingSystem> - </platform> - </platforms> - - </executablePlugin> - <executablePlugin> - <profile>CSPACK</profile> - <pluginClass>npanday.executable.impl.DefaultNetExecutable</pluginClass> - - <executable>cspack</executable> - <executableVersion>2.0</executableVersion> - - <vendor>MICROSOFT</vendor> - - <frameworkVersions> - <frameworkVersion>4.5.1</frameworkVersion> - <frameworkVersion>4.5</frameworkVersion> - <frameworkVersion>4.0</frameworkVersion> - <frameworkVersion>3.5</frameworkVersion> - </frameworkVersions> - - <probingPaths> - <probingPath>${HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\ServiceHosting\v2.0@InstallPath}\bin</probingPath> - </probingPaths> + --> <platforms> <platform>