New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuring plugins versions #60
Comments
Hello, this is a good question. I don't really get why this works in Kotlin but not in Groovy.
The generated version is a static string I wonder if in Groovy this is compiled to Versions.INSTANCE.dependency_license_report |
@sigurdurrafn If you are using Gradle 5.6 or have the possibility to update, I would recommend to try the new Plugins version Management feature https://docs.gradle.org/5.6/userguide/plugins.html#sec:plugin_management
|
Yes, moving to 5.6 helps. I can now use Versions.kt for the version. It would be nice if we were also able to use a const for the library name:
but this solves my main concern, thanks! |
Good to know! I edited your ticket so that it can serve as documentation for people facing the same issue.
Maybe we can generate code that helps with this if we detect that Versions.currentGradleVersion >= 5.6. |
Yeah! Just switched to Gradle 5.6.2 in my ever-lasting quest not to repeat myself. My The next big step forward would be to replace the repeated Actually, I have not yet found a use for the |
Yes, a solution similar to this: #61
I don't think so, but they are inclueded in the |
If someone wants to work on this, I think we can copy the solution from here https://github.com/icerockdev/moko-mvvm |
Hmm, I took a peek at that and can't see the connection. Perhaps because I can't read Cyrillic? |
They do this: // settings.gradle.kts
pluginManagement {
resolutionStrategy.eachPlugin {
val module = Plugins.map[requested.id.id] ?: return@eachPlugin
useModule(module)
}
}
// buildSrc/src/main/kotlin/Plugins.kt
object Plugins {
const val android =
"com.android.tools.build:gradle:${Versions.Plugins.android}"
const val kotlin =
"org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.Plugins.kotlin}"
const val androidExtensions =
"org.jetbrains.kotlin:kotlin-android-extensions:${Versions.Plugins.androidExtensions}"
val map: Map<String, String> = mapOf(
"com.android.application" to Plugins.android,
"com.android.library" to Plugins.android,
"org.jetbrains.kotlin.multiplatform" to Plugins.kotlin,
"kotlin-kapt" to Plugins.kotlin,
"kotlin-android" to Plugins.kotlin,
"kotlin-android-extensions" to Plugins.androidExtensions
)
} |
Here are my 2c. gradle.properties: com.gradle.plugin-publish.version=0.10.1 settings.gradle.kts: fun PluginDependenciesSpec.idv(name: String) =
id(name) version (extra["$name.version"] as String)
pluginManagement {
plugins {
idv("com.gradle.plugin-publish")
}
}
|
@nkiesel , The plugin-relevant bits there are and |
The |
|
The good news is that I tried the propose solution with The bad news is that I have no idea on how to find which plugins are applied to a project. From
So for now I have now idea on how to generate the |
ok, I found a way so I have a prototype for this feature now |
Hmm, that seems unfortunate because |
Interesting. Couple of questions:
|
@nkiesel @tadfisher @tadfisher @sigurdurrafn |
To apply a plugin, we can use the plugins DSL https://docs.gradle.org/current/userguide/plugins.html#sec:plugins_block
The problem is replacing the hard-coded version
1.9
withVersions.gradle_license_report
does not work for Groovy files.Is there a workaround to be able to use buildSrcVersions for managing plugin dependencies as well as Library dependencies?
This is already done for the special case of buildSrcVersions itself (#47) , although that only works in .kts files.
The text was updated successfully, but these errors were encountered: