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 ;
3733import java .io .File ;
3834import java .io .IOException ;
3935import java .nio .charset .StandardCharsets ;
4036import java .util .ArrayList ;
4137import java .util .HashMap ;
4238import java .util .List ;
4339import java .util .Map ;
44- import java .util .Objects ;
45- import java .util .Optional ;
4640import java .util .concurrent .TimeUnit ;
4741import java .util .regex .Matcher ;
4842import java .util .regex .Pattern ;
@@ -61,8 +55,6 @@ public class ReleaseNoteGeneration {
6155 private static final String RELEASE_NOTE_FILE_NAME = "release_note.md" ;
6256 private static final String GOOGLEAPIS_ORG = "googleapis" ;
6357
64- private static final ImmutableSet <String > splitRepositoryLibraryNames = ImmutableSet .of ();
65-
6658 private static boolean clientLibraryFilter (String coordinates ) {
6759 if (coordinates .contains ("google-cloud-core" )) {
6860 // Google Cloud Core is reported in core Google library section as this is not meant to be
@@ -332,11 +324,7 @@ private void reportCloudClientBomDifference(Bom oldBom, Bom newBom, String googl
332324 }
333325
334326 report .append ("# Notable Changes\n \n " );
335- reportClientLibrariesNotableChangeLogs (
336- minorVersionBumpVersionlessCoordinates ,
337- versionlessCoordinatesToVersionOld ,
338- versionlessCoordinatesToVersionNew ,
339- googleCloudJavaVersion );
327+ reportClientLibrariesNotableChangeLogs (googleCloudJavaVersion );
340328
341329 report .append ("# Version Upgrades\n \n " );
342330 if (!majorVersionBumpVersionlessCoordinates .isEmpty ()) {
@@ -429,27 +417,17 @@ void reportClientLibraryVersionDifference(
429417 libraryName = artifactId .replace ("google-" , "" );
430418 }
431419
432- List <String > links = new ArrayList <>();
420+ String releaseUrl = releaseUrlForMonorepo (libraryName , googleCloudJavaVersion );
421+ ImmutableList .Builder <String > links = ImmutableList .builder ();
433422 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 );
440423 links .add (String .format ("[v%s](%s)" , versionForReleaseNotes , releaseUrl ));
441424 }
442- line .append (Joiner .on (", " ).join (links )).append (")" );
425+ line .append (Joiner .on (", " ).join (links . build () )).append (")" );
443426
444427 report .append (line ).append ("\n " );
445428 }
446429 }
447430
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-
453431 private String releaseUrlForMonorepo (String libraryName , String version ) {
454432 if (monorepoReleaseExists ) {
455433 return String .format (
@@ -531,59 +509,8 @@ static boolean isPatchVersionBump(String previousVersion, String currentVersion)
531509 * in between the two versions, not including the old version.
532510 */
533511 @ VisibleForTesting
534- void reportClientLibrariesNotableChangeLogs (
535- Iterable <String > artifactsInBothBoms ,
536- Map <String , String > versionlessCoordinatesToVersionOld ,
537- Map <String , String > versionlessCoordinatesToVersionNew ,
538- String googleCloudJavaVersion )
512+ void reportClientLibrariesNotableChangeLogs (String googleCloudJavaVersion )
539513 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-
587514 report .append ("## Other libraries\n \n " );
588515 String changelog =
589516 fetchClientLibraryNotableChangeLog (
0 commit comments