File tree Expand file tree Collapse file tree 5 files changed +24
-28
lines changed
plugins/src/main/java/com/google/firebase/gradle/plugins Expand file tree Collapse file tree 5 files changed +24
-28
lines changed Original file line number Diff line number Diff line change 1111 permissions :
1212 pull-requests : write
1313 steps :
14- - name : Checkout PR
14+ - name : Checkout main
1515 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
16+ with :
17+ ref : ${{ github.base_ref }}
1618
1719 - name : Set up JDK 17
1820 uses : actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
@@ -21,13 +23,13 @@ jobs:
2123 distribution : temurin
2224 cache : gradle
2325
24- - name : Copy new api.txt files
26+ - name : Copy existing api.txt files
2527 run : ./gradlew copyApiTxtFile
2628
27- - name : Checkout main
29+ - name : Checkout PR
2830 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2931 with :
30- ref : ${{ github.base_ref }}
32+ ref : ${{ github.head_ref || github.ref_name }}
3133 clean : false
3234
3335 - name : Run Metalava SemVer check
Original file line number Diff line number Diff line change @@ -126,6 +126,20 @@ abstract class BaseFirebaseLibraryPlugin : Plugin<Project> {
126126 Coverage .apply (library)
127127 }
128128
129+ protected fun setupMetalavaSemver (project : Project , library : FirebaseLibraryExtension ) {
130+ project.tasks.register<CopyApiTask >(" copyApiTxtFile" ) {
131+ apiTxtFile.set(project.file(" api.txt" ))
132+ output.set(project.file(" existing_api.txt" ))
133+ }
134+
135+ project.tasks.register<SemVerTask >(" metalavaSemver" ) {
136+ apiTxtFile.set(project.file(" api.txt" ))
137+ existingApiFile.set(project.file(" existing_api.txt" ))
138+ currentVersionString.value(library.version)
139+ previousVersionString.value(library.previousVersion)
140+ }
141+ }
142+
129143 protected fun getApiInfo (
130144 project : Project ,
131145 srcDirs : ConfigurableFileCollection ,
Original file line number Diff line number Diff line change @@ -161,17 +161,7 @@ class FirebaseAndroidLibraryPlugin : BaseFirebaseLibraryPlugin() {
161161 )
162162 }
163163
164- project.tasks.register<CopyApiTask >(" copyApiTxtFile" ) {
165- apiTxtFile.set(project.file(" api.txt" ))
166- output.set(project.file(" new_api.txt" ))
167- }
168-
169- project.tasks.register<SemVerTask >(" metalavaSemver" ) {
170- apiTxtFile.set(project.file(" new_api.txt" ))
171- otherApiFile.set(project.file(" api.txt" ))
172- currentVersionString.value(firebaseLibrary.version)
173- previousVersionString.value(firebaseLibrary.previousVersion)
174- }
164+ setupMetalavaSemver(project, firebaseLibrary)
175165 }
176166
177167 private fun setupApiInformationAnalysis (project : Project , android : LibraryExtension ) {
Original file line number Diff line number Diff line change @@ -104,17 +104,7 @@ class FirebaseJavaLibraryPlugin : BaseFirebaseLibraryPlugin() {
104104 dependsOn(" copyPreviousArtifacts" )
105105 }
106106
107- project.tasks.register<CopyApiTask >(" copyApiTxtFile" ) {
108- apiTxtFile.set(project.file(" api.txt" ))
109- output.set(project.file(" new_api.txt" ))
110- }
111-
112- project.tasks.register<SemVerTask >(" metalavaSemver" ) {
113- apiTxtFile.set(project.file(" new_api.txt" ))
114- otherApiFile.set(project.file(" api.txt" ))
115- currentVersionString.value(firebaseLibrary.version)
116- previousVersionString.value(firebaseLibrary.previousVersion)
117- }
107+ setupMetalavaSemver(project, firebaseLibrary)
118108 }
119109
120110 private fun setupApiInformationAnalysis (project : Project ) {
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ import org.gradle.process.ExecOperations
3131abstract class SemVerTask @Inject constructor(private val execOperations : ExecOperations ) :
3232 DefaultTask () {
3333 @get:InputFile abstract val apiTxtFile: RegularFileProperty
34- @get:InputFile abstract val otherApiFile : RegularFileProperty
34+ @get:InputFile abstract val existingApiFile : RegularFileProperty
3535 @get:Input abstract val currentVersionString: Property <String >
3636 @get:Input abstract val previousVersionString: Property <String >
3737
@@ -55,7 +55,7 @@ abstract class SemVerTask @Inject constructor(private val execOperations: ExecOp
5555 " --source-files" ,
5656 apiTxtFile.get().asFile.absolutePath,
5757 " --check-compatibility:api:released" ,
58- otherApiFile .get().asFile.absolutePath,
58+ existingApiFile .get().asFile.absolutePath,
5959 ) +
6060 MAJOR .flatMap { m -> listOf (" --error" , m) } +
6161 MINOR .flatMap { m -> listOf (" --error" , m) } +
You can’t perform that action at this time.
0 commit comments