Merge "Drop support for non ub-supportlib-* builds of support library." into oc-mr1-jetpack-dev
diff --git a/buildSrc/init.gradle b/buildSrc/init.gradle
index 08faa27..2b703ff 100644
--- a/buildSrc/init.gradle
+++ b/buildSrc/init.gradle
@@ -16,6 +16,7 @@
import android.support.DiffAndDocs
+import android.support.SupportConfig
import android.support.gmaven.GMavenVersionChecker
import com.android.build.gradle.internal.coverage.JacocoReportTask
import com.android.build.gradle.internal.tasks.DeviceProviderInstrumentTestTask
@@ -63,27 +64,15 @@
}
def setSdkInLocalPropertiesFile() {
- ext.buildToolsVersion = '27.0.1'
- final String fullSdkPath = getFullSdkPath();
- if (file(fullSdkPath).exists()) {
- project.ext.currentSdk = 26
- project.ext.androidJar =
- files("${fullSdkPath}/platforms/android-${project.currentSdk}/android.jar")
- project.ext.androidSrcJar =
- file("${fullSdkPath}/platforms/android-${project.currentSdk}/android-stubs-src.jar")
- project.ext.androidApiTxt = null
+ final File fullSdkPath = file(getFullSdkPath())
+ if (fullSdkPath.exists()) {
+ project.ext.fullSdkPath = fullSdkPath
File props = file("local.properties")
- props.write "sdk.dir=${fullSdkPath}"
+ props.write "sdk.dir=${fullSdkPath.getAbsolutePath()}"
ext.usingFullSdk = true
} else {
- gradle.ext.currentSdk = 'current'
- project.ext.androidJar = files("${repos.prebuiltsRoot}/sdk/current/android.jar")
- project.ext.androidSrcJar = null
- project.ext.androidApiTxt = file("${repos.prebuiltsRoot}/sdk/api/26.txt")
- System.setProperty('android.dir', "${supportRootFolder}/../../")
- File props = file("local.properties")
- props.write "android.dir=../../"
- ext.usingFullSdk = false
+ throw Exception("You are using non ub-supportlib-* checkout. You need to check out "
+ + "ub-supportlib-* to work on support library. See go/supportlib for details.")
}
}
@@ -180,8 +169,6 @@
return
}
- project.ext.currentSdk = rootProject.ext.currentSdk
-
project.plugins.whenPluginAdded { plugin ->
def isAndroidLibrary = "com.android.build.gradle.LibraryPlugin"
.equals(plugin.class.name)
diff --git a/buildSrc/src/main/kotlin/android/support/DiffAndDocs.kt b/buildSrc/src/main/kotlin/android/support/DiffAndDocs.kt
index fefc3ed..f4a9733 100644
--- a/buildSrc/src/main/kotlin/android/support/DiffAndDocs.kt
+++ b/buildSrc/src/main/kotlin/android/support/DiffAndDocs.kt
@@ -30,7 +30,6 @@
import org.gradle.api.artifacts.Configuration
import org.gradle.api.file.FileCollection
import org.gradle.api.plugins.JavaBasePlugin
-import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.TaskContainer
import org.gradle.api.tasks.bundling.Zip
import org.gradle.api.tasks.compile.JavaCompile
@@ -166,7 +165,7 @@
setDocletpath(docletpathParam)
destinationDir = project.docsDir()
// Base classpath is Android SDK, sub-projects add their own.
- classpath = project.androidJar()
+ classpath = androidJarFile(project)
apiFile = File(project.docsDir(), "release/${project.name}/current.txt")
generateDocs = false
@@ -329,7 +328,7 @@
jdiffConfig: Configuration) =
project.tasks.createWithConfig("generateDiffs", JDiffTask::class.java) {
// Base classpath is Android SDK, sub-projects add their own.
- classpath = project.androidJar()
+ classpath = androidJarFile(project)
// JDiff properties.
oldApiXmlFile = oldApiTask.outputApiXmlFile
@@ -366,33 +365,18 @@
// Set up platform API files for federation.
private fun createGenerateSdkApiTask(project: Project, doclavaConfig: Configuration): Task =
- if (project.androidApiTxt() != null) {
- project.tasks.createWithConfig("generateSdkApi", Copy::class.java) {
- description = "Copies the API files for the current SDK."
- // Export the API files so this looks like a DoclavaTask.
- from(project.androidApiTxt()!!.absolutePath)
- val apiFile = sdkApiFile(project)
- into(apiFile.parent)
- rename { apiFile.name }
- // Register the fake removed file as an output.
- val removedApiFile = removedSdkApiFile(project)
- outputs.file(removedApiFile)
- doLast { removedApiFile.createNewFile() }
- }
- } else {
- project.tasks.createWithConfig("generateSdkApi", DoclavaTask::class.java) {
- dependsOn(doclavaConfig)
- description = "Generates API files for the current SDK."
- setDocletpath(doclavaConfig.resolve())
- destinationDir = project.docsDir()
- classpath = project.androidJar()
- source(project.zipTree(project.androidSrcJar()))
- apiFile = sdkApiFile(project)
- removedApiFile = removedSdkApiFile(project)
- generateDocs = false
- coreJavadocOptions {
- addStringOption("stubpackages", "android.*")
- }
+ project.tasks.createWithConfig("generateSdkApi", DoclavaTask::class.java) {
+ dependsOn(doclavaConfig)
+ description = "Generates API files for the current SDK."
+ setDocletpath(doclavaConfig.resolve())
+ destinationDir = project.docsDir()
+ classpath = androidJarFile(project)
+ source(project.zipTree(androidSrcJarFile(project)))
+ apiFile = sdkApiFile(project)
+ removedApiFile = removedSdkApiFile(project)
+ generateDocs = false
+ coreJavadocOptions {
+ addStringOption("stubpackages", "android.*")
}
}
@@ -411,7 +395,7 @@
setDocletpath(doclavaConfig.resolve())
val offline = project.processProperty("offlineDocs") != null
destinationDir = File(project.docsDir(), if (offline) "offline" else "online")
- classpath = project.androidJar()
+ classpath = androidJarFile(project)
val hidden = listOf<Int>(105, 106, 107, 111, 112, 113, 115, 116, 121)
doclavaErrors = ((101..122) - hidden).toSet()
doclavaWarnings = emptySet()
@@ -602,19 +586,22 @@
config: T.() -> Unit) =
create(name, taskClass) { task -> task.config() }
+private fun androidJarFile(project: Project): FileCollection =
+ project.files(arrayOf(File(project.fullSdkPath(),
+ "platforms/android-${SupportConfig.CURRENT_SDK_VERSION}/android.jar")))
+
+private fun androidSrcJarFile(project: Project): File = File(project.fullSdkPath(),
+ "platforms/android-${SupportConfig.CURRENT_SDK_VERSION}/android-stubs-src.jar")
+
// Nasty part. Get rid of that eventually!
private fun Project.docsDir(): File = properties["docsDir"] as File
-private fun Project.androidJar() = rootProject.properties["androidJar"] as FileCollection
-
-private fun Project.androidSrcJar() = rootProject.properties["androidSrcJar"] as File
+private fun Project.fullSdkPath(): File = rootProject.properties["fullSdkPath"] as File
private fun Project.version() = Version(project.version as String)
private fun Project.buildNumber() = properties["buildNumber"] as String
-private fun Project.androidApiTxt() = properties["androidApiTxt"] as? File
-
private fun Project.processProperty(name: String) =
if (hasProperty(name)) {
properties[name] as String
diff --git a/buildSrc/src/main/kotlin/android/support/SupportAndroidLibraryPlugin.kt b/buildSrc/src/main/kotlin/android/support/SupportAndroidLibraryPlugin.kt
index e55f383..d028776 100644
--- a/buildSrc/src/main/kotlin/android/support/SupportAndroidLibraryPlugin.kt
+++ b/buildSrc/src/main/kotlin/android/support/SupportAndroidLibraryPlugin.kt
@@ -102,16 +102,13 @@
val library = project.extensions.findByType(LibraryExtension::class.java)
?: throw Exception("Failed to find Android extension")
- val currentSdk = project.property("currentSdk")
- when (currentSdk) {
- is Int -> library.compileSdkVersion(currentSdk)
- is String -> library.compileSdkVersion(currentSdk)
- }
+ library.compileSdkVersion(SupportConfig.CURRENT_SDK_VERSION)
- library.buildToolsVersion = SupportConfig.getBuildTools(project)
+ library.buildToolsVersion = SupportConfig.BUILD_TOOLS_VERSION
// Update the version meta-data in each Manifest.
- library.defaultConfig.addManifestPlaceholders(mapOf("target-sdk-version" to currentSdk))
+ library.defaultConfig.addManifestPlaceholders(
+ mapOf("target-sdk-version" to SupportConfig.CURRENT_SDK_VERSION))
// Set test runner.
library.defaultConfig.testInstrumentationRunner = INSTRUMENTATION_RUNNER
@@ -124,10 +121,7 @@
setUpLint(library.lintOptions, SupportConfig.getLintBaseline(project))
- if (SupportConfig.isUsingFullSdk(project)) {
- // Library projects don't run lint by default, so set up dependency.
- project.tasks.getByName("uploadArchives").dependsOn("lintRelease")
- }
+ project.tasks.getByName("uploadArchives").dependsOn("lintRelease")
SourceJarTaskHelper.setUpAndroidProject(project, library)
diff --git a/buildSrc/src/main/kotlin/android/support/SupportAndroidTestAppPlugin.kt b/buildSrc/src/main/kotlin/android/support/SupportAndroidTestAppPlugin.kt
index 6d73c99..89e8177 100644
--- a/buildSrc/src/main/kotlin/android/support/SupportAndroidTestAppPlugin.kt
+++ b/buildSrc/src/main/kotlin/android/support/SupportAndroidTestAppPlugin.kt
@@ -42,19 +42,10 @@
val application = project.extensions.findByType(AppExtension::class.java)
?: throw Exception("Failed to find Android extension")
- val currentSdk = project.property("currentSdk")
- when (currentSdk) {
- is Int -> {
- application.compileSdkVersion(currentSdk)
- application.defaultConfig.targetSdkVersion(currentSdk)
- }
- is String -> {
- application.compileSdkVersion(currentSdk)
- application.defaultConfig.targetSdkVersion(currentSdk)
- }
- }
+ application.compileSdkVersion(SupportConfig.CURRENT_SDK_VERSION)
+ application.defaultConfig.targetSdkVersion(SupportConfig.CURRENT_SDK_VERSION)
- application.buildToolsVersion = SupportConfig.getBuildTools(project)
+ application.buildToolsVersion = SupportConfig.BUILD_TOOLS_VERSION
application.defaultConfig.versionCode = 1
application.defaultConfig.versionName = "1.0"
diff --git a/buildSrc/src/main/kotlin/android/support/SupportConfig.kt b/buildSrc/src/main/kotlin/android/support/SupportConfig.kt
index 26c3bf3..f9d08ed 100644
--- a/buildSrc/src/main/kotlin/android/support/SupportConfig.kt
+++ b/buildSrc/src/main/kotlin/android/support/SupportConfig.kt
@@ -23,10 +23,8 @@
object SupportConfig {
const val DEFAULT_MIN_SDK_VERSION = 14
const val INSTRUMENTATION_RUNNER = "android.support.test.runner.AndroidJUnitRunner"
-
- fun getBuildTools(project: Project): String {
- return project.rootProject.property("buildToolsVersion") as String
- }
+ const val BUILD_TOOLS_VERSION = "27.0.1"
+ const val CURRENT_SDK_VERSION = 26
fun getKeystore(project: Project): File {
val supportRoot = (project.rootProject.property("ext") as ExtraPropertiesExtension)
@@ -34,10 +32,6 @@
return File(supportRoot, "development/keystore/debug.keystore")
}
- fun isUsingFullSdk(project: Project): Boolean {
- return project.rootProject.property("usingFullSdk") as Boolean
- }
-
fun getLintBaseline(project: Project): File {
return File(project.projectDir, "/lint-baseline.xml")
}
diff --git a/room/compiler/build.gradle b/room/compiler/build.gradle
index f311a30..0d62cf8 100644
--- a/room/compiler/build.gradle
+++ b/room/compiler/build.gradle
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+
+import android.support.SupportConfig
+
import static android.support.dependencies.DependenciesKt.*
import android.support.LibraryGroups
import android.support.LibraryVersions
@@ -53,7 +56,7 @@
testCompile(INTELLIJ_ANNOTATIONS)
testCompile(JSR250)
testCompile(MOCKITO_CORE)
- testCompile fileTree(dir: "${sdkHandler.sdkFolder}/platforms/android-$rootProject.ext.currentSdk/",
+ testCompile fileTree(dir: "${sdkHandler.sdkFolder}/platforms/android-$SupportConfig.CURRENT_SDK_VERSION/",
include : "android.jar")
testCompile fileTree(dir: "${new File(project(":room:runtime").buildDir, "libJar")}",
include : "*.jar")