/*
 * Copyright 2018 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.
 */

/**
 * This file was created using the `create_project.py` script located in the
 * `<AndroidX root>/development/project-creator` directory.
 *
 * Please use that script when creating a new project, rather than copying an existing project and
 * modifying its settings.
 */
import androidx.build.ExportAtomicLibraryGroupsToTextTask
import androidx.build.SoftwareType

plugins {
    id("AndroidXPlugin")
    id("kotlin")
}

sourceSets {
    // Pull integration test source code in for use by lint testing framework.
    test.resources.srcDirs(layout.projectDirectory.dir("integration-tests/src/main"))
}

dependencies {
    compileOnly(libs.androidLintApi)
    compileOnly(libs.androidLintChecks)
    compileOnly(libs.androidToolsCommon)
    compileOnly(libs.intellijCore)
    compileOnly(libs.intellijKotlinCompiler)
    compileOnly(libs.kotlinStdlib)
    compileOnly(libs.lintModel)
    compileOnly(libs.sdklib)
    compileOnly(libs.uast)

    testImplementation(libs.androidLint)
    testImplementation(libs.androidLintTests)
    testImplementation(libs.junit)
    testImplementation(libs.guava)
}

androidx {
    name = "Lint checks"
    type = SoftwareType.LINT
    inceptionYear = "2018"
    description = "Internal lint checks"
}

def exportTaskProvider = tasks.register(
        "exportAtomicLibraryGroupsToText",
        ExportAtomicLibraryGroupsToTextTask
) { task ->
    task.libraryGroups = androidx.AllLibraryGroups
    task.outputDir.set(layout.buildDirectory.dir("generated/resources"))
}

def extension = project.extensions.getByType(JavaPluginExtension.class)
def mainSources = extension.sourceSets.getByName("main")
mainSources.getOutput().dir(exportTaskProvider.flatMap { it.outputDir })
