@@ -278,6 +278,85 @@ class DisableViewBindingTest : RunnerTest() {
278278 logger.parsedReport() shouldBe listOf ()
279279 }
280280
281+ @Test
282+ fun `ViewBinding from debug & release is used in main source set` () {
283+
284+ val lib1 = androidLibrary(" :lib1" , " com.modulecheck.lib1" ) {
285+ buildFile {
286+ """
287+ plugins {
288+ id("com.android.library")
289+ kotlin("android")
290+ }
291+
292+ android {
293+ buildFeatures.viewBinding = true
294+ }
295+ """
296+ }
297+ addLayoutFile(
298+ " fragment_lib1.xml" ,
299+ """ <?xml version="1.0" encoding="utf-8"?>
300+ <androidx.constraintlayout.widget.ConstraintLayout
301+ xmlns:android="https://schemas.android.com/apk/res/android"
302+ android:id="@+id/fragment_container"
303+ android:layout_width="match_parent"
304+ android:layout_height="match_parent"
305+ />
306+ """ ,
307+ SourceSetName .DEBUG
308+ )
309+ addLayoutFile(
310+ " fragment_lib1.xml" ,
311+ """ <?xml version="1.0" encoding="utf-8"?>
312+ <androidx.constraintlayout.widget.ConstraintLayout
313+ xmlns:android="https://schemas.android.com/apk/res/android"
314+ android:id="@+id/fragment_container"
315+ android:layout_width="match_parent"
316+ android:layout_height="match_parent">
317+
318+ <!-- Slightly different XML layout for release-->
319+ </androidx.constraintlayout.widget.ConstraintLayout>
320+ """ ,
321+ SourceSetName .RELEASE
322+ )
323+
324+ // Setting a debug base package, but it's never used. The inferred FqName for the generated
325+ // binding should still reflect the main source set even though it's evaluating a file in
326+ // debug.
327+ platformPlugin.manifests[SourceSetName .DEBUG ] = projectDir
328+ .child(" src/debug/AndroidManifest.xml" )
329+ .createSafely(" <manifest package=\" com.modulecheck.lib1.debug\" />" )
330+
331+ addKotlinSource(
332+ """
333+ package com.modulecheck.lib1
334+
335+ import com.modulecheck.lib1.databinding.FragmentLib1Binding
336+
337+ val binding = FragmentLib1Binding()
338+ """
339+ )
340+ }
341+
342+ run (
343+ autoCorrect = false
344+ ).isSuccess shouldBe true
345+
346+ lib1.buildFile shouldHaveText """
347+ plugins {
348+ id("com.android.library")
349+ kotlin("android")
350+ }
351+
352+ android {
353+ buildFeatures.viewBinding = true
354+ }
355+ """
356+
357+ logger.parsedReport() shouldBe listOf ()
358+ }
359+
281360 @Test
282361 fun `ViewBinding from debug with different base package is used in debug source set` () {
283362
0 commit comments