jar dependency match with json report
See original GitHub issueProblem
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:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
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.org:name:version
, egorg.ow2.asm:asm:4.0
org:name:packaging:version
, egorg.ow2.asm:asm:jar:4.0
org:name:packaging:classifier:version
, egorg.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.
closed by d0b46864c832ec1315ff886e55f6b94dfa3dfb0d