play-services-plugins icon indicating copy to clipboard operation
play-services-plugins copied to clipboard

Fully support standard Gradle plugins block

Open bubenheimer opened this issue 2 years ago • 2 comments

Describe the bug It appears that it is still necessary to use the antiquated style of loading oss-licenses-plugin via a buildscript classpath definition in the project root build.gradle, instead of the standard plugins block.

This is what I'd expect to use in project root build.gradle, similar to how I'd apply the plugin at the module level as described here: https://developers.google.com/android/guides/opensource#add-gradle-plugin

buildscript {
    repositories {
        google()
    }
}

plugins {
    id("com.google.android.gms.oss-licenses-plugin") version("0.10.5") apply(false)
}

However this produces an error:

org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.google.android.gms.oss-licenses-plugin', version: '0.10.5', apply: false] was not found in any of the following sources:

Instead I still have to use

buildscript {
    repositories {
        google()
    }

    dependencies {
        classpath("com.google.android.gms:oss-licenses-plugin:0.10.5")
    }
}

Gradle 7.4.2 Android Gradle plugin 7.1.3

bubenheimer avatar Apr 16 '22 15:04 bubenheimer

Link #50, still blocking on #222, provide a workaround, you can configure a resolutionStrategy in settings.gradle like:

pluginManagement {
    repositories {
        google()
    }
    resolutionStrategy {
        eachPlugin {
            if (requested.id.id == "com.google.android.gms.oss-licenses-plugin") {
                useModule("com.google.android.gms:oss-licenses-plugin:${requested.version}")
            }
        }
    }
}

Goooler avatar Sep 03 '22 16:09 Goooler

Great! Thank you for the workaround.

Here the plugin documentation how to publish the plugin.

emartynov avatar Mar 23 '23 14:03 emartynov