Mustafa Ozhan
03/20/2023, 1:31 PMlibs
from gradle/libs.versions.toml
in pre-compiled scripts located in buildScr/src/main/kotlin
?CLOVIS
03/20/2023, 1:34 PMgradle/conventions
, it's the same in buildSrc
: https://gitlab.com/opensavvy/decouple/-/blob/110-gradle/gradle/conventions/settings.gradle.kts#L11Mustafa Ozhan
03/20/2023, 1:36 PMbuildScr/build.gradle.kts
that’s fine
but I want to reach it also inside
buildScr/src/main/kotlin/some.name.gradle.kts
CLOVIS
03/20/2023, 1:37 PMAdam S
03/20/2023, 1:37 PMMustafa Ozhan
03/20/2023, 1:38 PMVampire
03/20/2023, 2:08 PMMustafa Ozhan
03/20/2023, 2:39 PMJavier
03/20/2023, 2:54 PMVampire
03/20/2023, 3:13 PMMustafa Ozhan
03/20/2023, 9:18 PMhackaround
is still not enough to use in plugin
block right ? I confirm that I am now able to use libs in gradle file of included build but I can not use the libs inside plugins {…}
block, perhaps it is not integrated yet when the plugins
block is being read.
Maybe there is another hackaround
for that too ? 😄Adam S
03/20/2023, 9:58 PMHumphrey
03/20/2023, 10:06 PMVampire
03/20/2023, 11:19 PMMustafa Ozhan
03/21/2023, 9:11 AM[plugins]
from TOML file in my build.gradle
but it seems not possible,
I mean it is possible everywhere except
plugins {
// here is not possible
}
dependencies {
// here is possible
}
I think the reason is when the plugins
block is applied the version catalogs are not integrated yet.
I wanted to keep the name of pre-compiled plugins inside TOML file and avoid statically writingAdam S
03/21/2023, 9:15 AMplugins {}
block (see docs), you have to specify the plugin version in the dependencies block in buildSrc/build.gradle.kts
. And you can use version catalog to do that.buildSrc/build.gradle.kts
to specify the version of the external plugins
public fun DependencyHandlerScope.plugin(id: String, version: String): String =
"$id:$id.gradle.plugin:$version"
public fun DependencyHandlerScope.plugin(plugin: Provider<PluginDependency>): Provider<String> =
plugin.map { "${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version}" }
https://www.linen.dev/s/gradle-community/t/10015775/one-feature-that-i-liked-about-buildsrc-is-that-i-could-defi#3c55229f-e2d0-4cd6-bff8-8137a717bd53Mustafa Ozhan
03/21/2023, 10:45 AMVampire
03/21/2023, 10:53 AMMustafa Ozhan
03/21/2023, 10:53 AMVampire
03/21/2023, 10:53 AMMustafa Ozhan
03/21/2023, 10:57 AMbuildScr
, and your hack-around should work for that as wellVampire
03/21/2023, 11:09 AMbuildSrc
. That change is only about normal build script's plugins blocks.Mustafa Ozhan
03/21/2023, 11:11 AMAdam S
03/21/2023, 11:13 AMbuildSrc/src/main/kotlin/my-project-conventions.gradle.kts
. You can't use Plugin Aliases here, and even if you could, the plugins' coordinates would have to be defined in dependencies [}
in buildSrc/build.gradle.kts
anyway.
And regular build.gradle.kts
files
e.g.
• ./build.gradle.kts
• ./buildSrc/build.gradle.kts
• ./my-cool-subproject/build.gradle.kts
.
You can use plugin aliases in these since Gradle 7.3 or something. The bugfix in 8.1 is specifically about fixing an IDE warning.Mustafa Ozhan
03/21/2023, 11:21 AMbuildSrc/src/main/kotlin/my-project-conventions.gradle.kts
and it seems not possible to get plugins from version catalog in plugins
block, i just have to write it statically.
We wanted to share this module as git submodule between projects and then each project could have different plugin id with same name in TOML fileAdam S
03/21/2023, 11:22 AMMustafa Ozhan
03/21/2023, 11:38 AMAdam S
03/21/2023, 11:42 AMMustafa Ozhan
03/21/2023, 11:51 AMdetekt = { id = "detek-commercial" }
whereas some
detekt = {id = "detek-library" }
in their TOML file but their submodules will only use
plugins { id(libs.plugins.detekt.get().pluginId) }
in gradle, so TOML file of root project will help which scripts to be used over all submodulesAdam S
03/21/2023, 11:52 AMMustafa Ozhan
03/21/2023, 12:03 PMplugins
block, it will allow us to create only 1 PR with 1 file into main repo, instead of creating 4-5 PRs to different repositories modifying 40-50 different build.gradle files and replacing "detek-commercial"
to "detek-library"
Adam S
03/21/2023, 12:07 PMdetek-commercial
and detek-library
are two of your own convention plugins. I presume both apply Detekt, and each have some slightly different configuration based on the final product you want to build?Mustafa Ozhan
03/21/2023, 12:09 PMAdam S
03/21/2023, 12:11 PMMustafa Ozhan
03/21/2023, 12:12 PMAdam S
03/21/2023, 12:14 PMORG_GRADLE_PROJECT_
, or in a gradle.properties
file, or via the command lineMustafa Ozhan
03/21/2023, 12:18 PMAdam S
03/21/2023, 12:18 PMtestJavaLauncherVersion
variable to set the default Java launcher version for all test tasks
https://github.com/Kotlin/dokka/blob/e66f9d8711b5c1ba5e75fdcde8cfe998042c294a/build-logic/src/main/kotlin/org/jetbrains/conventions/base-java.gradle.kts#L25-L31Mustafa Ozhan
03/21/2023, 12:24 PMAdam S
03/21/2023, 12:26 PMJavier
03/21/2023, 12:36 PMMustafa Ozhan
03/21/2023, 12:43 PM