Skip to content

Resolve metalava semver using outdated version info #7159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/metalava-semver-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ jobs:
permissions:
pull-requests: write
steps:
- name: Checkout PR
- name: Checkout main
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.base_ref }}

- name: Set up JDK 17
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
Expand All @@ -21,13 +23,13 @@ jobs:
distribution: temurin
cache: gradle

- name: Copy new api.txt files
- name: Copy existing api.txt files
run: ./gradlew copyApiTxtFile

- name: Checkout main
- name: Checkout PR
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.base_ref }}
ref: ${{ github.head_ref || github.ref_name }}
clean: false

- name: Run Metalava SemVer check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@ abstract class BaseFirebaseLibraryPlugin : Plugin<Project> {
Coverage.apply(library)
}

protected fun setupMetalavaSemver(project: Project, library: FirebaseLibraryExtension) {
project.tasks.register<CopyApiTask>("copyApiTxtFile") {
apiTxtFile.set(project.file("api.txt"))
output.set(project.file("existing_api.txt"))
}

project.tasks.register<SemVerTask>("metalavaSemver") {
apiTxtFile.set(project.file("api.txt"))
existingApiFile.set(project.file("existing_api.txt"))
currentVersionString.value(library.version)
previousVersionString.value(library.previousVersion)
}
}

protected fun getApiInfo(
project: Project,
srcDirs: ConfigurableFileCollection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,7 @@ class FirebaseAndroidLibraryPlugin : BaseFirebaseLibraryPlugin() {
)
}

project.tasks.register<CopyApiTask>("copyApiTxtFile") {
apiTxtFile.set(project.file("api.txt"))
output.set(project.file("new_api.txt"))
}

project.tasks.register<SemVerTask>("metalavaSemver") {
apiTxtFile.set(project.file("new_api.txt"))
otherApiFile.set(project.file("api.txt"))
currentVersionString.value(firebaseLibrary.version)
previousVersionString.value(firebaseLibrary.previousVersion)
}
setupMetalavaSemver(project, firebaseLibrary)
}

private fun setupApiInformationAnalysis(project: Project, android: LibraryExtension) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,7 @@ class FirebaseJavaLibraryPlugin : BaseFirebaseLibraryPlugin() {
dependsOn("copyPreviousArtifacts")
}

project.tasks.register<CopyApiTask>("copyApiTxtFile") {
apiTxtFile.set(project.file("api.txt"))
output.set(project.file("new_api.txt"))
}

project.tasks.register<SemVerTask>("metalavaSemver") {
apiTxtFile.set(project.file("new_api.txt"))
otherApiFile.set(project.file("api.txt"))
currentVersionString.value(firebaseLibrary.version)
previousVersionString.value(firebaseLibrary.previousVersion)
}
setupMetalavaSemver(project, firebaseLibrary)
}

private fun setupApiInformationAnalysis(project: Project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import org.gradle.api.tasks.TaskAction

abstract class SemVerTask : DefaultTask() {
@get:InputFile abstract val apiTxtFile: RegularFileProperty
@get:InputFile abstract val otherApiFile: RegularFileProperty
@get:InputFile abstract val existingApiFile: RegularFileProperty
@get:Input abstract val currentVersionString: Property<String>
@get:Input abstract val previousVersionString: Property<String>

Expand All @@ -51,7 +51,7 @@ abstract class SemVerTask : DefaultTask() {
"--source-files",
apiTxtFile.get().asFile.absolutePath,
"--check-compatibility:api:released",
otherApiFile.get().asFile.absolutePath,
existingApiFile.get().asFile.absolutePath,
) +
MAJOR.flatMap { m -> listOf("--error", m) } +
MINOR.flatMap { m -> listOf("--error", m) } +
Expand Down
Loading