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

Allow in-repo scalac plugins to have in-repo deps. #4987

Merged
merged 1 commit into from Oct 18, 2017

Conversation

Projects
None yet
2 participants
@benjyw
Copy link
Contributor

benjyw commented Oct 17, 2017

Problem

scalac plugins are not read from the regular classpath, so this requires special handling.

See #4594.

(javac plugins are read from the regular classpath, so deps work naturally there.)

Solution

Instead of providing only the classpath entry containing the plugin metadata
to the scalac -Xplugin: flag, as previously, we now provide that entry and
all those of its deps. scalac uses everything after the -Xplugin: as a private
classpath for the plugin, so this works. The only gotcha is we must be sure
that the entry containing the plugin metadata is the first one in that list, so
that we don't inadvertently load the wrong plugin (it's entirely possible
for the dependency closure of a plugin to contain some other plugin).

Note that we don't support external plugins with deps, as there's no easy way
to resolve just those deps by the time we're figuring out plugins. And putting
the entire external resolved classpath in every -Xplugin: seems like overkill.

However no-dep plugins seem to be the norm - e.g., SBT doesn't appear to
support plugin deps at all. To have external plugins with deps, you presumably
need to publish the plugin as a "fat jar".

Also adds examples to demonstrate javac/scalac plugin deps.

@benjyw benjyw force-pushed the benjyw:scalac_plugin_example branch 2 times, most recently from b4b7966 to 601e9ae Oct 17, 2017

Allow in-repo scalac plugins to have in-repo deps.
scalac plugins are not read from the regular classpath,
so this requires special handling.

javac plugins are read from the regular classpath,
so deps work naturally there.

Note that we don't support external plugins with deps,
as there's no easy way to resolve just those deps
by the time we're figuring out plugins.  However no-dep
plugins seem to be the norm - e.g., SBT doesn't appear to
support plugin deps at all.  To have external plugins
with deps, you presumably need to publish the plugin
as a "fat jar".

Also adds examples to demonstrate javac/scalac plugin deps.

@benjyw benjyw force-pushed the benjyw:scalac_plugin_example branch from 601e9ae to 6b87620 Oct 17, 2017

@stuhood
Copy link
Member

stuhood left a comment

Looks good: thanks!

@benjyw benjyw merged commit 67a3fa2 into pantsbuild:master Oct 18, 2017

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Details

@benjyw benjyw deleted the benjyw:scalac_plugin_example branch Oct 18, 2017

@stuhood stuhood added this to the 1.3.1 milestone Oct 18, 2017

stuhood added a commit that referenced this pull request Nov 3, 2017

Allow in-repo scalac plugins to have in-repo deps. (#4987)
scalac plugins are not read from the regular classpath,
so this requires special handling.

javac plugins are read from the regular classpath,
so deps work naturally there.

Note that we don't support external plugins with deps,
as there's no easy way to resolve just those deps
by the time we're figuring out plugins.  However no-dep
plugins seem to be the norm - e.g., SBT doesn't appear to
support plugin deps at all.  To have external plugins
with deps, you presumably need to publish the plugin
as a "fat jar".

Also adds examples to demonstrate javac/scalac plugin deps.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment