Merge "Stop splitting support lib into modules in Android Studio." into nyc-support-25.1-dev
diff --git a/build.gradle b/build.gradle
index 7236469..ab8272a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -31,6 +31,7 @@
     doclava project(':doclava')
 }
 
+gradle.ext.currentSdk = 'current'
 ext.supportVersion = '25.1.0-SNAPSHOT'
 ext.extraVersion = 40
 ext.supportRepoOut = ''
@@ -105,7 +106,6 @@
 }
 
 
-import android.support.build.ApiModule
 import com.google.common.io.Files
 import com.google.common.base.Charsets
 
diff --git a/buildSrc/apiModule.gradle b/buildSrc/apiModule.gradle
deleted file mode 100644
index b3186b7..0000000
--- a/buildSrc/apiModule.gradle
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2016 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.
- */
-
-/**
- * Generic build.gradle file that can be used for API specific support lib implementations.
- * This file is used only if Android Studio opens the project.
- */
-apply plugin: 'com.android.library'
-def apiModule = gradle.ext.getApiModule(project)
-logger.info ("apiModule for ${project.projectDir} is $apiModule. "
-        + "compileSDK: ${apiModule.apiForSourceSet} minSDK: ${apiModule.api}")
-android {
-    compileSdkVersion apiModule.apiForSourceSet
-    // these api modules all use the same package name so we should not package their BuildConfig
-    // files.
-    packageBuildConfig false
-
-    sourceSets {
-        main.manifest.srcFile '../AndroidManifest.xml'
-        main.java.srcDirs = ['.']
-        main.res.srcDirs = []
-        apiModule.resourceFolders.each {
-            main.res.srcDirs += "../$it"
-        }
-        main.assets.srcDirs = []
-        apiModule.assetFolders.each {
-            main.assets.srcDirs += "../$it"
-        }
-        main.resources.srcDirs = []
-        apiModule.javaResourceFolders.each {
-            main.resources.srcDirs += "../$it"
-        }
-    }
-
-    lintOptions {
-        abortOnError false
-    }
-
-    compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_7
-        targetCompatibility JavaVersion.VERSION_1_7
-    }
-
-    enforceUniquePackageName = false
-}
-
-
-dependencies {
-    if (apiModule.prev != null) {
-        compile project(apiModule.prev.moduleName)
-    } else {
-        apiModule.parentModuleDependencies.each { dep ->
-            compile project(dep)
-        }
-    }
-}
diff --git a/buildSrc/src/main/java/android/support/build/ApiModule.java b/buildSrc/src/main/java/android/support/build/ApiModule.java
deleted file mode 100644
index 4b73f94..0000000
--- a/buildSrc/src/main/java/android/support/build/ApiModule.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2016 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 android.support.build;
-
-import org.gradle.api.tasks.SourceSet;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Defines an API specific support library modules.
- * e.g. Honeycomb implementation of Support-v4.
- *
- * These ApiModules are converted into real modules when project is opened in AndroidStudio.
- * When project is run from the command line, they are converted into source sets.
- * This allows us to rely on previous compile setup to deploy projects with their dependencies while
- * supporting development on Android Studio.
- */
-public class ApiModule {
-    public static final int CURRENT = 99;
-    private String mFolderName;
-    private int mApi;
-    private SourceSet mSourceSet;
-    private ApiModule mPrev;
-    private String mParentModuleName;
-    private List<String> mParentModuleDependencies;
-    private List<String> mResourceFolders = new ArrayList<>();
-    private List<String> mAssetFolders = new ArrayList<>();
-    private List<String> mJavaResourceFolders = new ArrayList<>();
-
-    public ApiModule(String folderName, int api) {
-        mFolderName = folderName;
-        mApi = api;
-    }
-
-    public ApiModule resources(String... resourceFolders) {
-        Collections.addAll(mResourceFolders, resourceFolders);
-        return this;
-    }
-
-    public ApiModule assets(String... assetFolders) {
-        Collections.addAll(mAssetFolders, assetFolders);
-        return this;
-    }
-
-    public ApiModule javaResources(String... javaResourceFolders) {
-        Collections.addAll(mJavaResourceFolders, javaResourceFolders);
-        return this;
-    }
-
-    public List<String> getResourceFolders() {
-        return mResourceFolders;
-    }
-
-    public List<String> getAssetFolders() {
-        return mAssetFolders;
-    }
-
-    public List<String> getJavaResourceFolders() {
-        return mJavaResourceFolders;
-    }
-
-    public void setResourceFolders(List<String> resourceFolders) {
-        mResourceFolders = resourceFolders;
-    }
-
-    public String getParentModuleName() {
-        return mParentModuleName;
-    }
-
-    public void setParentModuleName(String parentModuleName) {
-        mParentModuleName = parentModuleName;
-    }
-
-    public String getFolderName() {
-        return mFolderName;
-    }
-
-    public int getApi() {
-        return mApi;
-    }
-
-    public Object getApiForSourceSet() {
-        return mApi == CURRENT ? "current" : mApi;
-    }
-
-    public SourceSet getSourceSet() {
-        return mSourceSet;
-    }
-
-    public void setSourceSet(SourceSet sourceSet) {
-        mSourceSet = sourceSet;
-    }
-
-    public ApiModule getPrev() {
-        return mPrev;
-    }
-
-    public void setPrev(ApiModule prev) {
-        mPrev = prev;
-    }
-
-    public String getModuleName() {
-        return ":" + mParentModuleName + "-" + mFolderName;
-    }
-
-    public List<String> getParentModuleDependencies() {
-        return mParentModuleDependencies;
-    }
-
-    public void setParentModuleDependencies(List<String> parentModuleDependencies) {
-        mParentModuleDependencies = parentModuleDependencies;
-    }
-}
diff --git a/buildSrc/studioCompat.gradle b/buildSrc/studioCompat.gradle
deleted file mode 100644
index 1c58c62..0000000
--- a/buildSrc/studioCompat.gradle
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright (C) 2016 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.
- */
-import android.support.build.ApiModule
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-/**
- * To add platform specific code to a library:
- * 1) add the related source set into the studioCompat map (defined below)
- * 2) In your build gradle file, call:
- *    * createApiSourceSets(project, gradle.ext.studioCompat.modules.<PROJECT>.apiTargets)
- *    * setApiModuleDependencies(project, dependencies, gradle.ext.studioCompat.modules.<PROJECT>.dependencies)
- */
-
-def studioCompat = [
-    enableApiModules : hasProperty('android.injected.invoked.from.ide'),
-    modules : [
-        compat : [
-            apiTargets : [
-                new ApiModule("gingerbread",9),
-                new ApiModule("honeycomb",11),
-                new ApiModule("honeycomb_mr1",12),
-                new ApiModule("honeycomb_mr2",13),
-                new ApiModule("ics",14),
-                new ApiModule("ics-mr1",15),
-                new ApiModule("jellybean", 16),
-                new ApiModule("jellybean-mr1",17),
-                new ApiModule("jellybean-mr2",18),
-                new ApiModule("kitkat",19),
-                new ApiModule("api20",20),
-                new ApiModule("api21",21),
-                new ApiModule("api22",22),
-                new ApiModule("api23",23),
-                new ApiModule("api24",24)
-            ],
-            dependencies : [":support-annotations"],
-            folder : "compat",
-            moduleName : "support-compat"
-        ],
-        mediacompat : [
-                apiTargets : [
-                        new ApiModule("ics",14),
-                        new ApiModule("jellybean-mr2",18),
-                        new ApiModule("kitkat",19),
-                        new ApiModule("api21",21),
-                        new ApiModule("api22",22),
-                        new ApiModule("api23",23),
-                        new ApiModule("api24",24)
-                ],
-                dependencies : [":support-compat"],
-                folder : "media-compat",
-                moduleName : "support-media-compat"
-        ],
-        coreutils : [
-                apiTargets : [
-                        new ApiModule("gingerbread",9),
-                        new ApiModule("honeycomb",11),
-                        new ApiModule("jellybean", 16),
-                        new ApiModule("kitkat",19),
-                        new ApiModule("api20",20),
-                        new ApiModule("api21",21),
-                        new ApiModule("api23",23),
-                        new ApiModule("api24",24)
-                ],
-                dependencies : [":support-compat"],
-                folder : "core-utils",
-                moduleName : "support-core-utils"
-        ],
-        coreui : [
-                apiTargets : [
-                        new ApiModule("honeycomb",11),
-                        new ApiModule("ics",14),
-                        new ApiModule("jellybean-mr2",18),
-                        new ApiModule("api21",21)
-                ],
-                dependencies : [":support-compat"],
-                folder : "core-ui",
-                moduleName : "support-core-ui"
-        ],
-        fragment : [
-                apiTargets : [
-                        new ApiModule("gingerbread",9),
-                        new ApiModule("honeycomb",11),
-                        new ApiModule("jellybean", 16),
-                        new ApiModule("api21",21)
-                ],
-                dependencies : [":support-media-compat", ":support-core-ui", ":support-core-utils"],
-                folder : "fragment",
-                moduleName : "support-fragment"
-        ],
-        v13 : [
-            apiTargets : [
-                new ApiModule("ics", 14),
-                new ApiModule("ics-mr1", 15),
-                new ApiModule("api23", 23),
-                new ApiModule("api24", 24),
-                new ApiModule("api25", ApiModule.CURRENT)
-            ],
-            dependencies : [":support-v4"],
-            folder : "v13",
-            moduleName : "support-v13"
-        ],
-        mediaRouter : [
-            apiTargets : [
-                new ApiModule("jellybean", 16),
-                new ApiModule("jellybean-mr1", 17),
-                new ApiModule("jellybean-mr2", 18),
-                new ApiModule("api24",24)
-            ],
-            folder : "v7/mediarouter",
-            moduleName : "support-mediarouter-v7"
-        ]
-    ]
-]
-
-/**
- * Adds a link to the previous ApiModule for each module. This information is later used when
- * setting dependencies.
- */
-def setupDependencies(projectConfig) {
-    projectConfig.apiTargets.eachWithIndex { entry, index ->
-        entry.parentModuleName = projectConfig.moduleName
-        entry.prev = index == 0 ? null : projectConfig.apiTargets[index - 1]
-    }
-}
-gradle.ext.currentSdk = studioCompat.enableApiModules ? ApiModule.CURRENT : 'current'
-
-// the hashmap from apiModuleProjectFolder -> ApiModule
-gradle.ext.folderToApiModuleMapping = new HashMap()
-
-/**
- * For each APIModule in the given projectConfig, creates a gradle module. These modules use the
- * common `apiModule.gradle` build file.
- */
-def createModules(projectConfig) {
-    Path buildFile = Paths.get(file("apiModule.gradle").toURI())
-    projectConfig.apiTargets.each { ApiModule module  ->
-        logger.info "creating ${module.moduleName}"
-        module.setParentModuleDependencies(projectConfig.dependencies)
-        include "${module.moduleName}"
-        def folder = new File(rootDir, "${projectConfig.folder}/${module.folderName}")
-        project("${module.moduleName}").projectDir = folder
-        project("${module.moduleName}").buildFileName = Paths.get(folder.toURI()).relativize(buildFile)
-        gradle.ext.folderToApiModuleMapping[folder.canonicalPath] = module
-    }
-}
-
-/**
- * returns the APIModule for the given project.
- */
-ApiModule getApiModule(Project project) {
-    return gradle.ext.folderToApiModuleMapping[project.projectDir.canonicalPath]
-}
-
-studioCompat.modules.each { k, v ->
-    setupDependencies(v)
-}
-// create these fake modules only if Studio opens the project.
-if (studioCompat.enableApiModules) {
-    // validate we have the 99 folder, otherwise it wont work
-    def currentSdkPrebuilt = file("${rootProject.projectDir}/../../prebuilts/sdk/" +
-            "${ApiModule.CURRENT}/")
-    if (!currentSdkPrebuilt.exists()) {
-        throw new GradleScriptException(
-                "You need a symlink in prebuilts/sdk/${ApiModule.CURRENT} that points to"
-                        + " prebuilts/sdk/current."
-                        + "Without it, studio cannot understand current SDK.\n"
-                        + "> ln -s ../../prebuilts/sdk/current "
-                        + "../../prebuilts/sdk/${ApiModule.CURRENT}\n"
-                , new Exception())
-    }
-    Properties localProps = new Properties()
-    def localPropsStream = new FileInputStream(file("${rootProject.projectDir}/local.properties"))
-    try {
-        localProps.load(localPropsStream)
-        def sdkDir = localProps.get("sdk.dir")
-        if (sdkDir != null && sdkDir != "") {
-            throw new GradleScriptException("You should not have sdk.dir in local.properties because"
-                    + " it overrides android.dir and prevents studio from seeing current sdk. "
-                    + " Studio may add it by mistake, just remove it and it will work fine.",
-            new Exception())
-        }
-    } finally {
-        localPropsStream.close()
-    }
-    studioCompat.modules.each { k, v ->
-        createModules(v)
-    }
-}
-gradle.ext.studioCompat = studioCompat
-gradle.ext.getApiModule = this.&getApiModule
diff --git a/settings.gradle b/settings.gradle
index fcdd6c3..b7dce9c 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,5 +1,3 @@
-apply from:'buildSrc/studioCompat.gradle'
-
 /////////////////////////////
 //
 // Libraries