Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

wisechengyi
Copy link
Contributor

No description provided.

Copy link
Contributor

@baroquebobcat baroquebobcat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good to me, a part from one bit of duplication.

'-A', 'jar,bundle,test-jar,maven-plugin,src,doc,aar'
]

[cache.resolve.coursier]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you've got cach.resolve.coursier in here twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah thanks. corrected

Copy link
Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned that we're exposing all of coursier's options right out of the box, as that seems likely to get us in the same situation we were in with ivy, where if someone had a custom config, it was very difficult to validate that it didn't break certain rules like the ivy_cache_dir location.

If it wouldn't be too restrictive, would consider starting with something like a --maven-resolvers list option, and then expanding the options we expose as we go. Maybe with an escape hatch for "--extra-coursier-options", or something.

[resolve.coursier]
# jvm option in case of large resolves
jvm_options: ['-Xmx4g', '-XX:MaxMetaspaceSize=256m']
# The opposite of resolve.ivy.soft_excludes
Copy link
Member

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

@wisechengyi wisechengyi Jan 23, 2018

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be happy to cherry pick that in.

'-r', 'https://repo1.maven.org/maven2/',
'-r', 'https://dl.google.com/dl/android/maven2/',

# Quiet mode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the output consumed by the workunit? Is quiet required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

# Do not use default public maven repo.
'--no-default',

# Concurrent workers
Copy link
Member

@stuhood stuhood Jan 23, 2018

Choose a reason for hiding this comment

The 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?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filed #5384

# Concurrent workers
'-n', '10',

# Specify the type of artifacts to fetch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto... this feels like something that the task should set.

@@ -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)
Copy link
Contributor

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/


fetch_options: [
# Specify maven repos
'-r', 'https://repo1.maven.org/maven2/',
Copy link
Contributor

@benjyw benjyw Jan 26, 2018

Choose a reason for hiding this comment

The 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:

<url name="foo.bar">
  <artifact pattern="https://foo.com/bar/[organisation]/[artifact]/[revision]/[artifact]-[revision].[ext]" />
</url>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, I just tried to emulate that with this:

'-r', 'ivy:https://foo.com/bar/[organisation]/[artifact]/[revision]/[artifact]-[revision].[ext]'

But unfortunately it replaces the [artifact] placeholder with the string "ivy", instead of with the name of my artifact. So maybe ivy emulation is broken?

Copy link
Contributor

@benjyw benjyw Jan 26, 2018

Choose a reason for hiding this comment

The 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"...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But unfortunately it replaces the [artifact] placeholder with the string "ivy", instead of with the name of my artifact. So maybe ivy emulation is broken?

if you suspect resolving against ivy repo is broken, please file a ticket at https://github.com/coursier/coursier with a minimal repro.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

@benjyw benjyw Jan 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, the behavior is weird. It assumes that your pattern ends with /[artifact].[ext] so that it can substitute artifact=ivy, ext=xml and fetch an ivy.xml. But if your pattern doesn't end with those, it'll still do the substitution and try to fetch the file . So, e.g., if your pattern ends with /[module].jar it'll fetch the jar and then try to parse it as XML...

Ivy deals with this by having two separate patterns in the settings - one for the artifacts and one for the ivy.xml.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allow_global_excludes: False

[cache.resolve.coursier]
# In order to enable remote caching, need to relativize the classpath entries serialized.
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Member

@stuhood stuhood Jan 26, 2018

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that --cache-ignore would even skip fingerprinting which coursier resolve needs, so if there is a way to still do fingerprinting but disabling cache checking, that'll be great.

Copy link
Member

@stuhood stuhood Jan 26, 2018

Choose a reason for hiding this comment

The 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.

fetch_options: [
# Specify maven repos
'-r', 'https://repo1.maven.org/maven2/',
'-r', 'https://dl.google.com/dl/android/maven2/',
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

@benjyw benjyw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Stu that maybe we don't need to expose all coursier options? At least not in the documentation. People can always go read the coursier docs for those.

But what's still missing for me is a "here's how to migrate from ivy" tutorial. Specifically, how to convert your ivysettings.xml to coursier options.

@benjyw
Copy link
Contributor

benjyw commented Jan 26, 2018

Is there an equivalent of an ivy report for coursier? Its error messages are not very helpful, in general. E.g.,

 java.lang.AssertionError: assertion failed
                       	at scala.Predef$.assert(Predef.scala:156)
                       	at coursier.TermDisplay$UpdateDisplayRunnable.newEntry(TermDisplay.scala:165)
                       	at coursier.TermDisplay.downloadingArtifact(TermDisplay.scala:444)
                       	at coursier.Cache$$anonfun$remote$1$1$$anonfun$apply$26.apply(Cache.scala:669)
                       	at coursier.Cache$$anonfun$remote$1$1$$anonfun$apply$26.apply(Cache.scala:669)
                       	at scala.Option.foreach(Option.scala:257)
                       	at coursier.Cache$$anonfun$remote$1$1.apply(Cache.scala:669)
                       	at coursier.Cache$$anonfun$remote$1$1.apply(Cache.scala:556)
                       	at scalaz.concurrent.Task$.Try(Task.scala:456)
                       	at scalaz.concurrent.Task$$anonfun$apply$25.apply(Task.scala:353)
                       	at scalaz.concurrent.Task$$anonfun$apply$25.apply(Task.scala:353)
                       	at scalaz.concurrent.Future$$anonfun$apply$15$$anon$3.call(Future.scala:432)
                       	at scalaz.concurrent.Future$$anonfun$apply$15$$anon$3.call(Future.scala:432)
                       	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
                       	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
                       	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
                       	at java.lang.Thread.run(Thread.java:748)

@benjyw
Copy link
Contributor

benjyw commented Jan 26, 2018

I'd love to switch to Coursier, because Ivy is so painful and over-engineered and complex. But so far Coursier seems to be not great at dealing with anything other than "download from a standard Maven-style repo"...

@benjyw
Copy link
Contributor

benjyw commented Jan 26, 2018

BTW while banging on Coursier I noticed a minor issue around workunits in the resolve task. Filed an issue.

@wisechengyi
Copy link
Contributor Author

Thanks @baroquebobcat @stuhood @benjyw. Let me summarize and see if there's anything missing.

  1. Limit the options exposed to user to, e.g. number of workers, list of maven repos. Move others to advanced options if user wants to further dig up coursier options.
  2. Suggest the migration path from ivy. Clearly call out what coursier cannot do.
  3. Suggest the generic method for debugging coursier resolves. @benjyw the particular stacktrace was fixed already on master as discussed in slack.
  4. Leave caching options default, because [resolve.coursier] writes to results_dir but does not enable caching.

@stuhood
Copy link
Member

stuhood commented Feb 1, 2018

Yea, sounds about right. Thanks.

  1. Suggest the migration path from ivy. Clearly call out what coursier cannot do.

I think that this boils down to either describing or scripting conversion of the most commonly configured bits of ivy: basically, resolvers.

  1. Suggest the generic method for debugging coursier resolves.

Yea. Some equivalent of ./pants resolve.ivy --open (even if it were text based) will be important.

@wisechengyi
Copy link
Contributor Author

Closed in favor of #5675

@wisechengyi wisechengyi closed this Apr 8, 2018
wisechengyi added a commit that referenced this pull request Apr 9, 2018
Address points from #5382

* Extract the following coursier options and assign sensible defaults
  * artifact types
  * cache dir
  * fetch options
  * repos
* Add `--report` flag to show coursier output
* Add documentation
@wisechengyi wisechengyi deleted the coursier_doc branch April 9, 2018 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants