Repository: incubator-reef
Updated Branches:
  refs/heads/branch-0.11.0-incubating-maven [created] f924414ae


[REEF-284] Remove hard coded -SNAPSHOT in NuGet packages generation script

This PR is to improve and consolidate the NuGet version generation.  It

        • Removes power shell script for NuGet version and Nuget Spec
        • generates nugget version number in build.prop so that it can be 
used in other proj files
        • Replaces NuGet version in NuGet spec on the fly instead of copying 
and generating another spec file
        • Uses flags instead of hard coding to decide if -SNAPSHOT or 
-incubating is needed as part of the version number.

JIRA: REEF-284(https://issues.apache.org/jira/browse/REEF-284)

This closes #

Author: Julia Wang  Email: [email protected]


Project: http://git-wip-us.apache.org/repos/asf/incubator-reef/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-reef/commit/09c29edd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-reef/tree/09c29edd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-reef/diff/09c29edd

Branch: refs/heads/branch-0.11.0-incubating-maven
Commit: 09c29eddfee12d706fb40d3dce626e6d7f4f7908
Parents: b2e85d1
Author: Julia Wang <[email protected]>
Authored: Tue Apr 28 10:26:36 2015 -0700
Committer: Julia Wang <[email protected]>
Committed: Tue Apr 28 10:26:36 2015 -0700

----------------------------------------------------------------------
 lang/cs/.nuget/NuGet.targets                    | 15 ++--
 lang/cs/.nuget/finalizeNuspec.ps1               | 93 --------------------
 .../Org.Apache.REEF.Bridge.JAR.csproj           | 72 +++++++--------
 lang/cs/build.props                             |  6 +-
 4 files changed, 49 insertions(+), 137 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/09c29edd/lang/cs/.nuget/NuGet.targets
----------------------------------------------------------------------
diff --git a/lang/cs/.nuget/NuGet.targets b/lang/cs/.nuget/NuGet.targets
index c395f45..951ec18 100644
--- a/lang/cs/.nuget/NuGet.targets
+++ b/lang/cs/.nuget/NuGet.targets
@@ -80,7 +80,8 @@ under the License.
         <PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' 
">"$(SolutionDir)"</PaddedSolutionDir>
 
         <!-- Nuspec file -->
-        
<FinalizedNuspecFile>$(SolutionDir)\.nuget\nuspec\$(AssemblyName).nuspec</FinalizedNuspecFile>
+<!--        
<FinalizedNuspecFile>$(SolutionDir)\.nuget\nuspec\$(AssemblyName).nuspec</FinalizedNuspecFile>
  -->
+        
<FinalizedNuspecFile>$(SolutionDir)\$(AssemblyName)\$(AssemblyName).nuspec</FinalizedNuspecFile>
 
         <!-- Project path -->
         <NugetProjectPath>$(SolutionDir)\$(RootNamespace)</NugetProjectPath>
@@ -141,9 +142,9 @@ under the License.
               Condition="'$(OS)' == 'Windows_NT' And 
Exists('$(PackagesConfig)')" />
     </Target>
 
-    <Target Name="BuildPackage" DependsOnTargets="ExtractPOMVersion; 
CheckPrerequisites; FinalizeNuspecFiles">
+    <Target Name="BuildPackage" DependsOnTargets="ExtractPOMVersion; 
CheckPrerequisites">
         <PropertyGroup>
-            <BuildCommand>$(NuGetCommand) pack "$(FinalizedNuspecFile)" 
-BasePath $(NugetProjectPath) -Properties 
"Configuration=$(Configuration);Platform=$(Platform);REEF_Version=$(REEF_Version)"
 $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" </BuildCommand>
+            <BuildCommand>$(NuGetCommand) pack "$(FinalizedNuspecFile)" 
-BasePath $(NugetProjectPath) -Properties 
"Configuration=$(Configuration);Platform=$(Platform);REEF_Version=$(REEF_Version);Version=$(REEF_NugetVersion)"
 $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" </BuildCommand>
         </PropertyGroup>
 
         <Exec Command="$(BuildCommand)"
@@ -154,7 +155,7 @@ under the License.
               Condition=" '$(OS)' == 'Windows_NT' " />
     </Target>
 
-    <Target Name="FinalizeNuspecFiles">
+    <!--<Target Name="FinalizeNuspecFiles">
         <PropertyGroup>
             
<FinalizeNuspecScript>$(SolutionDir)\.nuget\finalizeNuspec.ps1</FinalizeNuspecScript>
             <ScriptCommand Condition="'$(IsSnapshot)' == 
'true'">$(FinalizeNuspecScript) -SolutionDir $(SolutionDir) -Snapshot 
-SnapshotNumber $(SnapshotNumber)</ScriptCommand>
@@ -164,7 +165,7 @@ under the License.
         <Exec Command="powershell -NonInteractive -NoProfile -Command 
$(ScriptCommand)"
             LogStandardErrorAsError="true">
         </Exec>
-    </Target>
+    </Target> -->
 
     <Target Name="CleanNugetPackages">
         <PropertyGroup>
@@ -190,11 +191,11 @@ under the License.
 
     <Target Name="PushPackages" >
         <ItemGroup>
-            <PackageFile 
Include="$(SolutionDir2).nuget\packages\$(RootNamespace).$(REEF_NugetVersion)$(SnapshotNumber).nupkg"
 />
+            <PackageFile 
Include="$(SolutionDir2).nuget\packages\$(RootNamespace).$(REEF_NugetVersion).nupkg"
 />
         </ItemGroup>
 
         <PropertyGroup>
-           <PushCommand Condition="'$(NuGetApiKey)' == '' OR '$(NuGetApiKey)' 
== '*Undefined*'">$(NuGetCommand) push @(PackageFile) -Source 
$(NuGetRepository)</PushCommand>
+            <PushCommand Condition="'$(NuGetApiKey)' == '' OR '$(NuGetApiKey)' 
== '*Undefined*'">$(NuGetCommand) push @(PackageFile) -Source 
$(NuGetRepository)</PushCommand>
             <PushCommand Condition="'$(NuGetApiKey)' != '' AND 
'$(NuGetApiKey)' != '*Undefined*'">$(NuGetCommand) push @(PackageFile) 
$(NuGetApiKey) -Source $(NuGetRepository)</PushCommand>
 
         </PropertyGroup>

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/09c29edd/lang/cs/.nuget/finalizeNuspec.ps1
----------------------------------------------------------------------
diff --git a/lang/cs/.nuget/finalizeNuspec.ps1 
b/lang/cs/.nuget/finalizeNuspec.ps1
deleted file mode 100644
index 72c3dee..0000000
--- a/lang/cs/.nuget/finalizeNuspec.ps1
+++ /dev/null
@@ -1,93 +0,0 @@
-<#
-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.
-#>
-
-Param(
-    [Parameter(Mandatory=$true)]
-    [string]$SolutionDir,
-
-    [switch]$Snapshot,
-
-    [int]$SnapshotNumber
-)
-
-Function Get-Nuspec-Version {
-    <#
-    .DESCRIPTION
-    Extracts the NuGet version number from the pom.xml file in the source 
directory.
-    #>
-
-    $pomPath = "$SolutionDir\..\..\pom.xml"
-    $pom = [xml] (Get-Content $pomPath)
-    $version = $pom.project.version -replace '-incubating-SNAPSHOT',''
-    return $version
-}
-
-Function Prep-Nuspec-Files {
-    <#
-    .DESCRIPTION
-    Creates a directory for the finalized nuspec files to live.  Next,
-    the temporary nuspec files in each source directory will get copied
-    to the new nuspec directory.
-    #>
-
-    $nuspecDir = "$SolutionDir\.nuget\nuspec"
-
-    # Delete the directory if it already exists
-    if (Test-Path $nuspecDir) {
-        rmdir -Force -Recurse $nuspecDir
-    }
-
-    # Create directory for finalized nuspec files to live
-    mkdir -Force $nuspecDir
-
-    # Copy over temporary nuspec files into new nuspec directory
-    $tempNuspecFiles = Get-ChildItem $SolutionDir\**\*.nuspec
-    foreach ($tempNuspecFile in $tempNuspecFiles) {
-        Copy-Item $tempNuspecFile.FullName $nuspecDir
-    }
-}
-
-Function Finalize-Nuspec-Version {
-    <#
-    .DESCRIPTION
-    Replaces the $version$ token in each nuspec file with the actual version 
string.
-    #>
-
-    param([string]$version)
-
-    if ($Snapshot) {
-        $fullVersion = "$version-SNAPSHOT-$SnapshotNumber"
-    } 
-    else {
-        $fullVersion = $version
-    }
-
-    $nuspecDir = "$SolutionDir\.nuget\nuspec"
-    Write-Output $nuspecDir
-    $nuspecFiles = Get-ChildItem $nuspecDir
-    
-    # Replace the $version$ token with the specified version in each nuspec 
file
-    foreach ($nuspec in $nuspecFiles) {
-        $finalizedNuspec = Get-Content $nuspec.FullName | foreach { $_ 
-replace '\$version\$',"$fullVersion" }
-        Set-Content -Path $nuspec.FullName -Value $finalizedNuspec
-    }
-}
-
-Prep-Nuspec-Files
-$version = Get-Nuspec-Version
-Finalize-Nuspec-Version($version)
-Exit $LASTEXITCODE 

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/09c29edd/lang/cs/Org.Apache.REEF.Bridge.JAR/Org.Apache.REEF.Bridge.JAR.csproj
----------------------------------------------------------------------
diff --git 
a/lang/cs/Org.Apache.REEF.Bridge.JAR/Org.Apache.REEF.Bridge.JAR.csproj 
b/lang/cs/Org.Apache.REEF.Bridge.JAR/Org.Apache.REEF.Bridge.JAR.csproj
index 63cbd8b..21637e7 100644
--- a/lang/cs/Org.Apache.REEF.Bridge.JAR/Org.Apache.REEF.Bridge.JAR.csproj
+++ b/lang/cs/Org.Apache.REEF.Bridge.JAR/Org.Apache.REEF.Bridge.JAR.csproj
@@ -91,40 +91,42 @@ under the License.
   -->
   <Target Name="Rebuild" DependsOnTargets="Clean;Build"/>
   <Target Name="CheckPrerequisites" DependsOnTargets="Build"/>
-    <Target Name="BuildPackage" Condition="'$(BuildPackage)' == 'true'" 
DependsOnTargets="ExtractPOMVersion; CheckPrerequisites; FinalizeNuspecFiles" 
AfterTargets="Build">
-        <PropertyGroup>
-            <BuildCommand>$(NuGetCommand) pack "$(FinalizedNuspecFile)" 
-BasePath $(NugetProjectPath) -Properties 
"Configuration=$(Configuration);Platform=$(Platform);REEF_Version=$(REEF_Version)"
 $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" </BuildCommand>
-            
<ReefVer>$([System.String]::Copy('$(REEF_NugetVersion)').Replace('-SNAPSHOT-',''))</ReefVer>
-        </PropertyGroup>
+  <Target Name="BuildPackage" Condition="'$(BuildPackage)' == 'true'" 
DependsOnTargets="ExtractPOMVersion; CheckPrerequisites" AfterTargets="Build">
 
-  <ItemGroup>
-    <Line Include="line01"><Text>param($installPath, $toolsPath, $package, 
$project)</Text></Line>
-    <Line Include="line02"><Text>$file1 = 
$project.ProjectItems.Item("reef-bridge-java-$(ReefVer)-incubating-SNAPSHOT-shaded.jar")</Text></Line>
-    <Line Include="line03"><Text>$copyToOutput1 = 
$file1.Properties.Item("CopyToOutputDirectory")</Text></Line>
-    <Line Include="line04"><Text>$copyToOutput1.Value = 2</Text></Line>
-    <!--Copy the client JAR-->
-    <Line Include="line05"><Text>$file2 = 
$project.ProjectItems.Item("reef-bridge-client-$(ReefVer)-incubating-SNAPSHOT-shaded.jar")</Text></Line>
-    <Line Include="line06"><Text>$copyToOutput2 = 
$file2.Properties.Item("CopyToOutputDirectory")</Text></Line>
-    <Line Include="line07"><Text>$copyToOutput2.Value = 2</Text></Line>
-    <LineText Include="%(Line.Text)" />
-  </ItemGroup>
-  <WriteLinesToFile
-     
File="$(SolutionDir)\bin\$(Platform)\$(Configuration)\$(AssemblyName)\install.ps1"
-     Lines="@(LineText)"
-     Overwrite="true"
-     />
-        <Exec Command="$(BuildCommand)" Condition=" '$(OS)' != 'Windows_NT' " 
/>
-        <Exec Command="$(BuildCommand)" LogStandardErrorAsError="true" 
Condition=" '$(OS)' == 'Windows_NT' " />
-    </Target>
-    <Target Name="PushPackages" Condition="'$(PushPackages)' == 'true'" 
DependsOnTargets="BuildPackage"  AfterTargets="BuildPackage">
-        <ItemGroup>
-            <PackageFile 
Include="$(SolutionDir).nuget\packages\$(RootNamespace).$(REEF_NugetVersion)$(SnapshotNumber).nupkg"
 />
-        </ItemGroup>
-        <PropertyGroup>
-            <PushCommand Condition="'$(NuGetApiKey)' == '' OR '$(NuGetApiKey)' 
== '*Undefined*'">$(NuGetCommand) push @(PackageFile) -Source 
$(NuGetRepository)</PushCommand>
-            <PushCommand Condition="'$(NuGetApiKey)' != '' AND 
'$(NuGetApiKey)' != '*Undefined*'">$(NuGetCommand) push @(PackageFile) 
$(NuGetApiKey) -Source $(NuGetRepository)</PushCommand>
-        </PropertyGroup>
-       <Exec Condition="'$(BuildPackage)' == 'true'" Command="$(PushCommand)" 
LogStandardErrorAsError="true">
-        </Exec>
-    </Target>
+    <PropertyGroup>
+        <BuildCommand>$(NuGetCommand) pack "$(FinalizedNuspecFile)" -BasePath 
$(NugetProjectPath) -Properties 
"Configuration=$(Configuration);Platform=$(Platform);REEF_Version=$(REEF_Version);Version=$(REEF_NugetVersion)"
 $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" </BuildCommand>
+        
<ReefVer>$([System.String]::Copy('$(REEF_NugetVersion)').Replace('-SNAPSHOT-',''))</ReefVer>
+    </PropertyGroup>
+
+    <ItemGroup>
+        <Line Include="line01"><Text>param($installPath, $toolsPath, $package, 
$project)</Text></Line>
+        <Line Include="line02"><Text>$file1 = 
$project.ProjectItems.Item("reef-bridge-java-$(REEF_Version)-shaded.jar")</Text></Line>
+        <Line Include="line03"><Text>$copyToOutput1 = 
$file1.Properties.Item("CopyToOutputDirectory")</Text></Line>
+        <Line Include="line04"><Text>$copyToOutput1.Value = 2</Text></Line>
+        <!--Copy the client JAR-->
+       <Line Include="line05"><Text>$file2 = 
$project.ProjectItems.Item("reef-bridge-client-$(ReefVer)-incubating-SNAPSHOT-shaded.jar")</Text></Line>
+        <Line Include="line05"><Text>$file2 = 
$project.ProjectItems.Item("reef-bridge-client-$(REEF_Version)-shaded.jar")</Text></Line>
+        <Line Include="line07"><Text>$copyToOutput2.Value = 2</Text></Line>
+        <LineText Include="%(Line.Text)" />
+    </ItemGroup>
+
+    <WriteLinesToFile
+        
File="$(SolutionDir)\bin\$(Platform)\$(Configuration)\$(AssemblyName)\install.ps1"
+        Lines="@(LineText)"
+        Overwrite="true"
+    />
+    <Exec Command="$(BuildCommand)" Condition=" '$(OS)' != 'Windows_NT' " />
+    <Exec Command="$(BuildCommand)" LogStandardErrorAsError="true" Condition=" 
'$(OS)' == 'Windows_NT' " />
+  </Target>
+  <Target Name="PushPackages" Condition="'$(PushPackages)' == 'true'" 
DependsOnTargets="BuildPackage"  AfterTargets="BuildPackage">
+    <ItemGroup>
+        <PackageFile 
Include="$(SolutionDir).nuget\packages\$(RootNamespace).$(REEF_NugetVersion).nupkg"
 />
+    </ItemGroup>
+    <PropertyGroup>
+        <PushCommand Condition="'$(NuGetApiKey)' == '' OR '$(NuGetApiKey)' == 
'*Undefined*'">$(NuGetCommand) push @(PackageFile) -Source 
$(NuGetRepository)</PushCommand>
+        <PushCommand Condition="'$(NuGetApiKey)' != '' AND '$(NuGetApiKey)' != 
'*Undefined*'">$(NuGetCommand) push @(PackageFile) $(NuGetApiKey) -Source 
$(NuGetRepository)</PushCommand>
+    </PropertyGroup>
+    <Exec Condition="'$(BuildPackage)' == 'true'" Command="$(PushCommand)" 
LogStandardErrorAsError="true">
+    </Exec>
+  </Target>
 </Project>

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/09c29edd/lang/cs/build.props
----------------------------------------------------------------------
diff --git a/lang/cs/build.props b/lang/cs/build.props
index 60be51c..f7f2cf1 100644
--- a/lang/cs/build.props
+++ b/lang/cs/build.props
@@ -52,6 +52,7 @@ under the License.
 
   <!-- REEF NuGet properties -->
   <PropertyGroup>
+    <RemoveIncubating>true</RemoveIncubating>
     <IsSnapshot>true</IsSnapshot>
     <SnapshotNumber>92</SnapshotNumber>
     <PushPackages>false</PushPackages>
@@ -72,7 +73,7 @@ under the License.
     
<REEF_Source_Folder>$([System.IO.Path]::GetFullPath($(SolutionDir)\..\..))</REEF_Source_Folder>
   </PropertyGroup>
 
-  <!-- 
+  <!--
        ########################################################################
          Extract the REEF Version from the POM file 
        
######################################################################## 
@@ -100,7 +101,8 @@ under the License.
           Version = XDocument.Load(Path.Combine(ProjectFolder, 
"pom.xml")).Descendants()
             .Where(x => x.Name.ToString().Contains("version"))
             .FirstOrDefault().Value;
-          NugetVersion = Version.Replace("-incubating","") + "-" + 
SnapshotNumber;
+          var shortVer = $(RemoveIncubating) ? 
Version.Replace("-incubating","") : Version ;
+          NugetVersion = $(IsSnapshot) ? shortVer + "-" + $(SnapshotNumber) : 
shortVer.Replace("-SNAPSHOT","");
         ]]>
       </Code>
     </Task>

Reply via email to