NixOS / mvn2nix-maven-plugin

Generate project-info.json for use with nix's Maven repository generation functions
MIT License
31 stars 21 forks source link

Can generate dependencies with no url, causing failure in buildMaven #17

Closed charles-dyfis-net closed 5 years ago

charles-dyfis-net commented 5 years ago

Using lein pom to generate a pom.xml for https://github.com/threatgrid/kiries, and then mvn org.nixos.mvn2nix:mvn2nix-maven-plugin:mvn2nix, generates a project-info.json for which numerous dependencies have no URLs:

$ jq -r '.dependencies[] | select(.url? == null) | [.groupId, .artifactId, .version] | @tsv' <project-info.json | sort -u
org.apache  apache  10
org.apache  apache  5
org.apache.maven    maven-parent    11
org.apache.maven    maven-parent    21
org.apache.maven.wagon  wagon   1.0-beta-6
org.apache.maven.wagon  wagon-provider-api  1.0-beta-6
org.clojure clojure 1.8.0
org.codehaus.plexus plexus  2.0.7
org.codehaus.plexus plexus  3.3.1
org.codehaus.plexus plexus-component-annotations    1.5.5
org.codehaus.plexus plexus-components   1.1.18
org.codehaus.plexus plexus-containers   1.5.5
org.codehaus.plexus plexus-interpolation    1.14
org.sonatype.oss    oss-parent  7
org.sonatype.spice  spice-parent    17

This is much shorter than the list of 858 unique dependencies which do have URLs, so it's a fairly small subset. However, the nixpkgs code intended to consume these JSON files is really quite unhappy when encountering one of them:

nix-repl> buildMaven ./project-info.json
error: attribute 'url' missing, at /nix/store/9yjrxr1b9c31xir2hm8xbp1mpbr2irhj-nixos-18.09.1420.5d4a1a3897e/nixos/pkgs/build-support/build-maven.nix:17:39

I suspect that we should be downloading only metadata, and not build artifacts, for these items.

Any pointers?

charles-dyfis-net commented 5 years ago

On further reflection and analysis, I believe this should be addressed on the nixpkgs side, rather than here.

charles-dyfis-net commented 5 years ago

Hmm -- this looks like we actually have two separate bugs here.

One of these was the immediate failure on encountering any pom-only package; that's fixed by NixOS/nixpkgs#51240.

The second one is whatever is (in the aforementioned kiries example) causing org.clojure:clojure:1.8.0 to not be given a url (similarly, its metadata-only dependency org.sonatype.oss:oss-parent:7:pom has no url or metadata.url -- while sibling releases org.sonatype.oss:oss-parent:5:pom and org.sonatype.oss:oss-parent:9:pom are correctly downloaded and included in the repository).

That's still open, and I'm frankly scratching my head over it. The end impact of that issue looks something like the following:

  [ERROR] Failed to execute goal on project kiries: Could not resolve dependencies for project kiries:kiries:jar:1.0.0-SNAPSHOT: Failed to collect dependencies at com.taoensso:carmine:jar:2.16.0 -> com.taoensso:encore:jar:2.90.1 -> 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 (https://repo1.maven.org/maven2) in offline mode and the artifact org.sonatype.oss:oss-parent:pom:7 has not been downloaded from it before. -> [Help 1]
charles-dyfis-net commented 5 years ago

Hmm. It looks like the missing packages are dependencies of the mvn2nix plugin itself.