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 11
11
permissions :
12
12
pull-requests : write
13
13
steps :
14
- - name : Checkout PR
14
+ - name : Checkout main
15
15
uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
16
+ with :
17
+ ref : ${{ github.base_ref }}
16
18
17
19
- name : Set up JDK 17
18
20
uses : actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
@@ -21,13 +23,13 @@ jobs:
21
23
distribution : temurin
22
24
cache : gradle
23
25
24
- - name : Copy new api.txt files
26
+ - name : Copy existing api.txt files
25
27
run : ./gradlew copyApiTxtFile
26
28
27
- - name : Checkout main
29
+ - name : Checkout PR
28
30
uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
29
31
with :
30
- ref : ${{ github.base_ref }}
32
+ ref : ${{ github.head_ref || github.ref_name }}
31
33
clean : false
32
34
33
35
- name : Run Metalava SemVer check
Original file line number Diff line number Diff line change @@ -126,6 +126,20 @@ abstract class BaseFirebaseLibraryPlugin : Plugin<Project> {
126
126
Coverage .apply (library)
127
127
}
128
128
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
+
129
143
protected fun getApiInfo (
130
144
project : Project ,
131
145
srcDirs : ConfigurableFileCollection ,
Original file line number Diff line number Diff line change @@ -161,17 +161,7 @@ class FirebaseAndroidLibraryPlugin : BaseFirebaseLibraryPlugin() {
161
161
)
162
162
}
163
163
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)
175
165
}
176
166
177
167
private fun setupApiInformationAnalysis (project : Project , android : LibraryExtension ) {
Original file line number Diff line number Diff line change @@ -104,17 +104,7 @@ class FirebaseJavaLibraryPlugin : BaseFirebaseLibraryPlugin() {
104
104
dependsOn(" copyPreviousArtifacts" )
105
105
}
106
106
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)
118
108
}
119
109
120
110
private fun setupApiInformationAnalysis (project : Project ) {
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ import org.gradle.process.ExecOperations
31
31
abstract class SemVerTask @Inject constructor(private val execOperations : ExecOperations ) :
32
32
DefaultTask () {
33
33
@get:InputFile abstract val apiTxtFile: RegularFileProperty
34
- @get:InputFile abstract val otherApiFile : RegularFileProperty
34
+ @get:InputFile abstract val existingApiFile : RegularFileProperty
35
35
@get:Input abstract val currentVersionString: Property <String >
36
36
@get:Input abstract val previousVersionString: Property <String >
37
37
@@ -55,7 +55,7 @@ abstract class SemVerTask @Inject constructor(private val execOperations: ExecOp
55
55
" --source-files" ,
56
56
apiTxtFile.get().asFile.absolutePath,
57
57
" --check-compatibility:api:released" ,
58
- otherApiFile .get().asFile.absolutePath,
58
+ existingApiFile .get().asFile.absolutePath,
59
59
) +
60
60
MAJOR .flatMap { m -> listOf (" --error" , m) } +
61
61
MINOR .flatMap { m -> listOf (" --error" , m) } +
You can’t perform that action at this time.
0 commit comments