question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for Gradle plugins using "id"

See original GitHub issue

I am using Kotlin as language and adding plugins by calling:

id("de.fayard.buildSrcVersions") version "0.4."

I am able to use the generated version number by calling:

id("de.fayard.buildSrcVersions") version Versions.de_fayard_buildsrcversions_gradle_plugin

Unfortunately the string “de.fayard.buildSrcVersions” is not created in Libs. What about creating a third object named “Plugins”?

Wish: id(Plugins.buildSrcVersions) version Versions.de_fayard_buildsrcversions_gradle_plugin

PS: Great plugin - I love the idea of autogenerating the files and adding comments for newer versions! That is really great!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jschneidercommented, Aug 10, 2019

Well, it does work with build.gradle.kts files.

I am creating the Plugins object currently. This is what I find very, very helpful:

import org.gradle.kotlin.dsl.kotlin
import org.gradle.plugin.use.PluginDependencySpec

object Plugins {
  const val dokka: String = "org.jetbrains.dokka"
  const val shadow: String = "com.github.johnrengelman.shadow"
  const val buildSrcVersions: String = "de.fayard.buildSrcVersions"
  const val kotlinxSerialization: String = "kotlinx-serialization"
  const val download: String = "de.undercouch.download"
}

inline val org.gradle.plugin.use.PluginDependenciesSpec.kotlinJvm: PluginDependencySpec
  get() = kotlin("jvm")

inline val org.gradle.plugin.use.PluginDependenciesSpec.kotlinStdLibJdk8: PluginDependencySpec
  get() = kotlin("stdlib-jdk8")

inline val org.gradle.plugin.use.PluginDependenciesSpec.kotlinMultiplatform: PluginDependencySpec
  get() = kotlin("multiplatform")

inline val org.gradle.plugin.use.PluginDependenciesSpec.kotlinxSerialization: PluginDependencySpec
  get() = id(Plugins.kotlinxSerialization)

inline val org.gradle.plugin.use.PluginDependenciesSpec.shadow: PluginDependencySpec
  get() = id(Plugins.shadow)

inline val org.gradle.plugin.use.PluginDependenciesSpec.launch4j: PluginDependencySpec
  get() = id(Plugins.launch4j)

inline val org.gradle.plugin.use.PluginDependenciesSpec.download: PluginDependencySpec
  get() = id(Plugins.download)

You get the idea? I use the string constants with “apply” and the extension methods within a “plugins” block

0reactions
jmfayardcommented, Aug 21, 2019

@jschneider I have no plans to have the plug-in generate a Plugins.kt file. Seems too hard to do correctly in all cases. Writing it manually like in your example is the best solution imho

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Gradle Plugins
You apply plugins by their plugin id, which is a globally unique identifier, or name, for plugins. Core Gradle plugins are special in...
Read more >
What the difference in applying gradle plugin - Stack Overflow
The plugins block is the newer method of applying plugins, and they must be available in the Gradle plugin repository. The apply approach...
Read more >
Gradle - Plugins - Tutorialspoint
Most of the plugins need the configuration support from the build script. The Gradle project has an associated ExtensionContainer object that helps to...
Read more >
Introduction to writing Gradle plugins - Tom Gregory
Gradle plugin configuration – sets an id of com.tomgregory.file-diff which we can use to reference the plugin in tests and in other projects ......
Read more >
5. Add Gradle Plugin with Dependencies - Spring Cloud
build.gradle plugins { id "groovy" // this will work only for GA versions of ... JUNIT ) and JUnit 5 are supported with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found