-
-
Notifications
You must be signed in to change notification settings - Fork 646
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
classmap: a jvm console task that outputs mapping from class products to their targets #4081
Conversation
|
||
def console_output(self, _): | ||
def should_ignore(target): | ||
if target.address.spec.startswith('//:'): |
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.
Is this necessary? Seems easy enough to filter out any particular target before calling the goal.
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.
Removed the //:
check, agree easy to filter, either before (if calling with --internal-only
) or after on the output.
The extra benefit is to be honest allow us to inspect all dependencies including those from build tools.
|
||
def console_output(self, _): | ||
def should_ignore(target): | ||
return self.get_options().internal_only and isinstance(target, JarLibrary) |
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.
What about JvmBinary targets that have a source=?
Might be better to check for the opposite (not internal_only and isinstance(target, JarLibrary).
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.
not sure I get... see no difference how jvm_binary
is treated:
An example jvm_binary
(this example has source
but if w/o source if would be one less entry in the output of its own class mapping.)
tw-mbp-peiyu:pants peiyu$ ./pants classmap examples/src/java/org/pantsbuild/example/annotation/main --classmap-internal-only
org.pantsbuild.example.annotation.main.Main examples/src/java/org/pantsbuild/example/annotation/main:main
org.pantsbuild.example.annotation.example.Example examples/src/java/org/pantsbuild/example/annotation/example:example
org.pantsbuild.example.annotation.processor.ExampleProcessor examples/src/java/org/pantsbuild/example/annotation/processor:processor
tw-mbp-peiyu:pants peiyu$ ./pants classmap examples/src/java/org/pantsbuild/example/annotation/main --classmap-internal-only --no-classmap-transitive
org.pantsbuild.example.annotation.main.Main examples/src/java/org/pantsbuild/example/annotation/main:main
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.
Oh, I think I misread "JavaLibrary" for "JarLibrary". This is fine as-is.
@@ -576,11 +576,6 @@ def compute_classes_by_source(self, compile_contexts): | |||
classes_by_src[None] = list(unclaimed_classes) | |||
return classes_by_src_by_context | |||
|
|||
def classname_for_classfile(self, compile_context, class_file_name): |
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.
Is this not needed anywhere?
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.
yea, this is not used anywhere
[tw-mbp-peiyu pants (master)]$ git grep classname_for_classfile
src/python/pants/backend/jvm/tasks/jvm_compile/jvm_compile.py: def classname_for_classfile(self, compile_context, class_file_name):
… to their targets (pantsbuild#4081) The task is straightforward similar to `filemap` that prints out target-file mapings, this outputs target-class mappings. This is useful when fixing compilation errors. One use case we encounter recently is to enable `strict_deps` for performance, there are transitive dependencies need to be added. This can be achieved by first running `classmap` to get the transitive target-class mapping, then if after enabling `strict_deps`, we get error class X not found, we'll add X's mapping target to the dependencies. Test done ======== https://travis-ci.org/pantsbuild/pants/builds/177179488 A sample run ``` tw-mbp-peiyu:pants peiyu$ ./pants classmap testprojects//tests/java/org/pantsbuild/testproject/cucumber:lib |head org.pantsbuild.testproject.cucumber.BadnamesSteps testprojects/tests/java/org/pantsbuild/testproject/cucumber:lib org.pantsbuild.testproject.cucumber.DemoSteps testprojects/tests/java/org/pantsbuild/testproject/cucumber:lib org.junit.ClassRule 3rdparty:junit org.junit.Assert 3rdparty:junit org.junit.After 3rdparty:junit org.junit.rules.Stopwatch$Clock 3rdparty:junit org.junit.rules.DisableOnDebug 3rdparty:junit org.junit.rules.ExternalResource 3rdparty:junit org.junit.rules.TestWatcher$1 3rdparty:junit org.junit.rules.TemporaryFolder 3rdparty:junit ... ```
The task is straightforward similar to
filemap
that prints out target-file mapings, this outputstarget-class mappings.
This is useful when fixing compilation errors. One use case we encounter recently is to enable
strict_deps
for performance, there are transitive dependencies need to be added.This can be achieved by first running
classmap
to get the transitive target-class mapping, thenif after enabling
strict_deps
, we get error class X not found, we'll add X's mapping targetto the dependencies.
Test done
https://travis-ci.org/pantsbuild/pants/builds/177179488
A sample run