/*
 * Copyright 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.build.resources

import com.android.build.gradle.LibraryExtension
import org.gradle.api.Project
import java.io.File

fun Project.configurePublicResourcesStub(extension: LibraryExtension) {
    extension.libraryVariants.all { variant ->
        variant.registerGeneratedResFolders(
            project.files(
                File(project.rootDir, "/buildSrc/res")
            )
        )
    }
}

/*
 * Copyright 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.build.resources

import androidx.build.getSupportRootFolder
import com.android.build.gradle.LibraryExtension
import org.gradle.api.Project
import java.io.File

fun Project.configurePublicResourcesStub(extension: LibraryExtension) {
    extension.libraryVariants.all { variant ->
        variant.registerGeneratedResFolders(
            project.files(
                File(project.getSupportRootFolder(), "/buildSrc/res")
            )
        )
    }
}

Make publicResourcesStub registration compatible with playground
Make publicResourcesStub registration compatible with playground

The root project dir for playground projects is one level after root
checkout, so to support both we need to use supportRootFolder instead of
root project dir when creating a path to the stub public resources

Fixes: 177896088
Test: cd biometric && ./gradlew bOS
Change-Id: Ic37510c2b117beec07698440be0e8580965c4135

AndroidX/androidx,androidx/androidx,androidx/androidx,androidx/androidx,AndroidX/androidx,androidx/androidx,AndroidX/androidx,androidx/androidx,AndroidX/androidx,AndroidX/androidx,androidx/androidx,AndroidX/androidx,AndroidX/androidx,AndroidX/androidx,androidx/androidx,androidx/androidx,AndroidX/androidx,androidx/androidx,AndroidX/androidx,androidx/androidx