Include plugin jar as dependency

Is there any easy way to include the jar for a plugin as a dependency?

e.g.:

plugins {
    id("com.example.plugin") version "1.0"
}

dependencies {
    implementation(pluginDependency("com.example.plugin"))
}

where pluginDependency("com.example.plugin") is a hypothetical method that returns a dependency on the jar (artifact) used for that plugin.

Usually a plugin Id is not the same as the plugins artifact.
For example the SonarQube Plugin:
https://plugins.gradle.org/plugin/org.sonarqube

plugins {
  id "org.sonarqube" version "2.8"
}

but the legacy declaration is:

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.8"
  }
}

apply plugin: "org.sonarqube"

This means if you want to develop your own plugin agains the sonarqube Api, you can declare:

repositories {
    gradlePluginPortal()
}
depdendencies {
    implementation 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.8'
}

hope this helps