Why Java‑Groovy Builds Fail on Jenkins and How to Fix Them
The author encountered a "cannot find symbol" error when Java and Groovy code called each other, which worked locally but broke on Jenkins and Gradle builds, and solved it by renaming the file to .groovy and adding the Groovy plugin so Groovy compiles before Java.
When mixing Java and Groovy code, the author found that cross‑calls worked on the local machine but caused a "cannot find symbol" compilation error on Jenkins and when executing Gradle tasks.
错误: 找不到符号
import com.fission.alpha.base.Util;After consulting a colleague, the solution was to rename the problematic file with a .groovy extension and to apply the Groovy compilation plugin in build.gradle. This forces Gradle to compile Groovy sources first, after which Java sources can reference the generated classes without errors.
After the change, the project’s directory layout looks like the following (illustrated in the image):
The updated build.gradle includes the necessary plugins:
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'groovy'With these adjustments, the build succeeds both locally and on Jenkins, eliminating the symbol‑not‑found error.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
