1616
1717package com .google .cloud ;
1818
19- import static com .google .common .collect .ImmutableList .toImmutableList ;
20-
2119import com .google .cloud .tools .opensource .dependencies .Artifacts ;
2220import com .google .cloud .tools .opensource .dependencies .Bom ;
2321import com .google .cloud .tools .opensource .dependencies .MavenRepositoryException ;
2725import com .google .common .base .Joiner ;
2826import com .google .common .base .Splitter ;
2927import com .google .common .base .Verify ;
30- import com .google .common .base .VerifyException ;
3128import com .google .common .collect .ImmutableList ;
3229import com .google .common .collect .ImmutableMap ;
3330import com .google .common .collect .ImmutableSet ;
3431import com .google .common .collect .Sets ;
3532import com .google .common .collect .Sets .SetView ;
36- import com .google .common .collect . Streams ;
33+ import com .google .common .io . Files ;
3734import java .io .File ;
3835import java .io .IOException ;
3936import java .nio .charset .StandardCharsets ;
4037import java .util .ArrayList ;
4138import java .util .HashMap ;
4239import java .util .List ;
4340import java .util .Map ;
44- import java .util .Objects ;
45- import java .util .Optional ;
4641import java .util .concurrent .TimeUnit ;
4742import java .util .regex .Matcher ;
4843import java .util .regex .Pattern ;
@@ -61,7 +56,6 @@ public class ReleaseNoteGeneration {
6156 private static final String RELEASE_NOTE_FILE_NAME = "release_note.md" ;
6257 private static final String GOOGLEAPIS_ORG = "googleapis" ;
6358
64- private static final ImmutableSet <String > splitRepositoryLibraryNames = ImmutableSet .of ();
6559
6660 private static boolean clientLibraryFilter (String coordinates ) {
6761 if (coordinates .contains ("google-cloud-core" )) {
@@ -332,11 +326,7 @@ private void reportCloudClientBomDifference(Bom oldBom, Bom newBom, String googl
332326 }
333327
334328 report .append ("# Notable Changes\n \n " );
335- reportClientLibrariesNotableChangeLogs (
336- minorVersionBumpVersionlessCoordinates ,
337- versionlessCoordinatesToVersionOld ,
338- versionlessCoordinatesToVersionNew ,
339- googleCloudJavaVersion );
329+ reportClientLibrariesNotableChangeLogs (googleCloudJavaVersion );
340330
341331 report .append ("# Version Upgrades\n \n " );
342332 if (!majorVersionBumpVersionlessCoordinates .isEmpty ()) {
@@ -429,27 +419,17 @@ void reportClientLibraryVersionDifference(
429419 libraryName = artifactId .replace ("google-" , "" );
430420 }
431421
432- List <String > links = new ArrayList <>();
422+ String releaseUrl = releaseUrlForMonorepo (libraryName , googleCloudJavaVersion );
423+ ImmutableList .Builder <String > links = ImmutableList .builder ();
433424 for (String versionForReleaseNotes : versionsForReleaseNotes ) {
434- String [] versionAndQualifier = versionForReleaseNotes .split ("-" );
435- String version = versionAndQualifier [0 ];
436- String releaseUrl =
437- splitRepositoryLibraryNames .contains (libraryName )
438- ? releaseUrlForSplitRepo (libraryName , version )
439- : releaseUrlForMonorepo (libraryName , googleCloudJavaVersion );
440425 links .add (String .format ("[v%s](%s)" , versionForReleaseNotes , releaseUrl ));
441426 }
442- line .append (Joiner .on (", " ).join (links )).append (")" );
427+ line .append (Joiner .on (", " ).join (links . build () )).append (")" );
443428
444429 report .append (line ).append ("\n " );
445430 }
446431 }
447432
448- private static String releaseUrlForSplitRepo (String libraryName , String version ) {
449- return String .format (
450- "https://github.com/googleapis/java-%s/releases/tag/v%s" , libraryName , version );
451- }
452-
453433 private String releaseUrlForMonorepo (String libraryName , String version ) {
454434 if (monorepoReleaseExists ) {
455435 return String .format (
@@ -531,59 +511,8 @@ static boolean isPatchVersionBump(String previousVersion, String currentVersion)
531511 * in between the two versions, not including the old version.
532512 */
533513 @ VisibleForTesting
534- void reportClientLibrariesNotableChangeLogs (
535- Iterable <String > artifactsInBothBoms ,
536- Map <String , String > versionlessCoordinatesToVersionOld ,
537- Map <String , String > versionlessCoordinatesToVersionNew ,
538- String googleCloudJavaVersion )
514+ void reportClientLibrariesNotableChangeLogs (String googleCloudJavaVersion )
539515 throws IOException , InterruptedException {
540-
541- ImmutableList <String > sortedVersionlessCoordinates =
542- Streams .stream (artifactsInBothBoms ).sorted ().collect (toImmutableList ());
543-
544- for (String versionlessCoordinates : sortedVersionlessCoordinates ) {
545- List <String > coordinates = Splitter .on (":" ).splitToList (versionlessCoordinates );
546- String artifactId = coordinates .get (1 );
547- String previousVersion = versionlessCoordinatesToVersionOld .get (versionlessCoordinates );
548- String currentVersion = versionlessCoordinatesToVersionNew .get (versionlessCoordinates );
549- Optional <String > matchingSplitRepoName =
550- splitRepositoryLibraryNames .stream ()
551- .map (libraryName -> artifactId .endsWith (libraryName ) ? "java-" + libraryName : null )
552- .filter (Objects ::nonNull )
553- .findFirst ();
554- matchingSplitRepoName .ifPresent (
555- splitRepoName -> {
556- try {
557- ImmutableList <String > versionsForReleaseNotes =
558- clientLibraryReleaseNoteVersions (
559- versionlessCoordinates , previousVersion , currentVersion );
560- String changelog =
561- fetchClientLibraryNotableChangeLog (splitRepoName , versionsForReleaseNotes );
562- if (!changelog .isEmpty ()) {
563- // Only print library name when there are notable changes
564- report
565- .append ("## " )
566- .append (artifactId )
567- .append (" " )
568- .append (currentVersion )
569- .append (" (prev: " )
570- .append (previousVersion )
571- .append (")" );
572- report .append (changelog ).append ("\n " );
573- }
574- } catch (MavenRepositoryException | IOException | InterruptedException ex ) {
575- throw new VerifyException (
576- "Couldn't write notable changelog for "
577- + versionlessCoordinates
578- + "'s versions between "
579- + previousVersion
580- + " and "
581- + currentVersion ,
582- ex );
583- }
584- });
585- }
586-
587516 report .append ("## Other libraries\n \n " );
588517 String changelog =
589518 fetchClientLibraryNotableChangeLog (
0 commit comments