This repository has been archived by the owner on Dec 10, 2020. It is now read-only.
forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow targets to have sensible defaults for sources=.
95% of the time, a java_library() target will have sources=globs('*.java'), and it seems unnecessary to require this boilerplate to be repeated everywhere. This change provides a way for target to say "if no explicit sources are specified, use this glob". The change is gated behind an option, because it can have unintended consequences. For example, in the Pants codebase itself we had a few places where we were using a python_library() with no sources as a dependency aggregator, when we should have been using a target(). This change fixes such quirks in our own codebase. It also modifies a couple of our example targets to take advantage of this functionality, as proof-of-concept. This change required modifying quite a few tests that were creating library targets with no sources: These tests didn't init the relevant subsystem, and so couldn't consult the new option to see what to do when no sources= were provided. These tests were fixed in one of two ways: either by initializing the subsystem, or by providing explicit sources=[], whichever made more sense. Note that instead of creating a new subsystem, I added this option to the Target.UnknownArguments subsystem. This implied an expanded role for that subsystem, so its name was no longer applicable. I renamed it to Target.Arguments, and deprecated its scope. Finally, note that the defaults for library and test targets make it easy to have tests live side-by-side with the code they test, instead of in a separate source tree, which is a really useful idiom IMO. Testing Done: CI passes: https://travis-ci.org/pantsbuild/pants/builds/168486240 Reviewed at https://rbcommons.com/s/twitter/r/4300/
- Loading branch information
Showing
45 changed files
with
267 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
|
||
# Note that the target has no explicit name, so it defaults to the name | ||
# of the directory, in this case 'greet'. | ||
# It also has no explicit sources, so it defaults to the sources implied | ||
# by the target type, in this case "globs('*.py')". | ||
python_library( | ||
dependencies=[ | ||
'3rdparty/python:ansicolors', | ||
], | ||
sources=globs('*.py'), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.