@@ -31,27 +31,27 @@ Function CmdletHasMember($memberName) {
3131}
3232
3333Function GetMavenToolPath () {
34- if (! $mavenPath -or -not (Test-Path $mavenPath ))
35- {
36- throw " Maven path not specified or does not exist"
37- }
38- # The Maven bin path should contain either mvn.cmd (Maven 3) or mvn.bat (Maven 2)
39- $toolPath = gci - Path " $mavenPath " - Filter " mvn.cmd" - Recurse | select - First 1
40- if (! $toolPath )
41- {
42- $toolPath = gci - Path " $mavenPath " - Filter " mvn.bat" - Recurse | select - First 1
43- }
44- if (! $toolPath )
45- {
46- throw " Path $mavenPath does not contain a Maven installation"
47- }
48- Write-Host " Using Maven executable at $ ( $toolPath.FullName ) "
49- if ($mavenSetM2Home -eq $true )
50- {
51- $env: M2_HOME = $mavenPath
52- Write-Host " M2_HOME set to $mavenPath "
53- }
54- return $toolPath.FullName
34+ if (! $mavenPath -or -not (Test-Path $mavenPath ))
35+ {
36+ throw " Maven path not specified or does not exist"
37+ }
38+ # The Maven bin path should contain either mvn.cmd (Maven 3) or mvn.bat (Maven 2)
39+ $toolPath = gci - Path " $mavenPath " - Filter " mvn.cmd" - Recurse | select - First 1
40+ if (! $toolPath )
41+ {
42+ $toolPath = gci - Path " $mavenPath " - Filter " mvn.bat" - Recurse | select - First 1
43+ }
44+ if (! $toolPath )
45+ {
46+ throw " Path $mavenPath does not contain a Maven installation"
47+ }
48+ Write-Host " Using Maven executable at $ ( $toolPath.FullName ) "
49+ if ($mavenSetM2Home -eq $true )
50+ {
51+ $env: M2_HOME = $mavenPath
52+ Write-Host " M2_HOME set to $mavenPath "
53+ }
54+ return $toolPath.FullName
5555}
5656
5757Write-Verbose ' Entering Maven.ps1'
@@ -66,8 +66,8 @@ if($isCoverageEnabled -eq $true)
6666{
6767 Write-Verbose " codeCoverageTool = $codeCoverageTool " - Verbose
6868 Write-Verbose " classFilter = $classFilter " - Verbose
69- Write-Verbose " classFilesDirectories = $classFilesDirectories "
70- Write-Verbose " srcDirectories = $srcDirectories "
69+ Write-Verbose " classFilesDirectories = $classFilesDirectories "
70+ Write-Verbose " srcDirectories = $srcDirectories "
7171}
7272
7373Write-Verbose " javaHomeSelection = $javaHomeSelection "
@@ -132,8 +132,8 @@ Remove-Item -Recurse -Force $targetDirectory -ErrorAction SilentlyContinue
132132
133133if ($isCoverageEnabled )
134134{
135- Copy-Item $mavenPOMFile " $mavenPOMFile .tmp" - Force - ErrorAction Continue
136- Set-ItemProperty $mavenPOMFile - Name Attributes - Value Normal
135+ Copy-Item $mavenPOMFile " $mavenPOMFile .tmp" - Force - ErrorAction Continue
136+ Set-ItemProperty $mavenPOMFile - Name Attributes - Value Normal
137137}
138138
139139# Enable Code Coverage
@@ -146,40 +146,40 @@ ConfigureJDK $javaHomeSelection $jdkVersion $jdkArchitecture $jdkUserInputPath
146146Write-Host " Running Maven..."
147147if ($mavenVersionSelection -eq " Default" )
148148{
149- Invoke-Maven - MavenPomFile $mavenPOMFile - Options $options - Goals $goals
149+ Invoke-Maven - MavenPomFile $mavenPOMFile - Options $options - Goals $goals
150150}
151151else
152152{
153- $mavenToolPath = GetMavenToolPath
154- Invoke-Maven - MavenPomFile $mavenPOMFile - Options $options - Goals $goals - ToolPath $mavenToolPath
153+ $mavenToolPath = GetMavenToolPath
154+ Invoke-Maven - MavenPomFile $mavenPOMFile - Options $options - Goals $goals - ToolPath $mavenToolPath
155155}
156156
157157# Publish test results
158158$runTitleMemberExists = CmdletHasMember " RunTitle"
159159if ($runTitleMemberExists )
160160{
161- PublishTestResults $publishJUnitResults $testResultsFiles $testRunTitle
161+ PublishTestResults $publishJUnitResults $testResultsFiles $testRunTitle
162162}
163163else
164164{
165- if (! ([string ]::IsNullOrWhiteSpace($testRunTitle )))
166- {
167- Write-Warning " Update the build agent to be able to use the custom run title feature."
168- }
169- PublishTestResults $publishJUnitResults $testResultsFiles
165+ if (! ([string ]::IsNullOrWhiteSpace($testRunTitle )))
166+ {
167+ Write-Warning " Update the build agent to be able to use the custom run title feature."
168+ }
169+ PublishTestResults $publishJUnitResults $testResultsFiles
170170}
171171
172172if ($codeCoverageTool -eq " JaCoCo" )
173173{
174- # set sonar parameter
175- $execFileJacoco = Join-Path $reportDirectory " jacoco.exec"
176- # Publish code coverage for Jacoco
177- PublishCodeCoverageJacoco $isCoverageEnabled $mavenPOMFile $CCReportTask $summaryFileJacoco $reportDirectory $codeCoverageTool $reportPOMFile
174+ # set sonar parameter
175+ $execFileJacoco = Join-Path $reportDirectory " jacoco.exec"
176+ # Publish code coverage for Jacoco
177+ PublishCodeCoverageJacoco $isCoverageEnabled $mavenPOMFile $CCReportTask $summaryFileJacoco $reportDirectory $codeCoverageTool $reportPOMFile
178178}
179179ElseIf ($codeCoverageTool -eq " Cobertura" )
180180{
181- # Publish code coverage for Jacoco
182- PublishCodeCoverageCobertura $isCoverageEnabled $mavenPOMFile $summaryFileCobertura $reportDirectoryCobertura $codeCoverageTool
181+ # Publish code coverage for Jacoco
182+ PublishCodeCoverageCobertura $isCoverageEnabled $mavenPOMFile $summaryFileCobertura $reportDirectoryCobertura $codeCoverageTool
183183}
184184
185185# Run SonarQube analysis by invoking Maven with the "sonar:sonar" goal
@@ -188,8 +188,8 @@ RunSonarQubeAnalysis $sqAnalysisEnabled $sqConnectedServiceName $sqDbDetailsRequ
188188# Reset temp copy and file permissions are reset by default
189189if ($isCoverageEnabled )
190190{
191- Copy-Item " $mavenPOMFile .tmp" $mavenPOMFile - Force - ErrorAction Continue
192- Remove-Item " $mavenPOMFile .tmp" - Force - ErrorAction Continue
191+ Copy-Item " $mavenPOMFile .tmp" $mavenPOMFile - Force - ErrorAction Continue
192+ Remove-Item " $mavenPOMFile .tmp" - Force - ErrorAction Continue
193193}
194194
195195Write-Verbose " Leaving script Maven.ps1"
0 commit comments