From a34d298c47df02d9b9ed5945d47e6646e9f53c16 Mon Sep 17 00:00:00 2001 From: Prawal Agarwal Date: Mon, 4 Jul 2016 17:33:25 +0530 Subject: [PATCH 1/2] Fixing Java tasks --- Tasks/ANT/ant.ps1 | 39 +++++++++++++++++---------------- Tasks/ANT/task.json | 2 +- Tasks/ANT/task.loc.json | 2 +- Tasks/Gradle/Gradle.ps1 | 15 ++++++------- Tasks/Gradle/task.json | 2 +- Tasks/Gradle/task.loc.json | 2 +- Tasks/Maven/maven.ps1 | 44 +++++++++++++++++--------------------- Tasks/Maven/task.json | 2 +- Tasks/Maven/task.loc.json | 2 +- 9 files changed, 53 insertions(+), 57 deletions(-) diff --git a/Tasks/ANT/ant.ps1 b/Tasks/ANT/ant.ps1 index 5af0762a4bff..4192242f9afe 100644 --- a/Tasks/ANT/ant.ps1 +++ b/Tasks/ANT/ant.ps1 @@ -108,9 +108,15 @@ if ($jdkPath) } $buildRootPath = Split-Path $antBuildFile -Parent -$reportDirectoryName = [guid]::NewGuid() +$reportDirectoryName = "ReportDirectory_75C12DBC-FB59-450A-8E4F-772EA8BFCFA6" $reportDirectory = Join-Path $buildRootPath $reportDirectoryName +if(Test-Path $reportDirectory) + { + # delete any previous code coverage data + rm -r $reportDirectory -force | Out-Null + } + if($isCoverageEnabled) { if ($codeCoverageTool -eq "Cobertura") @@ -128,10 +134,22 @@ $summaryFile = Join-Path $summaryFile $summaryFileName # ensuring unique code coverage report task name by using guid $CCReportTask = "CodeCoverage_" +[guid]::NewGuid() -$reportBuildFileName = [guid]::NewGuid().tostring() + ".xml" +$reportBuildFileName = "ReportBuildFile_9B5907FC-EC56-4662-B8EA-EC23FCB97C43.xml" $reportBuildFile = Join-Path $buildRootPath $reportBuildFileName $instrumentedClassesDirectory = Join-Path $buildRootPath "InstrumentedClasses" +if(Test-Path $reportBuildFile) +{ + # delete any previous code coverage report build file + rm -r $reportBuildFile -force | Out-Null +} + +if(Test-Path $instrumentedClassesDirectory) +{ + # delete any previous instrumented classes directory + rm -r $instrumentedClassesDirectory -force | Out-Null +} + if($isCoverageEnabled) { try @@ -242,23 +260,6 @@ if($isCoverageEnabled) } } -if(Test-Path $reportDirectory) -{ - # delete any previous code coverage data - rm -r $reportDirectory -force | Out-Null -} - -if(Test-Path $reportBuildFile) -{ - # delete any previous code coverage report build file - rm -r $reportBuildFile -force | Out-Null -} - -if(Test-Path $instrumentedClassesDirectory) -{ - # delete any previous instrumented classes directory - rm -r $instrumentedClassesDirectory -force | Out-Null -} Write-Verbose "Leaving script Ant.ps1" diff --git a/Tasks/ANT/task.json b/Tasks/ANT/task.json index 9dfd27753433..4208208ca897 100644 --- a/Tasks/ANT/task.json +++ b/Tasks/ANT/task.json @@ -13,7 +13,7 @@ "version": { "Major": 1, "Minor": 0, - "Patch": 45 + "Patch": 46 }, "demands": [ "ant" diff --git a/Tasks/ANT/task.loc.json b/Tasks/ANT/task.loc.json index 264f9cac08f3..6efdb270ceba 100644 --- a/Tasks/ANT/task.loc.json +++ b/Tasks/ANT/task.loc.json @@ -13,7 +13,7 @@ "version": { "Major": 1, "Minor": 0, - "Patch": 45 + "Patch": 46 }, "demands": [ "ant" diff --git a/Tasks/Gradle/Gradle.ps1 b/Tasks/Gradle/Gradle.ps1 index ab18b20d8224..e9c692d5a1bb 100644 --- a/Tasks/Gradle/Gradle.ps1 +++ b/Tasks/Gradle/Gradle.ps1 @@ -105,9 +105,15 @@ if ($jdkPath) $buildRootPath = $cwd $wrapperDirectory = Split-Path $wrapperScript -Parent -$reportDirectoryName = [guid]::NewGuid() +$reportDirectoryName = "ReportDirectory_84B7D86C-F08D-4B65-8D37-742D8B02D27B" $reportDirectory = Join-Path $buildRootPath $reportDirectoryName +if(Test-Path $reportDirectory) +{ + # delete any code coverage data + rm -r $reportDirectory -force | Out-Null +} + # check if project is multi module gradle build or not $subprojects = Invoke-BatchScript -Path $wrapperScript -Arguments 'properties' -WorkingFolder $buildRootPath | Select-String '^subprojects: (.*)'|ForEach-Object {$_.Matches[0].Groups[1].Value} Write-Verbose "subprojects: $subprojects" @@ -213,11 +219,4 @@ if($isCoverageEnabled) } } -if(Test-Path $reportDirectory) -{ - # delete any code coverage data - rm -r $reportDirectory -force | Out-Null -} - - Write-Verbose "Leaving script Gradle.ps1" diff --git a/Tasks/Gradle/task.json b/Tasks/Gradle/task.json index df8bd7a8e88a..8a72d5c80bcd 100644 --- a/Tasks/Gradle/task.json +++ b/Tasks/Gradle/task.json @@ -12,7 +12,7 @@ "version": { "Major": 1, "Minor": 0, - "Patch": 43 + "Patch": 44 }, "demands": [ "java" diff --git a/Tasks/Gradle/task.loc.json b/Tasks/Gradle/task.loc.json index 3de71d7ce9cc..a62065c1b661 100644 --- a/Tasks/Gradle/task.loc.json +++ b/Tasks/Gradle/task.loc.json @@ -12,7 +12,7 @@ "version": { "Major": 1, "Minor": 0, - "Patch": 43 + "Patch": 44 }, "demands": [ "java" diff --git a/Tasks/Maven/maven.ps1 b/Tasks/Maven/maven.ps1 index 27619a0b45c7..f97027957729 100644 --- a/Tasks/Maven/maven.ps1 +++ b/Tasks/Maven/maven.ps1 @@ -109,9 +109,9 @@ import-module "Microsoft.TeamFoundation.DistributedTask.Task.TestResults" $buildRootPath = Split-Path $mavenPOMFile -Parent -$reportDirectoryName = [guid]::NewGuid() +$reportDirectoryName = "ReportDirectory_C91CDE2D-CC66-4541-9C27-E3EF6CB3DB16" $reportDirectoryNameCobertura = "target\site\cobertura" -$reportPOMFileName = [guid]::NewGuid().tostring() + ".xml" +$reportPOMFileName = "ReportPOMFile_4E52C1C4-8C32-4580-A54D-41D5E9ED1F74.xml" $reportPOMFile = Join-Path $buildRootPath $reportPOMFileName $reportDirectory = Join-Path $buildRootPath $reportDirectoryName $reportDirectoryCobertura = Join-Path $buildRootPath $reportDirectoryNameCobertura @@ -126,6 +126,24 @@ $CCReportTask = "jacoco:report" Write-Verbose "SummaryFileCobertura = $summaryFileCobertura" +if(Test-Path $reportDirectory) +{ + # delete any previous code coverage data + rm -r $reportDirectory -force | Out-Null +} + +if(Test-Path $reportDirectoryCobertura) +{ + # delete any previous code coverage data from Cobertura + rm -r $reportDirectoryCobertura -force | Out-Null +} + +if(Test-Path $reportPOMFile) +{ + # delete any previous code coverage data + rm $reportPOMFile -force | Out-Null +} + if($isCoverageEnabled) { if(Test-Path $targetDirectory) @@ -184,26 +202,4 @@ ElseIf ($codeCoverageTool -eq "Cobertura") # Run SonarQube analysis by invoking Maven with the "sonar:sonar" goal RunSonarQubeAnalysis $sqAnalysisEnabled $sqConnectedServiceName $sqDbDetailsRequired $sqDbUrl $sqDbUsername $sqDbPassword $options $mavenPOMFile $execFileJacoco -if(Test-Path $reportDirectory) -{ - # delete any previous code coverage data - rm -r $reportDirectory -force | Out-Null -} - -if(Test-Path $reportDirectoryCobertura) -{ - # delete any previous code coverage data from Cobertura - rm -r $reportDirectoryCobertura -force | Out-Null -} - -if(Test-Path $reportPOMFile) -{ - # delete any previous code coverage data - rm $reportPOMFile -force | Out-Null -} - Write-Verbose "Leaving script Maven.ps1" - - - - diff --git a/Tasks/Maven/task.json b/Tasks/Maven/task.json index 7ee1797b50bc..5b8bfaa72e1a 100644 --- a/Tasks/Maven/task.json +++ b/Tasks/Maven/task.json @@ -16,7 +16,7 @@ "version": { "Major": 1, "Minor": 0, - "Patch": 53 + "Patch": 54 }, "minimumAgentVersion": "1.89.0", "instanceNameFormat": "Maven $(mavenPOMFile)", diff --git a/Tasks/Maven/task.loc.json b/Tasks/Maven/task.loc.json index 8c479145c77b..a99cf70777b0 100644 --- a/Tasks/Maven/task.loc.json +++ b/Tasks/Maven/task.loc.json @@ -16,7 +16,7 @@ "version": { "Major": 1, "Minor": 0, - "Patch": 53 + "Patch": 54 }, "minimumAgentVersion": "1.89.0", "instanceNameFormat": "ms-resource:loc.instanceNameFormat", From 30a01a0e27c42015cc94f21ae5ef442a57288694 Mon Sep 17 00:00:00 2001 From: Prawal Agarwal Date: Tue, 5 Jul 2016 14:00:40 +0530 Subject: [PATCH 2/2] PR Comments --- Tasks/ANT/ant.ps1 | 47 +++++++++++++++++++++++++++++------------ Tasks/Gradle/Gradle.ps1 | 16 ++++++++++---- Tasks/Maven/maven.ps1 | 38 ++++++++++++++++++++++----------- 3 files changed, 72 insertions(+), 29 deletions(-) diff --git a/Tasks/ANT/ant.ps1 b/Tasks/ANT/ant.ps1 index 4192242f9afe..f8b5146eb715 100644 --- a/Tasks/ANT/ant.ps1 +++ b/Tasks/ANT/ant.ps1 @@ -108,14 +108,21 @@ if ($jdkPath) } $buildRootPath = Split-Path $antBuildFile -Parent -$reportDirectoryName = "ReportDirectory_75C12DBC-FB59-450A-8E4F-772EA8BFCFA6" +$reportDirectoryName = "ReportDirectory75C12DBC" $reportDirectory = Join-Path $buildRootPath $reportDirectoryName -if(Test-Path $reportDirectory) - { - # delete any previous code coverage data - rm -r $reportDirectory -force | Out-Null - } +try +{ + if(Test-Path $reportDirectory) + { + # delete any previous code coverage data + rm -r $reportDirectory -force | Out-Null + } +} +catch +{ + Write-Verbose "Failed to delete report directory" +} if($isCoverageEnabled) { @@ -134,20 +141,34 @@ $summaryFile = Join-Path $summaryFile $summaryFileName # ensuring unique code coverage report task name by using guid $CCReportTask = "CodeCoverage_" +[guid]::NewGuid() -$reportBuildFileName = "ReportBuildFile_9B5907FC-EC56-4662-B8EA-EC23FCB97C43.xml" +$reportBuildFileName = "ReportBuildFile9B5907FC.xml" $reportBuildFile = Join-Path $buildRootPath $reportBuildFileName $instrumentedClassesDirectory = Join-Path $buildRootPath "InstrumentedClasses" -if(Test-Path $reportBuildFile) +try +{ + if(Test-Path $reportBuildFile) + { + # delete any previous code coverage report build file + rm -r $reportBuildFile -force | Out-Null + } +} +catch { - # delete any previous code coverage report build file - rm -r $reportBuildFile -force | Out-Null + Write-Verbose "Failed to delete report build file" } -if(Test-Path $instrumentedClassesDirectory) +try +{ + if(Test-Path $instrumentedClassesDirectory) + { + # delete any previous instrumented classes directory + rm -r $instrumentedClassesDirectory -force | Out-Null + } +} +catch { - # delete any previous instrumented classes directory - rm -r $instrumentedClassesDirectory -force | Out-Null + Write-Verbose "Failed to delete instrumented classes directory" } if($isCoverageEnabled) diff --git a/Tasks/Gradle/Gradle.ps1 b/Tasks/Gradle/Gradle.ps1 index e9c692d5a1bb..db39de65176c 100644 --- a/Tasks/Gradle/Gradle.ps1 +++ b/Tasks/Gradle/Gradle.ps1 @@ -105,15 +105,23 @@ if ($jdkPath) $buildRootPath = $cwd $wrapperDirectory = Split-Path $wrapperScript -Parent -$reportDirectoryName = "ReportDirectory_84B7D86C-F08D-4B65-8D37-742D8B02D27B" +$reportDirectoryName = "ReportDirectory84B7D86C" $reportDirectory = Join-Path $buildRootPath $reportDirectoryName -if(Test-Path $reportDirectory) +try +{ + if(Test-Path $reportDirectory) + { + # delete any code coverage data + rm -r $reportDirectory -force | Out-Null + } +} +catch { - # delete any code coverage data - rm -r $reportDirectory -force | Out-Null + Write-Verbose "Failed to delete report directory" } + # check if project is multi module gradle build or not $subprojects = Invoke-BatchScript -Path $wrapperScript -Arguments 'properties' -WorkingFolder $buildRootPath | Select-String '^subprojects: (.*)'|ForEach-Object {$_.Matches[0].Groups[1].Value} Write-Verbose "subprojects: $subprojects" diff --git a/Tasks/Maven/maven.ps1 b/Tasks/Maven/maven.ps1 index f97027957729..dcb88b80a625 100644 --- a/Tasks/Maven/maven.ps1 +++ b/Tasks/Maven/maven.ps1 @@ -109,9 +109,9 @@ import-module "Microsoft.TeamFoundation.DistributedTask.Task.TestResults" $buildRootPath = Split-Path $mavenPOMFile -Parent -$reportDirectoryName = "ReportDirectory_C91CDE2D-CC66-4541-9C27-E3EF6CB3DB16" +$reportDirectoryName = "ReportDirectoryC91CDE2D" $reportDirectoryNameCobertura = "target\site\cobertura" -$reportPOMFileName = "ReportPOMFile_4E52C1C4-8C32-4580-A54D-41D5E9ED1F74.xml" +$reportPOMFileName = "ReportPOMFile4E52C1C4.xml" $reportPOMFile = Join-Path $buildRootPath $reportPOMFileName $reportDirectory = Join-Path $buildRootPath $reportDirectoryName $reportDirectoryCobertura = Join-Path $buildRootPath $reportDirectoryNameCobertura @@ -126,22 +126,36 @@ $CCReportTask = "jacoco:report" Write-Verbose "SummaryFileCobertura = $summaryFileCobertura" -if(Test-Path $reportDirectory) +try { - # delete any previous code coverage data - rm -r $reportDirectory -force | Out-Null -} + if(Test-Path $reportDirectory) + { + # delete any previous code coverage data + rm -r $reportDirectory -force | Out-Null + } -if(Test-Path $reportDirectoryCobertura) + if(Test-Path $reportDirectoryCobertura) + { + # delete any previous code coverage data from Cobertura + rm -r $reportDirectoryCobertura -force | Out-Null + } +} +catch { - # delete any previous code coverage data from Cobertura - rm -r $reportDirectoryCobertura -force | Out-Null + Write-Verbose "Failed to delete report directory" } -if(Test-Path $reportPOMFile) +try +{ + if(Test-Path $reportPOMFile) + { + # delete any previous code coverage data + rm $reportPOMFile -force | Out-Null + } +} +catch { - # delete any previous code coverage data - rm $reportPOMFile -force | Out-Null + Write-Verbose "Failed to delete report POM file" } if($isCoverageEnabled)