-
-
Notifications
You must be signed in to change notification settings - Fork 632
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
Add documentation for coursier usage #5382
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,6 +211,57 @@ Toolchain | |
Pants uses [Ivy](http://ant.apache.org/ivy/) to resolve `jar` dependencies. To change how Pants | ||
resolves these, configure `resolve.ivy`. | ||
|
||
Starting release `1.4.0.dev26`, Pants added an option to pick [coursier](https://github.com/coursier/coursier) | ||
as the JVM 3rdparty resolver, with performance improvement being the main motivation. The goal is to retire ivy | ||
eventually. Example config to use coursier: | ||
|
||
:::ini | ||
# This will turn on coursier and turn off ivy. | ||
[resolver] | ||
resolver: coursier | ||
|
||
[resolve.coursier] | ||
# jvm option in case of large resolves | ||
jvm_options: ['-Xmx4g', '-XX:MaxMetaspaceSize=256m'] | ||
# The opposite of resolve.ivy.soft_excludes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that we have #4437 outstanding, is it too late to make soft_excludes the default for coursier? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I made the default behavior consistent with ivy in oss 35e711f#diff-0b873245a3a9ee84a1f817502a221652R52 If you think we are not crossing release boundary yet (not sure if 1.4.0rc0 counts), I can just put a patch to flip the default. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be happy to cherry pick that in. |
||
allow_global_excludes: False | ||
|
||
[cache.resolve.coursier] | ||
# In order to enable remote caching, need to relativize the classpath entries serialized. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you show how to turn off remote caching but leave local caching? Is that even possible on a cache-by-cache basis? I don't remember any more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @benjyw : Yea, it's possible. but... @wisechengyi : Is this code even writing to the cache? If not, these settings shouldn't be relevant. If it is, you should probably just disable cache writing for now? I honestly think that invalidation (without caching) might be sufficient for coursier. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding is that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussed offline: if the code doesn't write to the cache, then these settings don't matter. And I think that we should almost certainly do our first caching of coursier via #4397, rather than via the v1 Task caching. |
||
# https://github.com/pantsbuild/pants/issues/5187 | ||
# We still want to compute fingerprints so we can validate or invalidate, | ||
# but do not want to check local or remote cache. | ||
read: False | ||
write: False | ||
|
||
[export] | ||
# Same if needed for large resolves | ||
jvm_options: ['-Xmx4g', '-XX:MaxMetaspaceSize=256m'] | ||
|
||
[coursier] | ||
# Change the following if you choose to [build coursier jar from scratch](https://github.com/coursier/coursier/blob/master/DEVELOPMENT.md#build-with-pants) | ||
# or to fetch from different location. | ||
bootstrap_jar_url: <url> | ||
version: <version> | ||
|
||
fetch_options: [ | ||
# Specify maven repos | ||
'-r', 'https://repo1.maven.org/maven2/', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there examples for custom repo URL formats using placeholders? The equivalent of this in an ivysettings:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For example, I just tried to emulate that with this:
But unfortunately it replaces the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turns out that [artifact] should be replaced with [module]. So this is an example of the kind of thing that should go into a "how to migrate from ivy" tutorial!! Update: it's actually a bit more complicated than that - module and artifact are two distinct ivy concepts, both of which appear to map to maven "artifact", at least for the purpose of placeholder substitution. Not sure why Coursier would decide that artifact should be "ivy", maybe because it's looking for "ivy.xml"... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
if you suspect resolving against ivy repo is broken, please file a ticket at https://github.com/coursier/coursier with a minimal repro. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ugh but there are still other issues. For example, it appears to insist on the presence of an ivy.xml file, which Ivy itself does not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, the behavior is weird. It assumes that your pattern ends with Ivy deals with this by having two separate patterns in the settings - one for the artifacts and one for the ivy.xml. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
'-r', 'https://dl.google.com/dl/android/maven2/', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this with with local filesystem repos? If so, an example would be great. |
||
|
||
# Quiet mode | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't the output consumed by the workunit? Is quiet required? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it will be consumed by the workunit, but it's good to turn on sometimes to visualize the resolve on pants server. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is consumed by workunit. but sometimes printing into workunit and viewing from pants server helps debugging. |
||
'-q', | ||
|
||
# Do not use default public maven repo. | ||
'--no-default', | ||
|
||
# Concurrent workers | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like something pants should set by inspecting available cores (or just letting coursier do that... presumably this value has a default?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. filed #5384 |
||
'-n', '10', | ||
|
||
# Specify the type of artifacts to fetch | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto... this feels like something that the task should set. |
||
'-A', 'jar,bundle,test-jar,maven-plugin,src,doc,aar' | ||
] | ||
|
||
Pants uses [Nailgun](https://github.com/martylamb/nailgun) to speed up compiles. Nailgun is a | ||
JVM daemon that runs in the background. This means you don't need to start up a JVM and load | ||
classes for each JVM-based operation. Things go faster. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: s/Starting release/At release/