Gradle groovy build-logic can't use any import statements
Hello, I am working on reworking a large buildscript. Trying to migrate it to build-logic so it can be reused between projects.
It functions fine at the gradle level, the build works. But in IntelliJ I can't import any classes, it results in "Cannot resolve symbol"
Is there any way to fix this? We have multiple on our project some of which (Me) uses Eclipse so I'd rather not switch to kotlin as that is not supported in any IDE besides IntelliJ.
It works if I put it in the app\build.gradle, but not in build-logic\convention\src\main\groovy\test.convention.gradle
Any help would be greatly appreciated, been bashing my head against gradle all week.
Upload id: 2026_08_23_23eEd3pbqbSDWnz73LSGEW (files: idea64_CUxLr5cDdq.png, gradle-build-logic-groovy.zip)

Please sign in to leave a comment.
LexManos This is a known limitation, tracked as IDEA-260351. A
*.gradleprecompiled script plugin is resolved against the build script classpath, not against the compile classpath of the module that holds it. Yourconventionmodule declarescommons-lang3and thegradleutilsplugin marker, so both classes are on that module's compile classpath, and the editor does not see that classpath. The import goes red,getByTypefalls back toObject, and every property access after that degrades. Gradle compiles the same file correctly, which matches what you see.Please vote and watch it for updates: Watching YouTrack issues.
There is no IDE-side setting that fixes it, but moving the logic out of the script does. Write the convention as a Groovy class that implements
Plugin<Project>underbuild-logic/convention/src/main/groovy, then register that class in agradlePlugin { plugins { ... } }block instead of relying on the*.gradlefile name. A.groovyfile is an ordinary module source, so the editor resolves it against the module's own dependencies.One
build-logic/conventionmodule, both variants importing the same two classes, one of them from the module's own source root: the*.gradlescript reportsCannot resolve symbolas an error on both import lines, and thePlugin<Project>class reports nothing. Gradle configures and runs both.It stays in Groovy, so it doesn’t push your Eclipse users to the Kotlin DSL, and the result is a plain plugin jar. I ran it on a minimal project rather than on yours.