Task :buildSrc:compileJava FAILED

Hello.
I am newbee here and I am trying to install X-Road but I have problem with Gradle.
I have gradle -v

openjdk version "21.0.6" 2025-01-21
OpenJDK Runtime Environment (build 21.0.6+7-Ubuntu-124.04.1)
OpenJDK 64-Bit Server VM (build 21.0.6+7-Ubuntu-124.04.1, mixed mode, sharing)

------------------------------------------------------------
Gradle 4.4.1
------------------------------------------------------------

Build time:   2012-12-21 00:00:00 UTC
Revision:     none

Groovy:       2.4.21
Ant:          Apache Ant(TM) version 1.10.14 compiled on September 25 2023
JVM:          21.0.6 (Ubuntu 21.0.6+7-Ubuntu-124.04.1)
OS:           Linux 5.15.167.4-microsoft-standard-WSL2 amd64

gradle --status

   PID STATUS   INFO
  7158 IDLE     4.4.1

When I run install script I get

    Building locally...
     ./compile_code.sh: line 30: ./gradlew: cannot execute: required file not found
    *** Error running build of binaries.(tput sgr0)

and gradle --info

> Configure project :buildSrc
Evaluating project ':buildSrc' using build file '/mnt/c/GIT/X-Road/src/buildSrc/build.gradle'.

> Task :buildSrc:compileJava FAILED
Putting task artifact state for task ':buildSrc:compileJava' into context took 0.0 secs.
Up-to-date check for task ':buildSrc:compileJava' took 0.023 secs. It is not up-to-date because:
  Task has failed previously.
All input files are considered out-of-date for incremental task ':buildSrc:compileJava'.

ending with

/mnt/c/GIT/X-Road/src/buildSrc/src/main/java/org/niis/xroad/oasvalidatorplugin/Oas3Validator.java:69: error: cannot find symbol
    private static ApiValidationResult validateOpenApiSpec(File apiSpecFile) throws ResolutionException {
                                                                                    ^
  symbol:   class ResolutionException
  location: class Oas3Validator
12 errors

:compileJava (Thread[#198,Task worker for ':buildSrc',5,main]) completed. Took 0.471 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':buildSrc:compileJava'.
> Compilation failed; see the compiler error output for details.

What can I do?
Thank you in advance.

You should never use an installed gradle to build a Gradle project.
You don’t even need to have any Gradle version installed locally usually.
Each and every Gradle project should have the 4 Gradle wrapper files contained that define and manage which Gradle version the build is designed for, known compatible with, and used to execute the build.
Each project that does not have them imho has a build bug.

X-Road does have the Gradle wrapper files and declares that it uses Gradle 8.12, but you try to build it with an ancient Gradle 4.4.1.
Use gradlew from the project instead of gradle and it should most probably fix your problem.

1 Like

Thank you.
Ok. I have uninstalled gradle but now I have another problem with user/group

useradd: UID 1000 is not unique
The command '/bin/sh -c groupadd -o -g $gid builder && useradd -m -u $uid -g $gid builder   && mkdir -p /mnt/gradle-cache && chown -R builder:builder /mnt/gradle-cache' returned a non-zero code: 4
*** Error building build image.(tput sgr0)

But it is not gradle problem.

Exactly, that is something in their docker files and you have to talk to them how to properly build their software :slight_smile: X-Road/src/packages/docker-compile/Dockerfile at c440bde0dd81010192b44bf0f5326148d7f43709 · nordic-institute/X-Road · GitHub