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

Dependencies shared with mvn2nix itself do not have URLs in output #19

charles-dyfis-net opened this Issue Nov 29, 2018 · 3 comments


None yet
1 participant

charles-dyfis-net commented Nov 29, 2018

Given the following POM:

<?xml version="1.0" encoding="UTF-8"?><project xmlns="" xmlns:xsi="" xsi:schemaLocation="">
  <description>A demonstration</description>

...the generated project-info.json references several artifacts which are not given URLs:

$ mvn org.nixos.mvn2nix:mvn2nix-maven-plugin:mvn2nix &>/dev/null && jq -r '.dependencies[] | select(.url? == null) | [.groupId, .artifactId, .version, .extension] | join(":")' <project-info.json

This is a strict subset of the dependency tree of the mvn2nix plugin itself, as shown by the following code:

(cd ~/VC/mvn2nix-maven-plugin &&
  mvn org.nixos.mvn2nix:mvn2nix-maven-plugin:mvn2nix >&2 &&
  { jq -r '.dependencies[] | [.groupId, .artifactId, .version, .extension] | join(":")' | sort; } <project-info.json >all-deps.txt
(cd ~/VC/mvnTest &&
  mvn org.nixos.mvn2nix:mvn2nix-maven-plugin:mvn2nix >&2 &&
  { jq -r '.dependencies[] | select(.url? == null) | [.groupId, .artifactId, .version, .extension] | join(":")' | sort; } <project-info.json >no-url-deps.txt
comm -13 ~/VC/mvn2nix-maven-plugin/all-deps.txt ~/VC/mvnTest/no-url-deps.txt

...which returns 0 (as the number of lines in no-url-deps.txt but not also in all-deps.txt).

@charles-dyfis-net charles-dyfis-net changed the title from Dependencies of mvn2nix itself do not have URLs in output to Dependencies shared with mvn2nix itself do not have URLs in output Nov 29, 2018


This comment has been minimized.

charles-dyfis-net commented Nov 29, 2018

...and, just to be clear that (some of) these items being missing represents a problem:

[chaduffy@app-build-04:~/VC/mvnTest]$ nix repl
Welcome to Nix version 2.1.3. Type :? for help.

nix-repl> :l ../nixpkgs/default.nix
Added 9721 variables.

nix-repl> :b (pkgs.buildMaven ./project-info.json).build
builder for '/nix/store/xcf18ykbx05ml0xa7dk5s2clj1xqjn2d-mvnTest-0.0.1-SNAPSHOT.jar.drv' failed with exit code 1; last 10 log lines:
  [INFO] Total time: 0.216 s
  [INFO] Finished at: 2018-11-29T22:26:05Z
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal on project mvnTest: Could not resolve dependencies for project mvnTest:mvnTest:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at org.clojure:tools.reader:jar:0.10.0: Failed to read artifact descriptor for org.clojure:tools.reader:jar:0.10.0: Cannot access central ( in offline mode and the artifact org.sonatype.oss:oss-parent:pom:7 has not been downloaded from it before. -> [Help 1]
  [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
  [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  [ERROR] For more information about the errors and possible solutions, please read the following articles:
  [ERROR] [Help 1]
[0 built (1 failed), 0.0 MiB DL]
error: build of '/nix/store/xcf18ykbx05ml0xa7dk5s2clj1xqjn2d-mvnTest-0.0.1-SNAPSHOT.jar.drv' failed

This comment has been minimized.

charles-dyfis-net commented Dec 4, 2018

Tracing through the code, there are two places where url can get populated:

  • The first is only relevant if art.isSnapshot() is true.
  • The second is only relevant if res.getRepository() returns a RemoteRepository. This isn't happening for the items being excluded as discussed in this ticket: a LocalRepository is being returned instead for the items which aren't being printed.

For Maven to operate, it and its dependencies are necessarily in the local repository, hence those items not having URLs assigned.

charles-dyfis-net added a commit to charles-dyfis-net/mvn2nix-maven-plugin that referenced this issue Dec 4, 2018

Do not use local repo (NixOS#19)
Adds dependency on commons-io for FileUtils.getTempDirectory()

This comment has been minimized.

charles-dyfis-net commented Dec 4, 2018

The above PR doesn't fix every broken case -- if an artifact can only be resolved with a repository added by a POM that included it, that URL still gets missed -- but that particular case has an immediate workaround (propagating such repository URLs up into the POM being operated against), and is rather distinct from the scenario this ticket is focused on.

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