From c4a9b698d011f6013c9e240e0eea1305d0480ef4 Mon Sep 17 00:00:00 2001 From: skaarthik Date: Mon, 8 Feb 2016 15:07:21 -0800 Subject: [PATCH] updating dev scripts to include missing files that need to be updated on version change --- dev/scripts/SetSparkClrJarVersion.ps1 | 16 ++++++- dev/scripts/SetSparkClrPackageVersion.ps1 | 52 ++++++++++++++--------- dev/scripts/SetVersion.cmd | 2 +- 3 files changed, 48 insertions(+), 22 deletions(-) diff --git a/dev/scripts/SetSparkClrJarVersion.ps1 b/dev/scripts/SetSparkClrJarVersion.ps1 index c5cd9e9..11c6496 100644 --- a/dev/scripts/SetSparkClrJarVersion.ps1 +++ b/dev/scripts/SetSparkClrJarVersion.ps1 @@ -43,7 +43,21 @@ function Update-SparkClrSubmit($targetDir, $version) ((Get-Content $_.FullName) -replace "\(set SPARKCLR_JAR=.*\)", "(set SPARKCLR_JAR=spark-clr_2.10-$version.jar)") | Set-Content $_.FullName -force } - Write-Output "[SetSparkClrJarVersion.Update-SparkClrSubmit] Done setting sparkclr-submit under $targetDir to version=$version" + Write-Output "[SetSparkClrJarVersion.Update-SparkClrSubmit] Done setting sparkclr-submit.cmd under $targetDir to version=$version" + + Write-Output "[SetSparkClrJarVersion.Update-SparkClrSubmit] Start setting sparkclr-submit.sh under $targetDir to version=$version" + + # + # Update SparkCLR package version to this release. The version string in sparkclr-submit.sh - + # + # export SPARKCLR_JAR=spark-clr_2.10-1.6.0-SNAPSHOT.jar + # + Get-ChildItem $targetDir -filter "sparkclr-submit.sh" -recurs | % { + Write-Output "[SetSparkClrJarVersion.Update-SparkClrSubmit] updating $($_.FullName)" + ((Get-Content $_.FullName) -replace "export SPARKCLR_JAR=.*", "export SPARKCLR_JAR=spark-clr_2.10-$version.jar") | Set-Content $_.FullName -force + } + + Write-Output "[SetSparkClrJarVersion.Update-SparkClrSubmit] Done setting sparkclr-submit.sh under $targetDir to version=$version" } function Print-Usage diff --git a/dev/scripts/SetSparkClrPackageVersion.ps1 b/dev/scripts/SetSparkClrPackageVersion.ps1 index 3f31ecc..4e3dbd7 100644 --- a/dev/scripts/SetSparkClrPackageVersion.ps1 +++ b/dev/scripts/SetSparkClrPackageVersion.ps1 @@ -4,24 +4,7 @@ # # "targetDir" parameter is default to current directory where this script is located, when not provided. # -Param([string]$targetDir, [string]$version) - -function Get-ScriptDirectory -{ - $Invocation = (Get-Variable MyInvocation -Scope 1).Value; - if($Invocation.PSScriptRoot) - { - $Invocation.PSScriptRoot; - } - Elseif($Invocation.MyCommand.Path) - { - Split-Path $Invocation.MyCommand.Path - } - else - { - $Invocation.InvocationName.Substring(0,$Invocation.InvocationName.LastIndexOf("\")); - } -} +Param([string]$targetDir, [string]$version, [string]$nuspecDir) function Update-Csproj($targetDir, $version) { @@ -67,6 +50,28 @@ function Update-PackageConfig($targetDir, $version) Write-Output "[SetSparkClrPackageVersion.Update-PackageConfig] Done setting *.csproj under $targetDir to version=$version" } +function Update_NuSpec($nuspecDir, $version) +{ + if (!(test-path $nuspecDir)) + { + Write-Output "[SetSparkClrPackageVersion.Update-NuSpec] WARNING!!! $nuspecDir does not exist. Please provide a valid directory name !" + return + } + + Write-Output "[SetSparkClrPackageVersion.Update-NuSpec] Start setting SparkCLR.nuspec under $nuspecDir to version=$version" + + # + # Update SparkCLR package version to this release. Example in SparkCLR.nuspec: + # 1.5.2-SNAPSHOT + # + Get-ChildItem $nuspecDir -filter "SparkCLR.nuspec" | % { + Write-Output "[SetSparkClrPackageVersion.Update-NuSpec] updating $($_.FullName)" + ((Get-Content $_.FullName) -replace "\s*\S*", "`"$version`"") | Set-Content -Encoding UTF8 -Path $_.FullName -force + } + + Write-Output "[SetSparkClrPackageVersion.Update-NuSpec] Done setting SparkCLR.nuspec under $nuspecDir to version=$version" +} + function Print-Usage { Write-Output '=====================================================================================================' @@ -93,9 +98,16 @@ if (!$PSBoundParameters.ContainsKey('version') -or [string]::IsNullOrEmpty($vers if (!$PSBoundParameters.ContainsKey('targetDir') -or [string]::IsNullOrEmpty($targetDir)) { - $targetDir = Get-ScriptDirectory - Write-Output "[SetSparkClrPackageVersion] targetDir is set to $targetDir" + Print-Usage + return +} + +if (!$PSBoundParameters.ContainsKey('nuspecDir') -or [string]::IsNullOrEmpty($nuspecDir)) +{ + Print-Usage + return } Update-Csproj $targetDir $version Update-PackageConfig $targetDir $version +Update_NuSpec $nuspecDir $version diff --git a/dev/scripts/SetVersion.cmd b/dev/scripts/SetVersion.cmd index 7984766..cd8194a 100644 --- a/dev/scripts/SetVersion.cmd +++ b/dev/scripts/SetVersion.cmd @@ -19,7 +19,7 @@ popd powershell -Command Set-ExecutionPolicy -Scope CurrentUser Unrestricted @rem update SparkClr Nuget package version reference -powershell -f SetSparkClrPackageVersion.ps1 -targetDir ..\..\examples -version %ProjectVersion% +powershell -f SetSparkClrPackageVersion.ps1 -targetDir ..\..\examples -version %ProjectVersion% -nuspecDir ..\..\csharp @rem update SparkClr jar version reference powershell -f SetSparkClrJarVersion.ps1 -targetDir ..\..\scripts -version %ProjectVersion%