Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pin maven-resources-plugin 2.6 #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

milahu
Copy link

@milahu milahu commented Aug 3, 2023

fix build with latest nixpkgs and latest jdk

build error was:

Plugin org.apache.maven.plugins:maven-resources-plugin:3.3.0 or one of its dependencies could not be resolved

adding missing dependencies to mvn2nix-lock.json does not help, the build fails with another error:

Error injecting: org.apache.maven.plugins.resources.ResourcesMojo
Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.3.0:resources (default-resources) on project mvn2nix
No implementation for MavenResourcesFiltering was bound.

im using mvn2nix in my nur-packages to build mwdumper:

fix build with latest nixpkgs and latest jdk

build error was:

> Plugin org.apache.maven.plugins:maven-resources-plugin:3.3.0 or one of its dependencies could not be resolved

adding missing dependencies to mvn2nix-lock.json does not help,
the build fails with another error:

> Error injecting: org.apache.maven.plugins.resources.ResourcesMojo
> Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.3.0:resources (default-resources) on project mvn2nix
> No implementation for MavenResourcesFiltering was bound.
milahu added a commit to milahu/nur-packages that referenced this pull request Aug 3, 2023
milahu added a commit to milahu/nur-packages that referenced this pull request Aug 3, 2023
milahu added a commit to milahu/nur-packages that referenced this pull request Aug 3, 2023
fix: Plugin org.apache.maven.plugins:maven-resources-plugin:3.3.0 or one of its dependencies could not be resolved

upstream PR: fzakaria/mvn2nix#57
@fzakaria
Copy link
Owner

fzakaria commented Aug 4, 2023

Looks like i have to update the test jobs. one sec

@milahu
Copy link
Author

milahu commented Jul 8, 2024

push

@fzakaria
Copy link
Owner

fzakaria commented Jul 8, 2024

What does push mean ?

@milahu
Copy link
Author

milahu commented Jul 9, 2024

this is still an issue when building mvn2nix with

mvn2nix.nix
# based on src/mvn2nix/default.nix
# avoid external sources: niv, nix-gitignore, nixpkgs
# fix: error: access to URI 'https://github.com/NixOS/nixpkgs/archive/a332da8588aeea4feb9359d23f58d95520899e3c.tar.gz' is forbidden in restricted mode
# avoid overlays

{ lib
, pkgs
, jdk_headless
}:

# create scope to override jdk
lib.makeScope pkgs.newScope (self: with self; rec {

  jdk = jdk_headless;

  mvn2nix = (self.callPackage ./src/mvn2nix/derivation.nix { }) // {
    # fix: error: attribute 'buildMavenRepositoryFromLockFile' missing
    # at pkgs/mwdumper/mwdumper.nix:
    #     mvn2nix.buildMavenRepositoryFromLockFile { file = ./mvn2nix-lock.json; };
    inherit buildMavenRepository buildMavenRepositoryFromLockFile;
  };

  mvn2nix-bootstrap = self.callPackage ./src/mvn2nix/derivation.nix { bootstrap = true; };

  buildMavenRepository =
    (self.callPackage ./src/mvn2nix/maven.nix { }).buildMavenRepository;

  buildMavenRepositoryFromLockFile =
    (self.callPackage ./src/mvn2nix/maven.nix { }).buildMavenRepositoryFromLockFile;

})

... called by default.nix

  # mvn2nix
  inherit (callPackage ./pkgs/development/tools/mvn2nix/mvn2nix.nix { })
    mvn2nix
    mvn2nix-bootstrap
    buildMavenRepository
    buildMavenRepositoryFromLockFile
  ;

... or (not-yet verified) when building mvn2nix
without the pinned nixpkgs from nix/sources.nix

default.nix.diff
--- a/default.nix
+++ b/default.nix
@@ -1,5 +1,6 @@
-{ nixpkgs ? (import ./nix/sources.nix).nixpkgs,
+{ pkgs ? (import ./nix/sources.nix).nixpkgs,
   system ? builtins.currentSystem }:
+let nixpkgs = pkgs; in
 let
   sources = import ./nix/sources.nix;
   pkgs = import nixpkgs {

... because nixpkgs has no nixpkgs attribute

$ nix repl
Welcome to Nix 2.18.2. Type :? for help.

nix-repl> :l <nixpkgs>      
Added 21357 variables.

nix-repl> nixpkgs
error: undefined variable 'nixpkgs'

       at «string»:1:1:

            1| nixpkgs
             | ^

nix-repl> builtins.length (builtins.attrNames pkgs)
21358

@fzakaria
Copy link
Owner

fzakaria commented Jul 9, 2024

Your fix helps?
I don't have any context anymore on this project; I'm looking for a maintainer.

I'm hesitant to merge but it looks safe.

@milahu
Copy link
Author

milahu commented Jul 9, 2024

works for me : )
i just stumbled over this bug again, and my patch still works

... or (not-yet verified) when building mvn2nix
without the pinned nixpkgs from nix/sources.nix

this requires either

nix-build -E 'with import <nixpkgs> { }; callPackage ./. { nixpkgs = <nixpkgs>; }'

or a default.nix without pinned nixpkgs

default.nix
{ pkgs ? null,
  # TODO remove the nixpkgs argument
  # because the pkgs argument is always set
  # so the `_pkgs == null` branch is not reachable
  nixpkgs ? (import ./nix/sources.nix).nixpkgs,
  system ? builtins.currentSystem }:
let _pkgs = pkgs; in
let
  sources = import ./nix/sources.nix;

  overlays = [
    (_: super: {
      niv = (import sources.niv { }).niv;
      # include local sources in your Nix projects, while taking gitignore files into account
      # https://github.com/hercules-ci/gitignore.nix
      gitignoreSource = (import sources.gitignore { inherit (super) lib; }).gitignoreSource;
    })
    (import ./overlay.nix)
  ];

  pkgs = (
    if _pkgs == null then import nixpkgs {
      inherit system; # TODO remove?
      inherit overlays;
    }
    else _pkgs.appendOverlays overlays
  );
in {
  mvn2nix = pkgs.mvn2nix;

  mvn2nix-bootstrap = pkgs.mvn2nix-bootstrap;

  buildMavenRepository = pkgs.buildMavenRepository;

  buildMavenRepositoryFromLockFile = pkgs.buildMavenRepositoryFromLockFile;
}

personally, i prefer unpinned nixpkgs with "update breakage" now and then
and "lets pin everything" should be reserved to nix flakes
but then, im a bad maintainer : P

@jsoo1
Copy link
Collaborator

jsoo1 commented Jul 16, 2024

Looks to me like maybe plugin dependencies are being excluded from maven's output now. So mvn2nix is skipping the plugin dependencies?

@jsoo1
Copy link
Collaborator

jsoo1 commented Jul 16, 2024

Maybe we also need to redo the bootstrap?

@jsoo1
Copy link
Collaborator

jsoo1 commented Jul 16, 2024

In any case, I think this shouldn't be merged.

@milahu
Copy link
Author

milahu commented Jul 17, 2024

so the pom.xml is a generated file, and the generator should be fixed?
i have zero experience with java, so im just guessing here

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