Unify the location of libary versions.
Test: ./gradlew buildOnServer
Change-Id: Ic6edd16441b2b649424b47829b46b8f67453ba40
diff --git a/app-toolkit/dependencies.gradle b/app-toolkit/dependencies.gradle
index ab62b15..c9e3dea 100644
--- a/app-toolkit/dependencies.gradle
+++ b/app-toolkit/dependencies.gradle
@@ -84,5 +84,4 @@
ext.tools.current_sdk = gradle.ext.currentSdk
ext.tools.build_tools_version = rootProject.ext.buildToolsVersion
ext.flatfoot = [:]
-ext.flatfoot.release_version = "1.0.0-alpha7"
ext.flatfoot.min_sdk = 14
diff --git a/app-toolkit/init.gradle b/app-toolkit/init.gradle
index fab8e17..e8a4ad3 100644
--- a/app-toolkit/init.gradle
+++ b/app-toolkit/init.gradle
@@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+import android.support.LibraryVersions
import org.gradle.internal.os.OperatingSystem
def root = ext.supportRootFolder
@@ -20,7 +22,6 @@
if (ext.inAppToolkitProject) {
apply from: "${ext.supportRootFolder}/buildSrc/init.gradle"
- init.loadDefaultVersions()
init.setSdkInLocalPropertiesFile()
}
@@ -91,7 +92,7 @@
def zipFlatfootDocsTask = rootProject.tasks.create(name : "createFlatfootDocsArchive", type : Zip) {
from rootProject.docsDir
destinationDir distDir
- baseName = String.format("flatfoot-docs-%s", rootProject.ext.flatfoot.release_version)
+ baseName = String.format("flatfoot-docs-%s", LibraryVersions.FLATFOOT.toString())
}
buildServerAnchorTask.dependsOn zipFlatfootDocsTask
@@ -125,7 +126,7 @@
}
project.group = finalGroup
if (!project.version) {
- project.version = flatfoot.release_version
+ project.version = LibraryVersions.FLATFOOT.toString()
}
if (project.getPath().contains("integration-tests")) {
diff --git a/build.gradle b/build.gradle
index 360ec02..8c32175 100644
--- a/build.gradle
+++ b/build.gradle
@@ -19,7 +19,6 @@
apply from: 'buildSrc/repos.gradle'
apply from: 'buildSrc/init.gradle'
- init.loadDefaultVersions()
init.setSdkInLocalPropertiesFile()
repos.addMavenRepositories(repositories)
diff --git a/buildSrc/diff_and_docs.gradle b/buildSrc/diff_and_docs.gradle
index 3011092..2c94849 100644
--- a/buildSrc/diff_and_docs.gradle
+++ b/buildSrc/diff_and_docs.gradle
@@ -14,20 +14,15 @@
* limitations under the License.
*/
+import android.support.LibraryVersions
+import android.support.Version
import android.support.checkapi.ApiXmlConversionTask
import android.support.checkapi.CheckApiTask
import android.support.checkapi.UpdateApiTask
import android.support.doclava.DoclavaTask
import android.support.jdiff.JDiffTask
-import android.support.Version
-
-import org.gradle.api.InvalidUserDataException
-
import groovy.io.FileType
-import groovy.transform.Field;
-
-import java.util.regex.Matcher
-import java.util.regex.Pattern
+import groovy.transform.Field
// Set up platform API files for federation.
if (project.androidApiTxt != null) {
@@ -490,7 +485,7 @@
}
if (hasApiFolder(rootProject)) {
- rootProject.version = rootProject.supportVersion
+ rootProject.version = LibraryVersions.SUPPORT_LIBRARY.toString();
initializeApiChecksForProject(rootProject)
}
diff --git a/buildSrc/init.gradle b/buildSrc/init.gradle
index b35123c..b9f85d3 100644
--- a/buildSrc/init.gradle
+++ b/buildSrc/init.gradle
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+import android.support.LibraryVersions
import com.android.build.gradle.internal.coverage.JacocoPlugin
import com.android.build.gradle.internal.coverage.JacocoReportTask
import com.android.build.gradle.internal.tasks.DeviceProviderInstrumentTestTask
@@ -38,10 +39,6 @@
dataname: "SUPPORT_DATA"
]
-def loadDefaultVersions() {
- apply from: "${supportRootFolder}/buildSrc/versions.gradle"
-}
-
def enableDoclavaAndJDiff(p) {
p.configurations {
doclava
@@ -170,7 +167,7 @@
project.ext.currentSdk = gradle.ext.currentSdk
apply plugin: 'maven'
- version = rootProject.ext.supportVersion
+ version = LibraryVersions.SUPPORT_LIBRARY.toString();
group = 'com.android.support'
project.plugins.whenPluginAdded { plugin ->
@@ -361,6 +358,5 @@
ext.init.setSdkInLocalPropertiesFile = this.&setSdkInLocalPropertiesFile
ext.init.setupRepoOutAndBuildNumber = this.&setupRepoOutAndBuildNumber
ext.init.setupRelease = this.&setupRelease
-ext.init.loadDefaultVersions = this.&loadDefaultVersions
ext.init.configureSubProjects = this.&configureSubProjects
ext.init.configureBuildOnServer = this.&configureBuildOnServer
diff --git a/buildSrc/src/main/groovy/android/support/SupportLibraryPlugin.groovy b/buildSrc/src/main/groovy/android/support/SupportLibraryPlugin.groovy
index 382b5b7..7ebef19 100644
--- a/buildSrc/src/main/groovy/android/support/SupportLibraryPlugin.groovy
+++ b/buildSrc/src/main/groovy/android/support/SupportLibraryPlugin.groovy
@@ -52,7 +52,7 @@
library.defaultConfig {
// Update the version meta-data in each Manifest.
- addManifestPlaceholders(["support-version": project.rootProject.supportVersion,
+ addManifestPlaceholders(["support-version": LibraryVersions.SUPPORT_LIBRARY.toString(),
"target-sdk-version": project.currentSdk])
// Set test related options.
diff --git a/buildSrc/src/main/java/android/support/LibraryVersions.java b/buildSrc/src/main/java/android/support/LibraryVersions.java
new file mode 100644
index 0000000..503fe1d
--- /dev/null
+++ b/buildSrc/src/main/java/android/support/LibraryVersions.java
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+package android.support;
+
+/**
+ * The list of versions codes of all the libraries in this project.
+ */
+public class LibraryVersions {
+ /**
+ * Version code of the support library components.
+ */
+ public static final Version SUPPORT_LIBRARY = new Version("26.1.0-SNAPSHOT");
+
+ /**
+ * Version code of the flatfoot libraries.
+ */
+ public static final Version FLATFOOT = new Version("1.0.0-alpha7");
+
+ /**
+ * Version code of the lifecycles library.
+ */
+ public static final Version LIFECYCLES = new Version("1.0.0-SNAPSHOT");
+}
diff --git a/buildSrc/src/main/java/android/support/Version.java b/buildSrc/src/main/java/android/support/Version.java
index 1338a1d..b88d8cf 100644
--- a/buildSrc/src/main/java/android/support/Version.java
+++ b/buildSrc/src/main/java/android/support/Version.java
@@ -68,4 +68,9 @@
public String getExtra() {
return mExtra;
}
+
+ @Override
+ public String toString() {
+ return mMajor + "." + mMinor + "." + mPatch + (mExtra != null ? mExtra : "");
+ }
}
diff --git a/buildSrc/versions.gradle b/buildSrc/versions.gradle
deleted file mode 100644
index 43caec7..0000000
--- a/buildSrc/versions.gradle
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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.
- */
-
-// Version code of the support library components.
-ext.supportVersion = "26.1.0-SNAPSHOT"
-
diff --git a/lifecycle/common/build.gradle b/lifecycle/common/build.gradle
index 1b64d9d..d237d30 100644
--- a/lifecycle/common/build.gradle
+++ b/lifecycle/common/build.gradle
@@ -1,3 +1,5 @@
+import android.support.LibraryVersions
+
apply plugin: 'java'
apply plugin: 'maven'
@@ -10,4 +12,4 @@
}
createAndroidCheckstyle(project)
-version = "1.0.0-SNAPSHOT"
\ No newline at end of file
+version = LibraryVersions.LIFECYCLES.toString()
\ No newline at end of file
diff --git a/lifecycle/runtime/build.gradle b/lifecycle/runtime/build.gradle
index 36d9126..926b9a2 100644
--- a/lifecycle/runtime/build.gradle
+++ b/lifecycle/runtime/build.gradle
@@ -1,3 +1,5 @@
+import android.support.LibraryVersions
+
apply plugin: 'com.android.library'
apply plugin: 'maven'
@@ -44,4 +46,4 @@
}
createAndroidCheckstyle(project)
-version = "1.0.0-SNAPSHOT"
+version = LibraryVersions.LIFECYCLES.toString()