From 4e3da39d5d6665d16cd04ce71c58e8566f20c3bb Mon Sep 17 00:00:00 2001 From: Manuel Vivo Date: Thu, 23 Jul 2020 09:40:40 +0200 Subject: [PATCH] [Crane] Adds buildSrc Change-Id: I2760f0488fce6fa02dabfc31eaa45bcf4fb039d6 --- Crane/app/build.gradle | 51 +++++++------- Crane/build.gradle | 41 +++++++++++ Crane/build.gradle.kts | 53 -------------- Crane/buildSrc/.gitignore | 1 + Crane/buildSrc/build.gradle.kts | 25 +++++++ .../example/crane/buildsrc/Dependencies.kt | 69 +++++++++++++++++++ 6 files changed, 164 insertions(+), 76 deletions(-) create mode 100644 Crane/build.gradle delete mode 100644 Crane/build.gradle.kts create mode 100644 Crane/buildSrc/.gitignore create mode 100644 Crane/buildSrc/build.gradle.kts create mode 100644 Crane/buildSrc/src/main/java/com/example/crane/buildsrc/Dependencies.kt diff --git a/Crane/app/build.gradle b/Crane/app/build.gradle index c2945c76b0..0e3d048138 100644 --- a/Crane/app/build.gradle +++ b/Crane/app/build.gradle @@ -1,5 +1,3 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - /* * Copyright 2019 Google, Inc. * @@ -16,19 +14,24 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile * limitations under the License. */ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' +import com.example.crane.buildsrc.Libs +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + id 'com.android.application' + id 'kotlin-android' +} // Reads the Google maps key that is used in the AndroidManifest Properties properties = new Properties() properties.load(project.rootProject.file("local.properties").newDataInputStream()) android { - compileSdkVersion 29 + compileSdkVersion 30 defaultConfig { applicationId "androidx.compose.samples.crane" minSdkVersion 21 - targetSdkVersion 29 + targetSdkVersion 30 versionCode 1 versionName "1.0" vectorDrawables.useSupportLibrary = true @@ -55,13 +58,16 @@ android { compose true } composeOptions { - kotlinCompilerVersion "1.4.0-dev-withExperimentalGoogleExtensions-20200720" - kotlinCompilerExtensionVersion "0.1.0-SNAPSHOT" + kotlinCompilerVersion Libs.AndroidX.Compose.kotlinCompilerVersion + kotlinCompilerExtensionVersion Libs.AndroidX.Compose.version } } tasks.withType(KotlinCompile).configureEach { kotlinOptions { + // Treat all Kotlin warnings as errors + allWarningsAsErrors = true + jvmTarget = "1.8" freeCompilerArgs += ["-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check"] } @@ -72,25 +78,24 @@ configurations { } dependencies { - implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4-M3' - implementation 'com.google.android.gms:play-services-maps:17.0.0' + implementation Libs.Kotlin.stdlib + implementation Libs.googleMaps - def composeVersion = "0.1.0-SNAPSHOT" - implementation "androidx.compose.runtime:runtime:$composeVersion" - implementation "androidx.compose.material:material:$composeVersion" - implementation "androidx.compose.foundation:foundation:$composeVersion" - implementation "androidx.compose.foundation:foundation-layout:$composeVersion" - implementation "androidx.compose.animation:animation:$composeVersion" - implementation "androidx.ui:ui-tooling:$composeVersion" + implementation Libs.AndroidX.Compose.runtime + implementation Libs.AndroidX.Compose.foundation + implementation Libs.AndroidX.Compose.material + implementation Libs.AndroidX.Compose.layout + implementation Libs.AndroidX.Compose.animation + implementation Libs.AndroidX.UI.tooling - implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0' - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'androidx.activity:activity-ktx:1.1.0' - implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' + implementation Libs.AndroidX.appcompat + implementation Libs.AndroidX.Lifecycle.viewModelKtx + implementation Libs.AndroidX.activityKtx + implementation Libs.AndroidX.Lifecycle.extensions - implementation 'com.squareup.picasso:picasso:2.71828' + implementation Libs.picasso - ktlint "com.pinterest:ktlint:0.37.2" + ktlint Libs.ktLint } task ktlint(type: JavaExec, group: "verification") { diff --git a/Crane/build.gradle b/Crane/build.gradle new file mode 100644 index 0000000000..5e0d0493f9 --- /dev/null +++ b/Crane/build.gradle @@ -0,0 +1,41 @@ +/* + * Copyright 2020 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 + * + * https://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 com.example.crane.buildsrc.Libs +import com.example.crane.buildsrc.Urls + +buildscript { + repositories { + google() + jcenter() + maven { url Urls.kotlinEap } + } + dependencies { + classpath Libs.androidGradlePlugin + classpath Libs.Kotlin.gradlePlugin + } +} + +subprojects { + repositories { + google() + jcenter() + maven { url Urls.kotlinEap } + if (Libs.AndroidX.Compose.version.endsWith("SNAPSHOT")) { + maven { url Urls.snapshotUrl } + } + } +} \ No newline at end of file diff --git a/Crane/build.gradle.kts b/Crane/build.gradle.kts deleted file mode 100644 index 13a5ffa2df..0000000000 --- a/Crane/build.gradle.kts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2019 Google, Inc. - * - * 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. - */ - -buildscript { - repositories { - google() - jcenter() - maven { - url = uri("https://dl.bintray.com/kotlin/kotlin-eap/") - } - } - - dependencies { - classpath("com.android.tools.build:gradle:4.2.0-alpha05") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4-M3") - } -} - -allprojects { - - // Compose dev15 - val snapshotUrl = - "https://androidx-dev-prod.appspot.com/snapshots/builds/6695716/artifacts/ui/repository/" - repositories { - maven { - url = uri(snapshotUrl) - } - google() - jcenter() - maven { - url = uri("https://dl.bintray.com/kotlin/kotlin-eap/") - } - } - tasks.withType().configureEach { - kotlinOptions { - // Treat all Kotlin warnings as errors - allWarningsAsErrors = true - } - } -} diff --git a/Crane/buildSrc/.gitignore b/Crane/buildSrc/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/Crane/buildSrc/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/Crane/buildSrc/build.gradle.kts b/Crane/buildSrc/build.gradle.kts new file mode 100644 index 0000000000..2567fced51 --- /dev/null +++ b/Crane/buildSrc/build.gradle.kts @@ -0,0 +1,25 @@ +/* + * Copyright 2020 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 + * + * https://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 org.gradle.kotlin.dsl.`kotlin-dsl` + +repositories { + jcenter() +} + +plugins { + `kotlin-dsl` +} diff --git a/Crane/buildSrc/src/main/java/com/example/crane/buildsrc/Dependencies.kt b/Crane/buildSrc/src/main/java/com/example/crane/buildsrc/Dependencies.kt new file mode 100644 index 0000000000..25ec39d6a0 --- /dev/null +++ b/Crane/buildSrc/src/main/java/com/example/crane/buildsrc/Dependencies.kt @@ -0,0 +1,69 @@ +/* + * Copyright 2020 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 + * + * https://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 com.example.crane.buildsrc + +object Versions { + const val ktLint = "0.37.2" +} + +object Libs { + const val androidGradlePlugin = "com.android.tools.build:gradle:4.2.0-alpha05" + const val ktLint = "com.pinterest:ktlint:${Versions.ktLint}" + const val picasso = "com.squareup.picasso:picasso:2.71828" + const val googleMaps = "com.google.android.gms:play-services-maps:17.0.0" + + object Kotlin { + private const val version = "1.4-M3" + const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version" + const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$version" + const val extensions = "org.jetbrains.kotlin:kotlin-android-extensions:$version" + } + + object AndroidX { + const val appcompat = "androidx.appcompat:appcompat:1.3.0-alpha01" + const val activityKtx = "androidx.activity:activity-ktx:1.1.0" + + object Compose { + const val snapshot = "6695716" + const val version = "0.1.0-SNAPSHOT" + + const val kotlinCompilerVersion = "1.4.0-dev-withExperimentalGoogleExtensions-20200720" + const val runtime = "androidx.compose.runtime:runtime:$version" + const val material = "androidx.compose.material:material:$version" + const val foundation = "androidx.compose.foundation:foundation:$version" + const val layout = "androidx.compose.foundation:foundation-layout:$version" + const val animation = "androidx.compose.animation:animation:$version" + } + + object UI { + const val tooling = "androidx.ui:ui-tooling:${Compose.version}" + } + + object Lifecycle { + private const val version = "2.2.0" + + const val viewModelKtx = "androidx.lifecycle:lifecycle-viewmodel-ktx:$version" + const val extensions = "androidx.lifecycle:lifecycle-extensions:$version" + } + } +} + +object Urls { + const val kotlinEap = "https://dl.bintray.com/kotlin/kotlin-eap/" + const val snapshotUrl = "https://androidx-dev-prod.appspot.com/snapshots/builds/" + // Dev15 + "${Libs.AndroidX.Compose.snapshot}/artifacts/ui/repository/" +} \ No newline at end of file