Both script and plugin assemblies make the same error. They print the version as part of the task settings, and do not give the task behavior (task action). If the plugin is used before the version is installed in the script assembly (as it usually happens), it will display the previous value of the property version(perhaps one of them is set to gradle.properties).
Correct task declaration:
task printVersion {
// any code that goes here is part of configuring the task
// this code will always get run, even if the task is not executed
doLast { // add a task action
// any code that goes here is part of executing the task
// this code will only get run if and when the task gets executed
println project.version
}
}
.