Pants: ensime support

Created on 19 Feb 2016  Â·  14Comments  Â·  Source: pantsbuild/pants

@lahosken I noticed that you'd created a .ensime generator, that's great!

Is it something that can be moved out into a plugin and hosted at https://github.com/ensime with you as the admin? We'd also like to add it to our list of supported build tools at http://ensime.org ... we can start to document that even if ensime support is embedded in pants, but the .ensime file may change at some point so we prefer to have these things as plugins.

Have you created a pants-mode for Emacs like https://github.com/ensime/emacs-sbt-mode ?

Most helpful comment

I actually made an ensime generator that works surprisingly well for this random thing I was working on (this is the pants-plugins/ directory). It ends up building a scala source which consumes the ensime-api jar to produce compatible .ensime files when invoked as a jvm tool, with ./pants ensime <targets...>.

The only issue I've seen is with I think having difficulty making sure my test-scoped jars were visible? But thinking about it now I don't think that was an issue, I just hadn't written it yet. There's another major kink -- if the server is alive and the .pants.d directory is deleted, then the ensime server will helpfully recreate the classfile output directories, but pants creates those with symlinks, so errors when it tries to access its own cache directory -- this is resolved by simply restarting the ensime server. But I don't think any of those would require significant effort to solve and the only reason I haven't made it into a PR is because I didn't know if it should be hosted in this repo, or in the ensime repo, or ???.

The ./pants ensime task in the link above works really reliably, uses the export task, and isn't that complex at all. It should be upstreamed somewhere. This has been the greatest productivity boost to me personally with this scala project, I use it a lot, and I doubt it would be hard to match or exceed sbt's level of support.

EDIT: Also, it should be noted that @fommil calling me out on twitter when I was frustrated about misunderstanding the ensime API and setting me straight on a few things led directly (within the next few hours) to me making a pants ensime generator that works great, so thanks!

All 14 comments

Hey @fommil

Been awhile since you filed this!

The plugin has gotten very out of date. One of the programmers at my last company has taken a valiant stab at getting it up to date but it's not up to ensime HEAD (https://github.com/toddgardner/pants-plugins/tree/master/src/python/verst/pants/ensime), I'm hoping to get it working and tested.

I talked to the pants team, and there's consensus for moving this over if y'all are still interested; I can fork out that piece of my repo.

Great! I basically have no idea how to use pants but I'd be happy to point you at examples in the sbt plugin and point out features that could be added for parity sake.

It's possible that the http://www.pantsbuild.org/export.html format could be used to create something that lived in an ensime repo. But assuming this continues to actually be a plugin for pants itself it would probably be least fragile for it to live in pantsbuild/pants, with additional integration tests.

EDIT: To be clear: we'd accept patches to pantsbuild/pants to modernize this, but we're fine with any approach.

Thanks for all of these pointers. I will try to find some time next week to figure out both ends of this. Are there docs anywhere of what all the required / optional fields in an .ensime file are?

@anfedorov the sbt plugin code is the reference implementation and has lots of examples in the tests. Currently both v1 and v2 of the file are used because the clients haven't all caught up with v2 so there is some duplication. Let me know if you find it.

I was hacking around with this yesterday and extracted the verst plugin to it's own repo: https://github.com/toddgardner/pants-ensime-plugin

Working on a better integration test.

One of the reasons I was thinking this should move to ensime is, from maintaining this (and @anatolydwnld did all the work on it so can probably speak more to it) the primary source of breakages was changes in the ensime file format rather than the pants plugin structure, and having some help or notifications of changes would probably help keep this more up to date. I could also see trying to share it somehow or keep it up to date otherwise.

if you want to move it to ensime org that's great (just assign to me and tell me who should be admin) but I don't think that means anybody else will be able to work on it than who already is :smile:

@toddgardner : I suspect that the reason the primary source of breakages was the ensime file format, rather than pants' API, was that while it lives in the pants repo, it is updated by pants maintainers. In particular, the plugin is currently using private APIs, which is totally fine while it lives in the repo (because we can't get a change through CI that will break it), but which may become an issue if it moves out. For example, IdeGen contains no public APIs currently... before you extract EnsimeGen from its current location, you'd probably want to submit a change to mark the private APIs that it depends on public: http://www.pantsbuild.org/deprecation_policy.html

Is anyone working on this right now?

Not that I'm aware of. I still plan to do so when I have time.

On Sun, Dec 17, 2017 at 12:53 PM, Duncan Hills Coffee Company <
[email protected]> wrote:

Is anyone working on this right now?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/pantsbuild/pants/issues/2939#issuecomment-352284725,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAmXNrWidstfdxHCbEBzbD86NfpK4nVks5tBX8-gaJpZM4Hd-1y
.

I actually made an ensime generator that works surprisingly well for this random thing I was working on (this is the pants-plugins/ directory). It ends up building a scala source which consumes the ensime-api jar to produce compatible .ensime files when invoked as a jvm tool, with ./pants ensime <targets...>.

The only issue I've seen is with I think having difficulty making sure my test-scoped jars were visible? But thinking about it now I don't think that was an issue, I just hadn't written it yet. There's another major kink -- if the server is alive and the .pants.d directory is deleted, then the ensime server will helpfully recreate the classfile output directories, but pants creates those with symlinks, so errors when it tries to access its own cache directory -- this is resolved by simply restarting the ensime server. But I don't think any of those would require significant effort to solve and the only reason I haven't made it into a PR is because I didn't know if it should be hosted in this repo, or in the ensime repo, or ???.

The ./pants ensime task in the link above works really reliably, uses the export task, and isn't that complex at all. It should be upstreamed somewhere. This has been the greatest productivity boost to me personally with this scala project, I use it a lot, and I doubt it would be hard to match or exceed sbt's level of support.

EDIT: Also, it should be noted that @fommil calling me out on twitter when I was frustrated about misunderstanding the ensime API and setting me straight on a few things led directly (within the next few hours) to me making a pants ensime generator that works great, so thanks!

hi @cosmicexplorer I'm going through and closing the tickets that I don't plan to work on, could you please copy this ticket to a fresh one so we can close this? Thanks.

Sure.

I'm glad it's working for you though! I am no longer involved with ensime but hopefully some people can join forces to maintain and improve the server.

Was this page helpful?
0 / 5 - 0 ratings