Could not get unknown property 'main' for SourceSet container of type org.gradle.api.internal.tasks.DefaultSourceSetContainer

While i am upgrading the project Gradle from 7.4.2 to 7.51, i get the following exception :Caused by: groovy.lang.MissingPropertyException: Could not get unknown property ‘main’ for SourceSet container of type org.gradle.api.internal.tasks.DefaultSourceSetContainer.
at org.gradle.internal.metaobject.AbstractDynamicObject.getMissingProperty(AbstractDynamicObject.java:85)
at org.gradle.internal.metaobject.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:62)
at org.gradle.api.internal.tasks.DefaultSourceSetContainer_Decorated.getProperty(Unknown Source)

Code inside the project : List sourceSets = composeClasspath ?
project.configurations.compileClasspath.allDependencies
.withType(ProjectDependency).dependencyProject.sourceSets.main :
[project.sourceSets.main]

You should not try to grab into other projects like that, it’s no wonder it breaks. :slight_smile:
You probably before got the dependency project configured before and thus the source set was created already, while now it is not the case anymore.

If you need things from other projects, you should use proper publication as described at Sharing outputs between projects