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

Support fetching sources and javadoc in export using coursier #5254

Merged
merged 15 commits into from
Dec 29, 2017

Conversation

wisechengyi
Copy link
Contributor

Description

Earlier the experimental coursier task does not support fetching sources and javadoc, so this change adds such functionality.

Testing

Leveraging the existing tests with @ensure_resolver

@wisechengyi wisechengyi changed the title Support fetching sources and javadocs in export using coursier Support fetching sources and javadoc in export using coursier Dec 28, 2017
@@ -54,7 +49,7 @@ def subsystem_dependencies(cls):
@classmethod
def register_options(cls, register):
super(CoursierMixin, cls).register_options(register)
register('--allow-global-excludes', type=bool, advanced=False, fingerprint=True, default=False,
register('--allow-global-excludes', type=bool, advanced=False, fingerprint=True, default=True,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is analogous to --soft-excludes which was default to False, which is the opposite of this, so correcting it here. The change does not cross release boundary, hence skipping deprecation step.

avro_lib_info = json_data.get('libraries').get('org.apache.avro:avro:1.7.7')
self.assertIsNotNone(avro_lib_info)
self.assertEquals(
self.assertIn(
'avro-1.7.7.jar',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

coursier and ivy have different paths, but what we care about is just the jar.

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.

Test changes look reasonable. I like the consolidation of coursier calls.

def test_export_jar_path_with_excludes(self):
with self.temporary_workdir() as workdir:
test_target = 'testprojects/src/java/org/pantsbuild/testproject/exclude:foo'
json_data = self.run_export(test_target, workdir, load_libs=True)
print(json_data)
Copy link
Contributor

Choose a reason for hiding this comment

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

xx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks. corrected.

@@ -91,7 +86,7 @@ def _compute_jars_to_resolve_and_pin(raw_jars, artifact_set, manager):

return jar_list, untouched_pinned_artifact

def resolve(self, targets, compile_classpath):
def resolve(self, targets, compile_classpath, sources, javadoc):
Copy link
Contributor

Choose a reason for hiding this comment

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

How would you feel about making the new params optional with default values of False?

Copy link
Contributor Author

@wisechengyi wisechengyi Dec 28, 2017

Choose a reason for hiding this comment

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

Good question. I thought about that and the settled with this idea:
I think generally it is a good practice especially when the call stack is relatively simple. However in cases where the same args get passed further down into other functions, things may look confusing, so making it non-optional would make it clear during debugging where the args came from, and also more clear for readers that just want to skim the code.

For example:

def resolve(..., sources=false, javadoc=false)
  x(sources, javadoc)

def x(sources,javadoc)
  y(sources,javadoc)

def y(sources, javadoc):
  // do other things

basically as a reader, it is hard to tell if sources, javadoc in y actually comes from the default value in resolve or the caller of resolve unless going back on the stack and then check how resolve is getting called, whereas non-optional args would make it clear that sources, javadoc in y is the exactly how resolve is getting called.

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds reasonable to me.

Copy link
Contributor

@baroquebobcat baroquebobcat Dec 28, 2017

Choose a reason for hiding this comment

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

The other approach that resolve methods take is to ask for a list of confs. Also, it looks like we don't use confs on the read-side of classpath products--and I'd generally like to move away from ivy confs as a pants concept.

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.

After another look over, 👍

"""
Calling coursier and return the result per invocation.

If coursier was called once for classifier '' and once for classifier 'tests', then the return value
would be: {'': <first couriser output>, 'tests': <second coursier output>}
would be: {'default': [<first couriser output>, <second coursier output>]}
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/couriser/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.

haha thanks. the curse of french

@wisechengyi wisechengyi merged commit 35e711f into pantsbuild:master Dec 29, 2017
@wisechengyi wisechengyi deleted the srcs_docs branch December 29, 2017 04:45
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.

2 participants