Skip to content

Conversation

@player-03
Copy link
Contributor

This allows including published plugins or custom user-created ones. Since plugins can make arbitrary changes to the build script, this allows multiple extensions to add to app/build.gradle without overwriting each other's changes.

https://docs.gradle.org/current/userguide/plugins.html
https://docs.gradle.org/current/userguide/sharing_build_logic_between_subprojects.html

Sample usage: <config:android gradle-apply-plugin="com.google.gms.google-services" />

From a quick search, there seem to be two ways to include a plugin. apply plugin is the more backwards-compatible option, so I went with that. However, plugin { } could be more future-proof. Maybe at some point we'll switch.

My main concern for now is, is "gradle-apply-plugin" distinctive enough from "gradle-plugin"? Or would another name be clearer?

@IriySoft
Copy link

This allows including published plugins or custom user-created ones. Since plugins can make arbitrary changes to the build script, this allows multiple extensions to add to app/build.gradle without overwriting each other's changes.

https://docs.gradle.org/current/userguide/plugins.html https://docs.gradle.org/current/userguide/sharing_build_logic_between_subprojects.html

Sample usage: <config:android gradle-apply-plugin="com.google.gms.google-services" />

There should be a classpath dependency added in the build.gradle too, otherwise Gradle won't be able to apply the plugin with "Plugin with id 'com.google.gms.google-services' not found." exception. That in turn requires adding the repositories paths to the app-level build.gradle (these are currently not present there). Something like this:

import groovy.swing.SwingBuilder
import java.awt.GridBagLayout
import java.awt.GridBagConstraints
import javax.swing.border.EmptyBorder

buildscript {
  repositories {
    google()
    mavenCentral()
  }

  dependencies {
    classpath 'com.google.gms:google-services:4.4.4'
  }
}

apply plugin: 'com.android.application'

. . .

@player-03
Copy link
Contributor Author

That's a lot of changes, and I'd rather keep the config options simple. Can't you create your own plugin to do all that?

https://docs.gradle.org/current/userguide/sharing_build_logic_between_subprojects.html

@IriySoft
Copy link

That's a lot of changes, and I'd rather keep the config options simple. Can't you create your own plugin to do all that?

https://docs.gradle.org/current/userguide/sharing_build_logic_between_subprojects.html

I can try this indeed, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants