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.

FunTester
FunTester
FunTester
Why Java‑Groovy Builds Fail on Jenkins and How to Fix Them

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):

File structure after renaming to .groovy
File structure after renaming to .groovy

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.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaGradleGroovyJenkinsBuild ErrorMixed Language
FunTester
Written by

FunTester

10k followers, 1k articles | completely useless

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.