Skip to content

remove gradle flag --console=plain#78

Closed
milahu wants to merge 1 commit intotadfisher:v2from
milahu:pull69-patch1
Closed

remove gradle flag --console=plain#78
milahu wants to merge 1 commit intotadfisher:v2from
milahu:pull69-patch1

Conversation

@milahu
Copy link

@milahu milahu commented Oct 15, 2024

the option --console=plain makes gradle fail with

Multiple arguments were provided for command-line option

because gradleSetupHook already adds --console plain since 2024-07-12

see also gradle/gradle#30913

FIXME update nixpkgs in flake.lock
this error only happens when calling gradle2nix from non-flake nix

@milahu milahu mentioned this pull request Oct 15, 2024
@tadfisher
Copy link
Owner

Fixed by dff8e5b

@tadfisher tadfisher closed this Jan 17, 2025
@nhooey
Copy link

nhooey commented Jul 27, 2025

Fixed by dff8e5b

How is this fixed by that change? I'm still getting the problem when building XTDB 2.0 that I added a Nix Flake to.

@milahu
Copy link
Author

milahu commented Jul 27, 2025

I'm still getting the problem

sure you are using the v2 branch with dff8e5b?

@nhooey
Copy link

nhooey commented Jul 27, 2025

@milahu: Yes I'm using that branch. I patched gradle2nix to get it working: by adding code to the setup-hook.sh shell script to strip the command-line option and value from the parameters.

Removing "--console=plain" from nix/build-gradle-package.nix had no effect.

I couldn't find console or plain anywhere in the gradle2nix v2 source code, or the xtdb 2.0.x code, so I have no idea where that duplicated --console parameter is coming from...

@nhooey
Copy link

nhooey commented Jul 27, 2025

sure you are using the v2 branch with dff8e5b?

Although, in that commit you linked, the unwrapped parameter is now gone in the v2 branch.

Although that doesn't matter because that package is only being called with an empty attribute set:

buildGradlePackage = callPackage ./build-gradle-package.nix { };

@milahu
Copy link
Author

milahu commented Jul 27, 2025

you can try postUnpack = "set -x"; or postPatch = "set -x";
to find the sources of the duplicate --console parameters in gradleFlags

the unwrapped parameter is now gone in the v2 branch

there never was an unwrapped parameter

dff8e5b uses gradle.passthru.unwrapped from
nixpkgs/pkgs/development/tools/build-managers/gradle/default.nix

      let
        gradle = gradle-unwrapped.override args;
      in
      # ...
        passthru = {
          # ...
          unwrapped = gradle;

nit: your remove_option_and_value function
works on --console plain but fails on --console=plain

if [ "${array_ref[$i]}" = "$option_to_remove" ]; then

I'm still getting the problem when building XTDB 2.0

feel free to share your code if youre stuck

non-flake example use of gradle2nix in my nur-packages:
gradle2nix.nix and gumtree.nix

@nhooey
Copy link

nhooey commented Jul 27, 2025

you can try postUnpack = "set -x"; or postPatch = "set -x";

The Bash was just a fix to continue for now. I'll find out where the extra command-line options are coming from. Thanks for the tip!

feel free to share your code if youre stuck

Thanks again! I have the XTDB database project almost building, it seems that gradle2nix is missing some libraries that I added to the gradle.lock file manually, but gradle isn't finding the libraries during nix build. Is there a bug in gradle2nix?

This is the XTDB 2.0.x_nix branch that I'm working on.

To see my commits just compare it to the 2.0.x branch:

git log --stat -p 2.0.x..2.0.x_nix

I also had to install protobuf as a nativeBuildInput because the gradle plugin for it was downloading.

I put some comments in the flake.nix file to show what I'm doing to build.

@nhooey
Copy link

nhooey commented Jul 28, 2025

Never mind about my build failures for the xtdb repository.

I added an extra build value to the command-line of xtdb:v2's flake.nix file, which added a lot of extra tasks for the nix build part, so many libraries didn't get included in gradle.lock.

@milahu
Copy link
Author

milahu commented Jul 28, 2025

the 2.0.x branch seems outdated

This branch is 9 commits ahead of, 138 commits behind main

v2.0.0 is on the main branch

building xtdb is the easy part, see xtdb.nix
(sorry i didnt debug your flake.nix)

installing and running xtdb is the hard part...

most jar files dont works with java -jar $jar

$ java -jar ./result/opt/xtdb/http-server/build/libs/xtdb-http-server-2.0.0-SNAPSHOT.jar
no main manifest attribute, in ./result/opt/xtdb/http-server/build/libs/xtdb-http-server-2.0.0-SNAPSHOT.jar

the "standalone" jar file does not work

$ java -jar ./result/opt/xtdb/docker/standalone/build/libs/xtdb-standalone.jar
Clojure 1.12.0
user=> (dev)
Syntax error compiling at (REPL:1:1).
Unable to resolve symbol: dev in this context
user=> (go)
Syntax error compiling at (REPL:1:1).
Unable to resolve symbol: go in this context

im trying to replicate ./gradlew :clojureRepl

docs are not helpful

maybe you know more to get this running
expected: $out/bin/xtdb should run the database server

@nhooey
Copy link

nhooey commented Jul 28, 2025

How did you get the gradle2nix locking to include all of the libraries that are needed to build?
I'm having to insert a lot of files manually...

@nhooey
Copy link

nhooey commented Jul 28, 2025

the "standalone" jar file does not work

The XTDB v2.0.0 Dockerfile has the parameters you need to get it running.

(I haven't confirmed that it actually works, I just found it.)

@milahu
Copy link
Author

milahu commented Aug 12, 2025

its still a mystery why this works with nix-build and breaks with nix flake

it seems like gradle.passthru.unwrapped is not passed to gradle2nix

debug: require gradle.passthru.unwrapped in gradle2nix/nix/gradle-setup-hook.nix

   gradle-unwrapped =
-    if gradle ? passthru && gradle.passthru ? unwrapped then gradle.passthru.unwrapped else gradle;
+    gradle.passthru.unwrapped;

in contrast, removing the --console=plain flag does work in 8f20348 and 40abf29

alternative: replace --console=plain with -Dorg.gradle.console=plain (#92)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants