I have a project root
and project child
inside it. In root project file ‘settings.gradle.kts’ file contains plugin resolution code:
...
pluginManagement {
val kotlinVersion: String by settings
resolutionStrategy {
eachPlugin {
if (requested.id.id.startsWith("org.jetbrains.kotlin")) {
useVersion(kotlinVersion)
return@eachPlugin
}
}
}
}
...
In gradle.properties
in root
project I have vrsion of plugin:
kotlinVersion=1.3.71
But if I run from root/child
command gradle wrapper --gradle-version 6.4.1
I get:
FAILURE: Build failed with an exception.
* Where:
Build file '/prj/root/child/build.gradle.kts' line: 6
* What went wrong:
Plugin [id: 'org.jetbrains.kotlin.jvm'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (plugin dependency must include a version number for this source)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 379ms
My purpose - do not duplicate version of plugin in all my projects, and store it in one place. But in this case I can’t call directly tasks in my subprojects. Build from subproject does not works too, but all works fine if I run build from root
.
How to do version resolution correctly? Store plugins version in one place and make in working in subprojects too, not only in root project.