I am currently updating my project and as one of the steps I am changing gradle files to use the plugins { id 'xxx' }
way instead of the legacy apply plugin 'xxx'
approach. I was able to migrate most of the imports to the new format, however I cannot add some plugins, as I am unable to find their gradle plugin ids.
For example, here are my old gradle files:
settings.gradle file
include ':app'
project's build.gradle file
buildscript {
repositories {
google()
mavenCentral()
(...)
}
dependencies {
(...)
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.0'
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.5'
}
}
(...)
module's build.gradle file
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.android.gms.oss-licenses-plugin'
(...)
And here are partially modified new gradle files:
settings.gradle file
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "xxxx"
include ':app'
project's build.gradle file
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.google.firebase.crashlytics' version '2.9.2' apply false
// DOESN'T WORK:
id 'com.google.android.gms.oss-licenses-plugin' version '0.10.5' apply false
}
(...)
module's build.gradle file
plugins {
id 'com.android.application'
id 'com.google.firebase.crashlytics'
// NEED TO SET SAME ID AS IN PROJECT'S GRADLE FILE PROBABLY:
id 'com.google.android.gms.oss-licenses-plugin'
(...)
}
Problem lays in how to get gradle plugin id for given plugin?
Many plugin installation instructions use the old apply plugin
approach and I don't want to mix both of them.
For example in case of Crashlytics with classpath of com.google.firebase:firebase-crashlytics-gradle
, the id is com.google.firebase.crashlytics
- how was I supposed to know that? I found this in one of the answers on Stackoverflow, but without information about how someone knew that.
Currently I am trying to add the oss-licenses-plugin and I am completly clueless as about how to find its gradle plugin id... Any suggestions?
Or maybe it is not guaranteed that every plugin added with use of classpath
can be translated to the new plugins { }
way? In this case, how can I tell it is this situation?
com.google.android.gms.oss-licenses-plugin
which should be converted tocom.google.android.gms.oss.licenses.plugin
according to the directory structure and it is not working. – Enosiscom.google.android.gms.oss-licenses-plugin
followingcom.android.application
prior tocom.google.firebase.crashlytics
- see whether that helps - otherwise I am just as stumped – Reuven