@@ -28,7 +28,7 @@ function Get-AllPackageInfoFromRepo ($serviceDirectory)
2828 $pkgProp = [PackageProps ]::new($pkgName , $pkgVersion , $pkgPath , $serviceDirName , $pkgGroup )
2929 $allPackageProps += $pkgProp
3030 }
31-
31+
3232 }
3333 return $allPackageProps
3434}
@@ -41,4 +41,72 @@ function SetPackageVersion ($PackageName, $Version, $ReleaseDate, $ReplaceLatest
4141 }
4242 & " $EngDir /scripts/Update-PkgVersion.ps1" - PackageName $PackageName - NewVersionString $Version `
4343 - ReleaseDate $ReleaseDate - ReplaceLatestEntryTitle $ReplaceLatestEntryTitle
44+ }
45+
46+ function Publish-andriod-GithubIODocs ($DocLocation , $PublicArtifactLocation )
47+ {
48+ $PublishedDocs = Get-ChildItem " $DocLocation " | Where-Object - FilterScript {$_.Name.EndsWith (" -javadoc.jar" )}
49+ foreach ($Item in $PublishedDocs )
50+ {
51+ $UnjarredDocumentationPath = " "
52+ try
53+ {
54+ $PkgName = $Item.BaseName
55+ # The jar's unpacking command doesn't allow specifying a target directory
56+ # and will unjar all of the files in whatever the current directory is.
57+ # Create a subdirectory to unjar into, set the location, unjar and then
58+ # set the location back to its original location.
59+ $UnjarredDocumentationPath = Join-Path - Path $DocLocation - ChildPath $PkgName
60+ New-Item - ItemType directory - Path " $UnjarredDocumentationPath "
61+ $CurrentLocation = Get-Location
62+ Set-Location $UnjarredDocumentationPath
63+ jar - xf " $ ( $Item.FullName ) "
64+ Set-Location $CurrentLocation
65+
66+ # If javadocs are produced for a library with source, there will always be an
67+ # index.html. If this file doesn't exist in the UnjarredDocumentationPath then
68+ # this is a sourceless library which means there are no javadocs and nothing
69+ # should be uploaded to blob storage.
70+ $IndexHtml = Join-Path - Path $UnjarredDocumentationPath - ChildPath " index.html"
71+ if (! (Test-Path - path $IndexHtml ))
72+ {
73+ Write-Host " $ ( $PkgName ) does not have an index.html file, skipping."
74+ continue
75+ }
76+
77+ # Get the POM file for the artifact we're processing
78+ $PomFile = $Item.FullName.Substring (0 , $Item.FullName.LastIndexOf ((" -javadoc.jar" ))) + " .pom"
79+ Write-Host " PomFile $ ( $PomFile ) "
80+
81+ # Pull the version from the POM
82+ [xml ]$PomXml = Get-Content $PomFile
83+ $Version = $PomXml.project.version
84+ $ArtifactId = $PomXml.project.artifactId
85+
86+ # inject the ga tag just before we upload the index to storage.
87+ $indexContent = Get-Content - Path $IndexHtml - Raw
88+ $tagContent = Get-Content - Path $CampaignTag - Raw
89+
90+ $indexContent = $indexContent.Replace (" </head>" , $tagContent + " </head>" )
91+ Set-Content - Path $IndexHtml - Value $indexContent - NoNewline
92+
93+ Write-Host " Start Upload for $ ( $PkgName ) /$ ( $Version ) "
94+ Write-Host " DocDir $ ( $UnjarredDocumentationPath ) "
95+ Write-Host " PkgName $ ( $ArtifactId ) "
96+ Write-Host " DocVersion $ ( $Version ) "
97+ $releaseTag = RetrieveReleaseTag $PublicArtifactLocation
98+ Upload- Blobs - DocDir $UnjarredDocumentationPath - PkgName $ArtifactId - DocVersion $Version - ReleaseTag $releaseTag
99+ }
100+ Finally
101+ {
102+ if (! [string ]::IsNullOrEmpty($UnjarredDocumentationPath ))
103+ {
104+ if (Test-Path - Path $UnjarredDocumentationPath )
105+ {
106+ Write-Host " Cleaning up $UnjarredDocumentationPath "
107+ Remove-Item - Recurse - Force $UnjarredDocumentationPath
108+ }
109+ }
110+ }
111+ }
44112}
0 commit comments