dniz 12c22feda2 Update androidx dependency versions
core: 1.1.0-rc02 -> 1.1.0-rc03
viewpager2: 1.0.0-beta02 -> 1.0.0-beta03
PiperOrigin-RevId: 262392428
2019-08-16 15:34:35 -04:00

288 lines
10 KiB
Groovy

buildscript {
ext.kotlinVersion = '1.3.21'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
allprojects {
repositories {
google()
jcenter()
mavenLocal()
}
}
ext {
compileSdkVersion = 29
minSdkVersion = 14
targetSdkVersion = 27
androidXVersions = [
annotation : '1.0.1',
appCompat : '1.1.0-rc01', // Needed for CSL + theme attr fixes
cardView : '1.0.0',
coordinatorlayout : '1.1.0-beta01', // Needed for NestedScrolling3 APIs
core : '1.1.0-rc03', // Needed for CSL + theme attr fixes
fragment : '1.0.0',
lifecycle : "2.0.0",
recyclerView : '1.0.0',
recyclerViewSelection : '1.0.0',
transition : '1.0.1',
vectorDrawable : '1.1.0-rc01', // Needed for CSL + theme attr fixes
viewpager2 : '1.0.0-beta03', // Needed for TabLayout and MaterialCalendar
]
testRunnerVersion = '1.1.0'
espressoVersion = '3.1.0'
mockitoCoreVersion = '2.25.0'
truthVersion = '0.45'
// Enforce the use of prebuilt dependencies in all sub-projects. This is
// required for the doclava dependency.
usePrebuilts = "true"
// Disable pre-dexing when gradle called with -PdisablePreDex;
preDexLibs = !project.hasProperty('disablePreDex')
mavenRepoUrl = (project.hasProperty('mavenRepoUrl')
? project.property('mavenRepoUrl') : 'file://localhost/tmp/myRepo/')
// Current version of the library (could be in-development/unreleased).
mdcLibraryVersion = '1.1.0-alpha09'
mdcLibraryPackage = "com.google.android.material"
mdcLibraryDir = "com/google/android/material"
}
// lint every library
task lint {
doLast {
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
private def getTransformedProjectPath(projectPath) {
def pathComponents = projectPath.tokenize('/')
def result = ''
def currentPath = ''
pathComponents.each { component ->
if (currentPath == '') {
currentPath += component
} else {
currentPath += '-' + component
}
result += ':' + currentPath
}
return result
}
/**
* Return the module dependency for the given compatibility library name.
*/
def compatibility(name) {
switch (name) {
case "annotation":
return "androidx.annotation:annotation:${androidXVersions.annotation}"
case "appcompat":
return "androidx.appcompat:appcompat:${androidXVersions.appCompat}"
case "cardview":
return "androidx.cardview:cardview:${androidXVersions.cardView}"
case "coordinatorlayout":
return "androidx.coordinatorlayout:coordinatorlayout:${androidXVersions.coordinatorlayout}"
case "core":
return "androidx.core:core:${androidXVersions.core}"
case "fragment":
return "androidx.fragment:fragment:${androidXVersions.fragment}"
case "lifecycleRuntime":
return "androidx.lifecycle:lifecycle-runtime:${androidXVersions.lifecycle}"
case "recyclerview":
return "androidx.recyclerview:recyclerview:${androidXVersions.recyclerView}"
case "transition":
return "androidx.transition:transition:${androidXVersions.transition}"
case "vectordrawable":
return "androidx.vectordrawable:vectordrawable:${androidXVersions.vectorDrawable}"
case "recyclerViewSelection":
return "androidx.recyclerview:recyclerview-selection:${androidXVersions.recyclerViewSelection}"
case "viewpager2":
return "androidx.viewpager2:viewpager2:${androidXVersions.viewpager2}"
default:
throw new IllegalArgumentException("No mapping exists for name: $name.")
}
}
/**
* Return the project dependency for the given project path.
*/
def fromPath(path) {
return getTransformedProjectPath(path)
}
def getArchivesBaseName(name) {
if (name == 'lib') {
return 'material'
}
def pathComponents = name.tokenize('-')
def knownComponents = ['lib', 'java', 'com', 'google', 'android', 'material']
def firstUnknownComponent = knownComponents.size();
for (def i = 0; i < knownComponents.size() && i < pathComponents.size(); i++) {
if (pathComponents[i] != knownComponents[i]) {
firstUnknownComponent = i;
break;
}
}
def result = 'material'
for (def i = firstUnknownComponent; i < pathComponents.size(); i++) {
result = result + '-' + pathComponents[i];
}
return result;
}
subprojects {
version = rootProject.ext.mdcLibraryVersion
group = 'com.google.android.material'
// Disable strict dependency resolution version constraints for test projects
if (project.name.contains("tests")) {
project.configurations.all {
dependencyConstraints.configureEach { dependencyConstraint ->
dependencyConstraint.version { versionConstraint ->
versionConstraint.strictly("")
}
}
}
}
project.plugins.whenPluginAdded { plugin ->
def isAndroidLibrary = "com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)
def isAndroidApp = "com.android.build.gradle.AppPlugin".equals(plugin.class.name)
def isAndroidTest = "com.android.build.gradle.TestPlugin".equals(plugin.class.name)
if (isAndroidLibrary || isAndroidApp) {
// Enable code coverage for debug builds only if we are not running inside the IDE,
// since enabling coverage reports breaks the method parameter resolution in the IDE
// debugger. Note that we avoid doing this for Android Test projects as it causes
// crashes on Dalvik ('Class ref in pre-verified class resolved to unexpected implementation')
project.android.buildTypes.debug.testCoverageEnabled = !hasProperty('android.injected.invoked.from.ide')
}
if (isAndroidLibrary || isAndroidApp || isAndroidTest) {
if (!isAndroidTest) {
rootProject.lint.dependsOn project.lint
}
// Disable pre-dexing when gradle called with -PdisablePreDex;
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
project.android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig.minSdkVersion rootProject.ext.minSdkVersion
// This disables the builds tools automatic vector -> PNG generation
defaultConfig.generatedDensities = []
compileOptions.sourceCompatibility JavaVersion.VERSION_1_7
compileOptions.targetCompatibility JavaVersion.VERSION_1_7
aaptOptions.additionalParameters "--no-version-vectors"
lintOptions {
baseline file("baseline.xml")
disable 'IconLauncherShape', 'IconDuplicates', 'SwitchIntDef', 'PxUsage', 'PrivateResource', 'GradleDependency', 'GradleOverrides', 'VectorRaster'
warningsAsErrors true
}
if (isAndroidLibrary) {
def JAVA_RESOURCES_TEMP_DIR = "$buildDir/javaResources"
task writeVersionFile() {
def versionFileDir = JAVA_RESOURCES_TEMP_DIR + '/META-INF'
def versionFileName = mdcLibraryPackage + '_' + getArchivesBaseName(project.name) + '.version'
new File(versionFileDir).mkdirs()
new File(versionFileDir + '/' + versionFileName).text = mdcLibraryVersion + "\n"
}
libraryVariants.all {
it.processJavaResources.dependsOn(writeVersionFile)
}
project.android.sourceSets.main.resources.srcDir JAVA_RESOURCES_TEMP_DIR
}
}
if (isAndroidLibrary) {
project.afterEvaluate {
project.tasks.all({
if (it instanceof com.android.build.gradle.tasks.GenerateBuildConfig) {
// Disable generating BuildConfig.java
it.enabled = false
}
})
project.android {
task sourcesJar(type: Jar) {
classifier = 'sources'
from(android.sourceSets.main.java.srcDirs) {
// Needed because we have Java sources and resources in same directory
include '**/*.java'
includeEmptyDirs = false
}
}
artifacts {
archives sourcesJar
}
}
if (project.uploadArchives.repositories.hasProperty("mavenDeployer")) {
project.uploadArchives.repositories.mavenDeployer.pom {
project {
name 'Material Components for Android'
description 'Material Components for Android is a static library that you can add to your Android application in order to use APIs that provide implementations of the Material Design specification. Compatible on devices running API 14 or later.'
url 'http://developer.android.com/tools/extras/support-library.html'
inceptionYear '2015'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
name 'The Android Open Source Project'
}
}
scm {
connection 'scm:git:https://github.com/material-components/material-components-android.git'
url 'https://github.com/material-components/material-components-android'
}
}
// Adds a <type> tag for each dependency. This assumes that all dependencies except
// for "annotation" are aars, but it can break if in the future the artifactId
// changes or we depend on anything else that's not an aar.
// TODO(b/73783252): Remove this once Gradle automatically determines dependency types.
whenConfigured { pom ->
pom.dependencies.findAll { dependency ->
if (dependency.artifactId != 'annotation' && dependency.artifactId != 'lifecycle-common-java8') {
dependency.type = 'aar'
}
}
}
}
}
}
}
}
}
}