I am trying to use mavenix
and am running into problems being that my “app” needs Java 17 and mavenix is stuck on 8.
I think the solution is to rebuild the package using 17, but I don’t really know how to do this.
Help!
I am trying to use mavenix
and am running into problems being that my “app” needs Java 17 and mavenix is stuck on 8.
I think the solution is to rebuild the package using 17, but I don’t really know how to do this.
Help!
I haven’t used mavenix before but ideally you should be able to override any of the functions to provide your own Java for Maven or JDK – perhaps with an overlay for https://github.com/nix-community/mavenix/blob/ce9ddfd7f361190e8e8dcfaf6b8282eebbb3c7cb/mavenix.nix
I haven’t used mavenix yet - the maven.buildMavenPackage
from nixpkgs was sufficient for my needs so far - might be worth a try?
First, use mvn2nix, and if that doesn’t work in the end, use maven.buildMavenPackage.
I haven’t used mvn2nix, because I saw Nixpkgs 23.11 manual | Nix & NixOS mentioned it is ‘no longer recommended’ - it’d be interesting to learn why you still prefer it?
Ah, I see. I wasn’t aware of that. I found that within mvn2nix, even if it might fail, I could specify more fine-grained build options compared to maven.buildMavenPackage. However, I recently managed to solve a Spring Boot issue using buildMavenPackage. I learned about this by, of course, taking a look at the nixpkgs code. Isn’t buildMavenPackage also built using mvn2nix? So, I practice with mvn2nix, and if I run into issues with the maven repo, I switch to using buildMavenPackage. I mentioned that mvn2nix allows for more option adjustments, but buildMavenPackage also allows for option adjustments. So I recommend trying to build basic ‘hello world’ code with mvn2nix first, and if that doesn’t work, then using buildMavenPackage.
Obviously, what’s above is not necessarily more accurate than the official manual; it’s just my thoughts based on personal experience. Also, personally, I wish gradle2nix could somehow be revived.
Sigh… Neither of them works with spring-boot again. Maybe someday, huh?
After clearing the cache with ‘sudo rm -rf /nix/store/.links’, the installation works well again… Probably there was an issue with the auto garbage collection, which seems to have prevented fetching the maven temp properly.
Could you create an issue with example code, a derivation and the steps to reproduce the problem? Or share them here?
Blockquote
sb-example = let
JDK = graalvm17-ce;
in
(if stdenv.isLinux then (stdenv.mkDerivation rec {
pname=“sb-example”;
version = “0.0.1”;
NAME = "${pname}-${version}";
src = ./.;
groupId = "org.plumpmath";
className = "Sb";
buildInputs = [ maven ];
nativeBuildInputs = [ JDK makeWrapper ];
dontFixup = true;
buildPhase =
''
mvn -X -Dmaven.repo.local=$out clean install spring-boot:repackage
'';
installPhase = ''
mkdir -p $out/bin
cp target/${NAME}.jar $out/
makeWrapper ${JDK}/bin/java $out/bin/spring-${pname} \
--add-flags "-jar $out/${NAME}.jar"
'';
}) else (maven.buildMavenPackage rec {
pname=“sb-example”;
version = “0.0.1”;
NAME = “${pname}-${version}”;
src = ./.;
mvnHash = “sha256-cKYXx1DER6Kqph8yyq5ZNqGnwMZZc8cryH852lXL9jg=”;
nativeBuildInputs = [ makeWrapper ];
installPhase = ‘’
mkdir -p $out/bin
cp target/${NAME}.jar $out/${pname}.jar
makeWrapper ${JDK}/bin/java $out/bin/spring-${pname}
–add-flags “-jar $out/${NAME}.jar”
‘’;
}));
Blockquote
Do you also have the code to go with this packaging?
I understand if you can’t share the code for your ‘actual’ project - does a minimal spring-boot project already show the problem?
I had this:
https://git.sr.ht/~tripleo/el-almost/tree/2023-09septagon-mvn2nix
(Please disregard the code )
I didn’t try buildMavenPackage
wiht it yet, I’ll do it soon.
I understand your fishing and open mind -.,- My problem is a different problem. That code works fine.
I just hope that in the nix ecosystem, a way to package both spring-boot and gradle Java projects made with gradle, as well as clojure/scala etc projects, and unify the jvm project can be completed. Our goals are the same.