Could not get unknown property 'build' for root project

I am getting following error migrating gradle project from 5.5 to 8.5

* What went wrong:
A problem occurred evaluating root project 'buildNetworkShared'.
> Could not get unknown property 'build' for root project 'buildNetworkShared' of type org.gradle.api.Project.

Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'build' for root project 'NetworkShared' of type org.gradle.api.Project.
        at org.gradle.internal.metaobject.AbstractDynamicObject.getMissingProperty(AbstractDynamicObject.java:85)
        at org.gradle.groovy.scripts.BasicScript$ScriptDynamicObject.getMissingProperty(BasicScript.java:160)
        at org.gradle.internal.metaobject.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:62)
        at org.gradle.api.internal.project.DefaultDynamicLookupRoutine.property(DefaultDynamicLookupRoutine.java:31)
        at org.gradle.groovy.scripts.BasicScript.getProperty(BasicScript.java:69)
        at build_57wn2y7wraqqtt67jyettd6ss.run(D:\GIT\Java17\NetworkShared\build.gradle:77)
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
        ... 164 more

build.gradle contains

defaultTasks 'build'
apply plugin: 'maven-publish'

task buildNetworkShared ( dependsOn: [ 'getDependencies', 'Java:installanywhere:CustomCode:build' ] ) doLast {
	runMsBuild('ReBuild', vsSlnFile)
	runMsBuild64('ReBuild', vsSlnFile)
}

build.dependsOn buildNetqosShared

build.mustRunAfter(getDependencies)
build.mustRunAfter(setDebugMode)
build.mustRunAfter(setReleaseMode)
..

How to resolve with syntax change or deprecated features? Appreciate your help!

There is no syntax change.

Before,
you applied the maven plugin
which in turn applied the base plugin
which in turn applied the lifecycle-base plugin
which added the build task.

Now,
you apply the maven-publish plugin
which in turn only applies the publishing plugin.

So you simply no longer apply a plugin that adds the task you try to configure.

Thanks, things are working fine after removing plugin.

1 Like