Skip to content

Commit

Permalink
Merge pull request #269 from google/wojtek-kalicinski-kotlin-rewrite
Browse files Browse the repository at this point in the history
Wojtek kalicinski kotlin rewrite
  • Loading branch information
davidmotson committed Aug 2, 2023
2 parents a7aa83d + 4eb653b commit b635f8f
Show file tree
Hide file tree
Showing 49 changed files with 6,214 additions and 853 deletions.
57 changes: 54 additions & 3 deletions google-services-plugin/README.md
Expand Up @@ -17,21 +17,72 @@ pluginManagement {
}
```

Apply the plugin in your app's build.gradle:
Apply the plugin in your app's build.gradle.kts:

```
plugins {
id("com.google.gms.google-services" version "5.0.0"
}
```

Or in build.gradle:
```
plugins {
id 'com.google.gms.google-services' version '4.3.15'
id 'com.google.gms.google-services' version '5.0.0'
}
```

### New in version 5.0.0

#### `google-services.json` location

Place the `google-services.json` file for your project in the `app/` directory.

Alternatively, you can use variant specific source-sets, for example:
`debug/google-services.json`.

#### Compatible Android plugins

The `com.google.gms.google-services` plugin can only be applied to projects with
`com.android.application` or `com.android.dynamic-feature`, as it requires an `applicationId`
to function.

The plugin is not compatible with plugins such as `com.android.library` that do not
contain an `applicationId`.

#### Plugin configuration

Configure the plugin's behavior through the `googleServices` block in build.gradle.kts:

```
googleServices {
// Disables checking of Google Play Services dependencies compatibility
// Default: false
disableVersionCheck = true
// Choose the behavior when google-services.json is missing:
// Default: MissingGoogleServicesStrategy.ERROR
// Possible options: IGNORE, WARN, ERROR
missingGoogleServicesStrategy = MissingGoogleServicesStrategy.WARN
}
```

You can use `missingGoogleServicesStrategy` when some variants in your project
do not require Google Play Services and are missing the `google-services.json` file.

#### Android Gradle plugin compatibility

The Google Services plugin requires AGP 7.3.0 or newer to work.

## Legacy way

Add the following to your buildscript classpath, obtained from Google’s
[Maven repository](//developer.android.com/studio/build/dependencies#google-maven):

```
classpath 'com.google.gms:google-services:4.3.15'
classpath 'com.google.gms:google-services:5.0.0'
```

Apply the plugin in your app's build.gradle:
Expand Down
42 changes: 0 additions & 42 deletions google-services-plugin/build.gradle

This file was deleted.

91 changes: 91 additions & 0 deletions google-services-plugin/build.gradle.kts
@@ -0,0 +1,91 @@
/*
* Copyright (C) 2023 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.
*/
plugins {
id("java-gradle-plugin")
id("org.jetbrains.kotlin.jvm") version "1.7.22"
id("com.gradle.plugin-publish") version "1.1.0"
}

group = "com.google.gms"
version = "5.0.0"

dependencies {
compileOnly(gradleApi())
implementation("com.android.tools.build:gradle-api:7.3.0")
implementation("com.google.android.gms:strict-version-matcher-plugin:1.2.4")
implementation("com.google.code.gson:gson:2.8.5")
implementation("com.google.guava:guava:27.0.1-jre")
testImplementation("junit:junit:4.12")
testImplementation("com.google.truth:truth:0.42")
}

gradlePlugin {
plugins {
create("googleServicesPlugin") {
id = "com.google.gms.google-services"
implementationClass = "com.google.gms.googleservices.GoogleServicesPlugin"
}
}
}

publishing {
repositories {
maven {
url = uri("${buildDir}/repo")
}
}
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}

kotlin {
jvmToolchain(11)
}

tasks.withType<Test>().configureEach {
// See GoogleServicesPluginTest.kt -> testResGeneration
dependsOn("publishAllPublicationsToMavenRepository")
}

tasks.withType<Jar>().configureEach {
from("LICENSE")
}

java {
withJavadocJar()
withSourcesJar()
}

publishing {
publications {
create<MavenPublication>("pluginMaven") {
artifactId = "google-services"

pom {
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
}
}
}
}
@@ -1,4 +1,4 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
48 changes: 0 additions & 48 deletions google-services-plugin/publish.gradle

This file was deleted.

30 changes: 30 additions & 0 deletions google-services-plugin/settings.gradle.kts
@@ -0,0 +1,30 @@
/*
* Copyright (C) 2023 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.
*/
pluginManagement {
repositories {
mavenCentral()
google()
gradlePluginPortal()
}
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
google()
}
}

0 comments on commit b635f8f

Please sign in to comment.