/*
 * Copyright (C) 2017 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.
 */

ext.supportRootFolder = new File("../../../..")
apply from: "$supportRootFolder/buildSrc/repos.gradle"
repos.addMavenRepositories(repositories)

ext.runningInBuildServer = System.env.DIST_DIR != null && System.env.OUT_DIR != null
ext.repoDir = runningInBuildServer ? new File(System.env.OUT_DIR + '/gradle/frameworks/support/build') :
        new File("$supportRootFolder/../../out/host/gradle/frameworks/support/build")

task createArchive(type: Exec) {
    inputs.files(fileTree(dir: "$supportRootFolder/navigation",
            includes: ['**/*.java', '**/*.kt'], exclude: 'integration-tests/*'))
    outputs.dir(repoDir)
    workingDir "$supportRootFolder/app-toolkit/"
    commandLine "./gradlew", "createArchive"
}

task unzip(type: Copy, dependsOn: createArchive) {
    from "$repoDir/support_repo"
    into "../build/localMaven/"
}

apply plugin: 'java'
dependencies {
    compile project(":moar-buildSrc")
}

tasks["build"].dependsOn unzip