gradle-dependency-lock-plugin
gradle-dependency-lock-plugin copied to clipboard
"Gradlew -PdependencyLock.useGeneratedGlobalLock=true build" fails with exception
I am looking for available options for dependency locking and came across this today and looks interesting. I am playing around with this and got into below issue. We got many multiprojects and I applied this plugin to one of my projects on root level and then just tried below steps.
1. gradlew generateGlobalLock
Can see it generated "build\global.lock" with all dependencies I got with locked version.
2. gradlew -PdependencyLock.useGeneratedGlobalLock=true build
failing with below error
Caused by: java.lang.NullPointerException: Cannot get property 'path' on null object
at nebula.plugin.dependencylock.DependencyLockPlugin.apply(DependencyLockPlugin.groovy:83)
at nebula.plugin.dependencylock.DependencyLockPlugin.apply(DependencyLockPlugin.groovy)
at org.gradle.api.internal.plugins.ImperativeOnlyPluginApplicator.applyImperative(ImperativeOnlyPluginApplicator.java:35)
at org.gradle.api.internal.plugins.RuleBasedPluginApplicator.applyImperative(RuleBasedPluginApplicator.java:43)
at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
... 61 more
I also tried the same command after "saveGlobalLock" and still the same issue. I am going through the code to understand this better and came across this area of code which seems to be causing it.
if I understand this better, we are creating the "generateGlobalLock" task and then trying to get "getDependenciesLock().path". not sure, if this path will be available. As it looks like this is going to be null?
Please let me know if I am missing anything here.
if you save the lock you don't need to -PdependencyLock.useGeneratedGlobalLock=true by default we look in the project directory, the useGenerated flags tell us to look in the build directory
The fix is provided in this PR: https://github.com/nebula-plugins/gradle-dependency-lock-plugin/pull/113