Use target type when matching source roots. #4093

Open
benjyw opened this Issue Nov 23, 2016 · 0 comments

Comments

Projects
None yet
1 participant
@benjyw
Contributor

benjyw commented Nov 23, 2016

E.g., JavaLibrary.target_base should only match source roots that were registered against the language java. Today we match source roots without regard for language, under the assumption that the repo doesn't have nesting source roots for different languages.

This would allow repos to have their .proto file imports be relative to the buildroot (as Google recommends), without that root then being returned as the target_base for all targets in all languages.

An alternative solution would be to take the longest match in the source root trie, instead of the shortest one as we do today.

@benjyw benjyw self-assigned this Nov 23, 2016

benjyw added a commit to benjyw/pants that referenced this issue Nov 23, 2016

Allow the buildroot to be a source root.
This is of limited use, because it would require all
languages in your repo to be rooted at the buildroot.
But I did encounter one such case (involving .proto files,
which Google now recommends be imported relative to the
buildroot), so might as well support it.

TODO: This brings to the fore the fact that source root
      computation is not dependent on the target type.
      If it were (e.g., java_library would only match build roots
      that are registered against 'java') then you could have
      .protos rooted at the buildroot but java in src/java etc.
      See pantsbuild#4093.

benjyw added a commit that referenced this issue Dec 7, 2016

Allow the buildroot to be a source root
This is of limited use, because it would require all
languages in your repo to be rooted at the buildroot.
But I did encounter one such case (involving .proto files,
which Google now recommends be imported relative to the
buildroot), so might as well support it.

TODO: This brings to the fore the fact that source root
      computation is not dependent on the target type.
      If it were (e.g., java_library would only match build roots
      that are registered against 'java') then you could have
      .protos rooted at the buildroot but java in src/java etc.
      See #4093.

lenucksi added a commit to lenucksi/pants that referenced this issue Apr 25, 2017

Allow the buildroot to be a source root
This is of limited use, because it would require all
languages in your repo to be rooted at the buildroot.
But I did encounter one such case (involving .proto files,
which Google now recommends be imported relative to the
buildroot), so might as well support it.

TODO: This brings to the fore the fact that source root
      computation is not dependent on the target type.
      If it were (e.g., java_library would only match build roots
      that are registered against 'java') then you could have
      .protos rooted at the buildroot but java in src/java etc.
      See pantsbuild#4093.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment