CrazyChaoz / gradle-dot-nix

This flake can generate the full maven repo required to build a gradle app from gradle/verification-metadata.xml, all in the sandbox, without code generation.
MIT License
4 stars 2 forks source link

Basic Spring Boot Project wont build #2

Closed eeedean closed 6 months ago

eeedean commented 6 months ago

I tried building a basic Spring Boot Application analogue to the example. However, the build of the gradle init script fails with an error for a couple dependencies:

HikariCP> Traceback (most recent call last):
HikariCP>   File "/private/tmp/nix-build-HikariCP-5.0.1.jar.drv-0/3rn3aq3mxc2w9zs33l8gm99a5dj83dqm-source/fetch-gradle-dependency.py", line 69, in <module>
HikariCP>     download_artifact(sys.argv[1], sys.argv[3], sys.argv[4], sys.argv[5], sys.argv[6], sys.argv[7], sys.argv[8],
HikariCP>                                                 ~~~~~~~~^^^
HikariCP> IndexError: list index out of range
accessors-smart> Traceback (most recent call last):
accessors-smart>   File "/private/tmp/nix-build-accessors-smart-2.5.0.jar.drv-0/3rn3aq3mxc2w9zs33l8gm99a5dj83dqm-source/fetch-gradle-dependency.py", line 69, in <module>
accessors-smart>     download_artifact(sys.argv[1], sys.argv[3], sys.argv[4], sys.argv[5], sys.argv[6], sys.argv[7], sys.argv[8],
accessors-smart>                                                 ~~~~~~~~^^^
accessors-smart> IndexError: list index out of range
accessors-smart> Traceback (most recent call last):
accessors-smart>   File "/private/tmp/nix-build-accessors-smart-2.5.0.pom.drv-0/3rn3aq3mxc2w9zs33l8gm99a5dj83dqm-source/fetch-gradle-dependency.py", line 69, in <module>
accessors-smart>     download_artifact(sys.argv[1], sys.argv[3], sys.argv[4], sys.argv[5], sys.argv[6], sys.argv[7], sys.argv[8],
accessors-smart>                                                 ~~~~~~~~^^^
accessors-smart> IndexError: list index out of range
error: builder for '/nix/store/jbbf98n73ngmpk5vwdkcwgr7ddn94y1i-HikariCP-5.0.1.jar.drv' failed with exit code 1;
       last 10 log lines:
       > Running phase: configurePhase
       > no configure script, doing nothing
       > Running phase: buildPhase
       > no Makefile or custom buildPhase, doing nothing
       > Running phase: installPhase
       > Traceback (most recent call last):
       >   File "/private/tmp/nix-build-HikariCP-5.0.1.jar.drv-0/3rn3aq3mxc2w9zs33l8gm99a5dj83dqm-source/fetch-gradle-dependency.py", line 69, in <module>
       >     download_artifact(sys.argv[1], sys.argv[3], sys.argv[4], sys.argv[5], sys.argv[6], sys.argv[7], sys.argv[8],
       >                                                 ~~~~~~~~^^^
       > IndexError: list index out of range
       For full logs, run 'nix log /nix/store/jbbf98n73ngmpk5vwdkcwgr7ddn94y1i-HikariCP-5.0.1.jar.drv'.
error: 1 dependencies of derivation '/nix/store/1kniwrgx1ni799yzbpdrz5ihwya5j2m3-HikariCP-5.0.1.jar.drv' failed to build
error: 1 dependencies of derivation '/nix/store/86j8d0ip418kz4dkbmq0fjsab2pdyprq-maven-repo.drv' failed to build
error: 1 dependencies of derivation '/nix/store/banxwk0nqfl35k1b2rw1l6a5h5mhbpp8-init.gradle.kts.drv' failed to build
error: 1 dependencies of derivation '/nix/store/gw4m6fg12kizwjnbi91zd49jhxm5i0mp-inventory-backend.drv' failed to build

A complete error log may be seen here.

To reproduce, you can clone my Git Repository and run nix build .#application -v in the project root.

Unfortunately I did not yet figure out, what's the reason for the failure.

Looking forward to your assistance and thanks for your time!

CrazyChaoz commented 6 months ago
  1. PLEASE DON'T DO TRAILING COMMAS IN PLAIN JSON it is not meant for it, parsers have issues with it, my parser has issues with it, i have not found an ultra-simple, similar performant solution (maybe I should use yaml parsers)

  2. the gradle wrapper tries to fetch the latest version, so try to use the pkgs.gradle binary if possible

  3. there should be no need for __noChroot = true;

  4. I improved the syntax for custom repos, they now work the way you specified them

  5. there is still something funky going on with the spring boot dependencies. I cannot query those that are not in the gradle verification metadata, yet i fear spring does exactly that. if that is the case I'll have to write a script to add those deps to the metadata afterwards.

CrazyChaoz commented 6 months ago

OK, I got your project to build, I guess.

Its currently failing the tests with java.lang.IllegalStateException: Could not find a valid Docker environment

I need to tweak the initscript a bit, since I only got it to work when I switched to manual maven repo generating and adding it to both settings.gradle and build.gradle

eeedean commented 6 months ago

there should be no need for __noChroot = true;

Yeah, that's not required anymore!

Its currently failing the tests with java.lang.IllegalStateException: Could not find a valid Docker environment

The JUnit Tests contained require a Docker Environment. That's why I run them in the checks with a NixOS qemu-kvm machine, which has a Docker environment enabled. You can just skip tests for build time with -x test.

Can you go into detail, what changes you did to the project in order to get it to build?

Thanks a lot for your efforts!

CrazyChaoz commented 6 months ago
  1. remove trailing comma
  2. replace __noChroot = true; with src = self;
  3. buildInputs = [ pkgs.openjdk17 pkgs.gradle];
  4. use gradle instead of ./gradlew

And the rest was on my side, so you need a quick nix flake update gradle-dot-nix