`gradlePluginPortal` missing from RepositoryType in RepositoryModel




I am building an Android Studio plugin that can inject dependencies into an Android project's build.gradle file. I am using `GradleBuildModel` and calling `gradleBuildModel.buildscript().repositories().repositories()` to get a list of `RepositoryModel`s that exist.


However, since `gradlePluginPortal()` is not one of the types for `RepositoryModel` (see https://github.com/JetBrains/android/blob/16d17317f2c44ec46e8cd2180faf9c349d381a06/gradle-dsl/src/com/android/tools/idea/gradle/dsl/api/repositories/RepositoryModel.java#L22-L28), it is not found in the following example, and the list contains only 2 entries for `google()` and `mavenCentral()`.


My plugin needs to add `gradlePluginPortal()` if it does not already exist. I think `gradlePluginPortal` should be added as one of the `RepositoryType`s. Otherwise, can you suggest what I can do instead?


buildscript {
    repositories {


Thanks so much

1 comment
Comment actions Permalink

indeed, gradlePluginPortal is not supported yet, thank you. I've created https://youtrack.jetbrains.com/issue/IDEA-294722

As a workaround for now, you can use raw dsl elements, something like this:

boolean isGradlePluginPresent = ((RepositoriesModelImpl)repositoriesModel)
.filter(e ->
(e instanceof GradleDslMethodCall) &&

and add like this

new GradleDslMethodCall(repositoriesModel.getRawElement(), GradleNameElement.empty(), "gradlePluginPortal"));


Please sign in to leave a comment.