Skip to content

Commit cad0339

Browse files
authored
Implement centralized config for Release Note generation (#6099)
Per [b/352342089](https://b.corp.google.com/issues/352342089), This implements a new extension through `FirebaseLibrary` called `ReleaseNotesConfigurationExtension`. This can be configured through the `releaseNotes` helper method that takes an `Action` argument; similar to what we do with `FirebaseTestLabExtension` and `FirebaseStaticAnalysis`. The goal of this move is to not only allow teams to modify their release notes metadata, but provide an obvious indicator of release note configuration that must be changed to properly generate release notes. This way, we avoid accidentally _not_ generating release notes for libraries that should otherwise have them. Furthermore, this opens the door for exposing more release note configurations to product teams (such as `annotationsNotToDisplay`, `suppressedFiles`, `includedHeadTagsPath`, `package-list` mappings, etc.,). NO_RELEASE_CHANGE
1 parent f23f6f1 commit cad0339

File tree

63 files changed

+288
-126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+288
-126
lines changed

appcheck/firebase-appcheck-debug-testing/firebase-appcheck-debug-testing.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ firebaseLibrary {
2121
libraryGroup "appcheck"
2222
testLab.enabled = true
2323
publishSources = true
24+
releaseNotes {
25+
name.set("{{app_check}} Debug Testing")
26+
versionName.set("appcheck-debug-testing")
27+
hasKTX.set(false)
28+
}
2429
}
2530

2631
android {

appcheck/firebase-appcheck-debug/firebase-appcheck-debug.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ plugins {
1919
firebaseLibrary {
2020
libraryGroup "appcheck"
2121
publishSources = true
22+
releaseNotes {
23+
name.set("{{app_check}} Debug")
24+
versionName.set("appcheck-debug")
25+
hasKTX.set(false)
26+
}
2227
}
2328

2429
android {

appcheck/firebase-appcheck-interop/firebase-appcheck-interop.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ plugins {
1919
firebaseLibrary {
2020
publishSources = true
2121
publishJavadoc = false
22-
publishReleaseNotes = false
22+
releaseNotes {
23+
enabled.set(false)
24+
}
2325
}
2426

2527
android {

appcheck/firebase-appcheck-playintegrity/firebase-appcheck-playintegrity.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ plugins {
1919
firebaseLibrary {
2020
libraryGroup "appcheck"
2121
publishSources = true
22+
releaseNotes {
23+
name.set("{{app_check}} Play integrity")
24+
versionName.set("appcheck-playintegrity")
25+
hasKTX.set(false)
26+
}
2227
}
2328

2429
android {

appcheck/firebase-appcheck/firebase-appcheck.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ plugins {
2020
firebaseLibrary {
2121
libraryGroup "appcheck"
2222
publishSources = true
23+
releaseNotes {
24+
name.set("{{app_check}}")
25+
versionName.set("appcheck")
26+
}
2327
}
2428

2529
android {

appcheck/firebase-appcheck/ktx/ktx.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ firebaseLibrary {
2121
libraryGroup "appcheck"
2222
testLab.enabled = true
2323
publishJavadoc = false
24-
publishReleaseNotes = false
24+
releaseNotes {
25+
enabled.set(false)
26+
}
2527
publishSources = true
2628
}
2729

buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseLibraryExtension.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ public class FirebaseLibraryExtension {
3737
/** Indicates whether the library has public javadoc. */
3838
public boolean publishJavadoc = true;
3939

40-
/** Indicates whether release notes are published for the library. */
41-
public boolean publishReleaseNotes = true;
42-
4340
/** Indicates whether sources are published alongside the library. */
4441
public boolean publishSources;
4542

@@ -54,6 +51,9 @@ public class FirebaseLibraryExtension {
5451
/** Firebase Test Lab configuration/ */
5552
public final FirebaseTestLabExtension testLab;
5653

54+
/** Release notes configuration. */
55+
public final ReleaseNotesConfigurationExtension releaseNotes;
56+
5757
public Property<String> groupId;
5858
public Property<String> artifactId;
5959

@@ -83,6 +83,10 @@ public FirebaseLibraryExtension(Project project, LibraryType type) {
8383
this.testLab = new FirebaseTestLabExtension(project.getObjects());
8484
this.artifactId = project.getObjects().property(String.class);
8585
this.groupId = project.getObjects().property(String.class);
86+
this.releaseNotes = project.getExtensions().create("releaseNotes", ReleaseNotesConfigurationExtension.class);
87+
this.releaseNotes.getEnabled().convention(true);
88+
this.releaseNotes.getHasKTX().convention(true);
89+
this.releaseNotes.getArtifactName().convention(project.getName());
8690

8791
if ("ktx".equals(project.getName()) && project.getParent() != null) {
8892
artifactId.set(new DefaultProvider<>(() -> project.getParent().getName() + "-ktx"));
@@ -127,6 +131,10 @@ public void customizePom(Action<MavenPom> action) {
127131
customizePomAction = action;
128132
}
129133

134+
public void releaseNotes(Action<ReleaseNotesConfigurationExtension> action) {
135+
action.execute(releaseNotes);
136+
}
137+
130138
public void applyPomCustomization(MavenPom pom) {
131139
if (customizePomAction != null) {
132140
customizePomAction.execute(pom);

buildSrc/src/main/java/com/google/firebase/gradle/plugins/MakeReleaseNotesTask.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,17 @@ abstract class MakeReleaseNotesTask : DefaultTask() {
8282
* updates.
8383
* ```
8484
*
85-
* @see convertToMetadata
85+
* @see ReleaseNotesConfigurationExtension
8686
*/
8787
@TaskAction
8888
fun make() {
8989
val changelog = Changelog.fromFile(changelogFile.asFile.get())
90-
val metadata = convertToMetadata(project.name)
90+
val config = project.firebaseLibrary.releaseNotes
9191
val unreleased = changelog.releases.first()
9292
val version = project.version.toString()
9393
val skipMissing = skipMissingEntries.getOrElse(false)
9494

95-
if (!project.firebaseLibrary.publishReleaseNotes)
95+
if (!config.enabled.get())
9696
throw StopActionException("No release notes required for ${project.name}")
9797

9898
if (!unreleased.hasContent()) {
@@ -108,7 +108,7 @@ abstract class MakeReleaseNotesTask : DefaultTask() {
108108

109109
val baseReleaseNotes =
110110
"""
111-
|### ${metadata.name} version $version {: #${metadata.versionName}_v$versionClassifier}
111+
|### ${config.name.get()} version $version {: #${config.versionName.get()}_v$versionClassifier}
112112
|
113113
|${unreleased.content.toReleaseNotes()}
114114
"""
@@ -117,13 +117,13 @@ abstract class MakeReleaseNotesTask : DefaultTask() {
117117

118118
val ktxReleaseNotes =
119119
"""
120-
|#### ${metadata.name} Kotlin extensions version $version {: #${metadata.versionName}-ktx_v$versionClassifier}
120+
|#### ${config.name.get()} Kotlin extensions version $version {: #${config.versionName.get()}-ktx_v$versionClassifier}
121121
|
122122
|${unreleased.ktx?.toReleaseNotes() ?: KTXTransitiveReleaseText(project.name)}
123123
"""
124124
.trimMargin()
125125
.trim()
126-
.takeIf { metadata.hasKTX }
126+
.takeIf { config.hasKTX.get() }
127127

128128
val releaseNotes =
129129
"""

buildSrc/src/main/java/com/google/firebase/gradle/plugins/MoveUnreleasedChangesTask.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,22 @@ abstract class MoveUnreleasedChangesTask : DefaultTask() {
8787
* Ensures the entry is only created if the library has a KTX lib to begin with, and adds template
8888
* subtext if it lacks any changes.
8989
*
90-
* @see convertToMetadata
90+
* @see ReleaseNotesConfigurationExtension
9191
* @see KTXTransitiveReleaseText
9292
*/
9393
private fun createEntryForKTX(release: ReleaseEntry): ReleaseContent? {
94-
val metadata = convertToMetadata(project.name)
94+
val releaseNotesConfig = project.firebaseLibrary.releaseNotes
9595

9696
val nonEmptyKTXContent = release.ktx?.takeIf { it.hasContent() }
9797

9898
val ktxContent =
99-
nonEmptyKTXContent ?: ReleaseContent(KTXTransitiveReleaseText(project.name), emptyList())
99+
nonEmptyKTXContent
100+
?: ReleaseContent(
101+
KTXTransitiveReleaseText(releaseNotesConfig.artifactName.get()),
102+
emptyList()
103+
)
100104

101-
return ktxContent.takeIf { metadata.hasKTX }
105+
return ktxContent.takeIf { releaseNotesConfig.hasKTX.get() }
102106
}
103107

104108
private fun configure() {
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.firebase.gradle.plugins
18+
19+
import org.gradle.api.provider.Property
20+
21+
/**
22+
* Configuration options for release note generation of libraries.
23+
*
24+
* Also facilitates the centralization of certain externally defined data (usually defined on G3).
25+
* As we can't link G3 files on GitHub, if you're setting up a new SDK and are unsure what release
26+
* note mappings your SDK has (or will have) ask Rachel or the ACore team for the relevant variable
27+
* mappings.
28+
*
29+
* @property enabled Whether to generate release notes for this library. Defaults to true.
30+
*
31+
* @property name The variable name mapping for this library, defined on G3.
32+
*
33+
* @property versionName The version name mapping for this library, defined on G3.
34+
*
35+
* @property hasKTX The library has a sub module with the suffix '-ktx' that releases alongside this
36+
* library, and should have the transitive text added to the release notes. Defaults to true. Will
37+
* likely be removed when we officially drop KTX libraries.
38+
*
39+
* @property artifactName The name of the generation artifact. _Only_ required if your project's
40+
* name is different than your generated artifact name. Defaults to the project name.
41+
*
42+
* @see MakeReleaseNotesTask
43+
*/
44+
abstract class ReleaseNotesConfigurationExtension {
45+
abstract val enabled: Property<Boolean>
46+
abstract val name: Property<String>
47+
abstract val versionName: Property<String>
48+
abstract val hasKTX: Property<Boolean>
49+
abstract val artifactName: Property<String>
50+
}

0 commit comments

Comments
 (0)