question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

jar dependency match with json report

See original GitHub issue

Problem

Coursier command:

fetch -t \
com.esotericsoftware.reflectasm:reflectasm:1.09,classifier=shaded \ # from pants jar_dep A
com.esotericsoftware.reflectasm:reflectasm:1.09 \ # from pants jar_dep B
org.ow2.asm:asm:4.0,classifier=sources \ # from pants jar_dep C
-A jar,src,doc,test-jar --json-output-file x.out

  Result:
├─ com.esotericsoftware.reflectasm:reflectasm:1.09
│  └─ org.ow2.asm:asm:4.0
├─ com.esotericsoftware.reflectasm:reflectasm:1.09
│  └─ org.ow2.asm:asm:4.0
└─ org.ow2.asm:asm:4.0

Since there are 3 roots to resolve, the tree is correct. One com.esotericsoftware.reflectasm:reflectasm:1.09 wants the default jar, and the other wants the shaded classifier jar. (UI wise it could be better to show that which is which)

Now look at the json output:

{
  "conflict_resolution": {},
  "dependencies": [
    {
      "coord": "org.ow2.asm:asm:4.0",
      "files": [
        [
          "sources",
          "<cache_dir>/https/repo1.maven.org/maven2/org/ow2/asm/asm/4.0/asm-4.0-sources.jar"
        ]
      ],
      "dependencies": []
    },
    {
      "coord": "com.esotericsoftware.reflectasm:reflectasm:1.09",
      "files": [
        [
          "shaded",
          "<cache_dir>/https/repo1.maven.org/maven2/com/esotericsoftware/reflectasm/reflectasm/1.09/reflectasm-1.09-shaded.jar"
        ]
      ],
      "dependencies": [
        "org.ow2.asm:asm:4.0"
      ]
    },
    {
      "coord": "org.ow2.asm:asm:4.0",
      "files": [
        [
          "",
          "<cache_dir>/https/repo1.maven.org/maven2/org/ow2/asm/asm/4.0/asm-4.0.jar"
        ]
      ],
      "dependencies": []
    },
    {
      "coord": "com.esotericsoftware.reflectasm:reflectasm:1.09",
      "files": [
        [
          "",
          "<cache_dir>/https/repo1.maven.org/maven2/com/esotericsoftware/reflectasm/reflectasm/1.09/reflectasm-1.09.jar"
        ]
      ],
      "dependencies": [
        "org.ow2.asm:asm:4.0"
      ]
    }
  ]
}

For jar_dep A, it has to find the coordinate “com.esotericsoftware.reflectasm:reflectasm”. There are two of them, but it knows to find the one with classifier ‘shaded’:

    {
      "coord": "com.esotericsoftware.reflectasm:reflectasm:1.09",
      "files": [
        [
          "shaded",
          "<cache_dir>/https/repo1.maven.org/maven2/com/esotericsoftware/reflectasm/reflectasm/1.09/reflectasm-1.09-shaded.jar"
        ]
      ],
      "dependencies": [
        "org.ow2.asm:asm:4.0"
      ]
    },

Great. jar_dep A grabs reflectasm-1.09-shaded.jar into its collection. Then it needs to grab its dependencies as well. Given the clue org.ow2.asm:asm:4.0, it finds:

    {
      "coord": "org.ow2.asm:asm:4.0",
      "files": [
        [
          "",
          "<cache_dir>/https/repo1.maven.org/maven2/org/ow2/asm/asm/4.0/asm-4.0.jar"
        ]
      ],
      "dependencies": []
    },

and

    {
      "coord": "org.ow2.asm:asm:4.0",
      "files": [
        [
          "sources",
          "<cache_dir>/https/repo1.maven.org/maven2/org/ow2/asm/asm/4.0/asm-4.0-sources.jar"
        ]
      ],
      "dependencies": []
    },

Now, there is no way to tell which it needs, because all it knows is just org.ow2.asm:asm:4.0. Currently Pants’ behavior is to grab both. However the correct jar to grab is just asm-4.0.jar and not asm-4.0-sources.jar

Proposed solution

Option 1:

Add classifier to dependencies org:name:version, i.e. org:name:version:classifier. For the same example:

{
  "conflict_resolution": {},
  "dependencies": [
    {
      "coord": "org.ow2.asm:asm:4.0",
      "files": [
        [
          "sources",
          "<cache_dir>/https/repo1.maven.org/maven2/org/ow2/asm/asm/4.0/asm-4.0-sources.jar"
        ]
      ],
      "dependencies": []
    },
    {
      "coord": "com.esotericsoftware.reflectasm:reflectasm:1.09",
      "files": [
        [
          "shaded",
          "<cache_dir>/https/repo1.maven.org/maven2/com/esotericsoftware/reflectasm/reflectasm/1.09/reflectasm-1.09-shaded.jar"
        ]
      ],
      "dependencies": [
        "org.ow2.asm:asm:4.0:<empty classifier>"
      ]
    },
    {
      "coord": "org.ow2.asm:asm:4.0",
      "files": [
        [
          "",
          "<cache_dir>/https/repo1.maven.org/maven2/org/ow2/asm/asm/4.0/asm-4.0.jar"
        ]
      ],
      "dependencies": []
    },
    {
      "coord": "com.esotericsoftware.reflectasm:reflectasm:1.09",
      "files": [
        [
          "",
          "<cache_dir>/https/repo1.maven.org/maven2/com/esotericsoftware/reflectasm/reflectasm/1.09/reflectasm-1.09.jar"
        ]
      ],
      "dependencies": [
        "org.ow2.asm:asm:4.0:<empty classifier>"
      ]
    }
  ]
}

Now jar_dep A knows the dependency is org.ow2.asm:asm:4.0:<empty classifier>, thus finding the following and grabs asm-4.0.jar only.

    {
      "coord": "org.ow2.asm:asm:4.0",
      "files": [
        [
          "",
          "<cache_dir>/https/repo1.maven.org/maven2/org/ow2/asm/asm/4.0/asm-4.0.jar"
        ]
      ],
      "dependencies": []
    },

Option 2: Make both coord and dependencies to adopt org:name:version:classifier. I am not sure what the report would look like when --sources and --javadoc are both specified, so might need more thoughts there. But option 1 should be more straight forward.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
baroquebobcatcommented, Jan 23, 2018

One thought I had here is that with either option I think we ought to adopt Maven’s coordinate structure instead of org:name:version:classifier. Maven’s coordinates have 3 different forms.

  • Default org:name:version, eg org.ow2.asm:asm:4.0
  • Including packaging/type org:name:packaging:version, eg org.ow2.asm:asm:jar:4.0
  • Including classifier org:name:packaging:classifier:version, eg org.ow2.asm:asm:jar:sources:4.0

By using the above scheme we don’t have to have an explicit value for empty classifier because it’s encoding in the formatting. It also opens up a place to include file-extension/packaging information on a per artifact level.

I don’t know enough about the currently accepted schema to be sure that this’ll work, but I’d appreciate some feedback.

0reactions
wisechengyicommented, Mar 13, 2018

closed by d0b46864c832ec1315ff886e55f6b94dfa3dfb0d

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSON-Report-Mapping failed due to missing fileName property
Final.jar) which is missing some data in its JSON structure. My workaround is to generate the Dependency-Check reports in both JSON and XML ......
Read more >
Dependency Scanning fails on Java-based project with Maven
Summary Dependency scanning is failing on a Java-based project using ... WARNING: gl-dependency-scanning-report.json: no matching files ...
Read more >
Apache Maven Dependency Plugin – Usage
dependency :analyze-report. This goal is used to include a report of the dependencies in the output of the maven-site-plugin .
Read more >
Maven Could not resolve dependencies, artifacts could not be ...
In this case, the JARs are coming from a SpringSource repository and are not on Maven Central. I had assumed that the friend...
Read more >
Jackson JSON Java Parser API Example Tutorial - DigitalOcean
To use Jackson JSON Java API in our project, we can add it to the project build path or if you are using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found