Giter Site home page Giter Site logo

Comments (7)

jschneider avatar jschneider commented on May 17, 2024 1

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

from refreshversions.

jmfayard avatar jmfayard commented on May 17, 2024

@jschneider can you try to create manually the Plugins object in the buildSrc and see if that works? Ideally both in a bruild.gradle and build.gradle.kts file
I remember that Gradle was really restrictive on what can be done in the plugins { ... } block, because they want to be able to parse it in a static matter in order to provide IDE support

from refreshversions.

jmfayard avatar jmfayard commented on May 17, 2024

@jschneider
Any reason to not include the version like this?

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

from refreshversions.

jschneider avatar jschneider commented on May 17, 2024

Good point. Thanks! Will give it a try.

from refreshversions.

jmfayard avatar jmfayard commented on May 17, 2024

@jschneider As a first step, I added an accessor for the plugin itself, so that it's easy to update its version.

#47

If you want to see if it can be generalized, look here

https://github.com/jmfayard/buildSrcVersions/blob/6a1afb4ec8b5c6c26d3d1b65f42b6e445332e93c/plugin/src/main/kotlin/de/fayard/KotlinPoetry.kt#L92-L102

from refreshversions.

jschneider avatar jschneider commented on May 17, 2024

One think about the version: The version can only be set once for a plugin (e.g. in the top level build.gradle.kts with apply false).

from refreshversions.

jmfayard avatar jmfayard commented on May 17, 2024

@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

from refreshversions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.