Skip to content
This repository has been archived by the owner on Dec 10, 2020. It is now read-only.

Commit

Permalink
Get rid of all bootstrap BUILD files in our repo.
Browse files Browse the repository at this point in the history
We'll continue to support them until the deprecation cycle
completes, but we ourselves will no longer use them.

Testing Done:
CI passes: https://travis-ci.org/pantsbuild/pants/builds/86308782

Reviewed at https://rbcommons.com/s/twitter/r/2996/
  • Loading branch information
benjyw authored and Benjy committed Oct 20, 2015
1 parent 4d1d2ba commit ba0450a
Show file tree
Hide file tree
Showing 31 changed files with 43 additions and 284 deletions.
17 changes: 0 additions & 17 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

# Pants source code
source_root('src/java', page, java_library, jvm_binary)
source_root('src/python', page, python_binary, python_library, resources)
source_root('src/resources', page, resources)
source_root('src/scala', page, scala_library, jvm_binary)

# Pants test code
source_root('tests/java', page, java_library, junit_tests, jvm_binary)
source_root('tests/python', page, python_library, python_tests, python_test_suite, python_binary,
resources)
source_root('tests/resources', page, resources)

# Pants own plugins for this repo's exclusive use
source_root('pants-plugins/src/python', page, python_binary, python_library, resources)
source_root('pants-plugins/tests/python', page, python_library, python_tests, python_test_suite,
python_binary, resources)

page(name="readme", source="README.md")
10 changes: 0 additions & 10 deletions build-support/bin/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ function run_local_pants() {
# and it'll fail. To solve that problem, we load the internal backend package
# dependencies into the pantsbuild.pants venv.
function execute_packaged_pants_with_internal_backends() {
local extra_bootstrap_buildfiles
if [[ "$1" =~ "extra_bootstrap_buildfiles" ]]; then
extra_bootstrap_buildfiles=${1#*=}
shift
fi

pip install --ignore-installed \
-r pants-plugins/3rdparty/python/requirements.txt &> /dev/null && \
PANTS_PYTHON_REPOS_REPOS="['${ROOT}/dist']" pants \
Expand All @@ -101,10 +95,6 @@ function execute_packaged_pants_with_internal_backends() {
'internal_backend.sitegen', \
'internal_backend.utilities', \
]" \
--goals-bootstrap-buildfiles="[ \
'${ROOT}/BUILD', \
${extra_bootstrap_buildfiles}
]" \
"$@"
}

Expand Down
22 changes: 5 additions & 17 deletions contrib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ Contrib plugins should generally follow 3 basic setup steps:
The only hard requirement though is the `register.py` entry point file in the main src dir -
in this example: `contrib/example/src/python/pants/contrib/example/register.py`.

Source roots for this layout would be added to contrib/example/BUILD:
```
source_root('src/python', page, python_library, resources)
source_root('tests/python', page, python_library, python_tests, resources)
```
Source roots for this layout should match your source root patterns. The default patterns
are typically sufficient.

**NB: python code should be in the pants/contrib and pants_test/contrib namespaces and the
`__init__.py` files for these shared root namespaces should contain a namespace declaration
like so:**
Expand All @@ -37,8 +35,8 @@ Contrib plugins should generally follow 3 basic setup steps:
```

2. Make the local pants aware of your plugin
This involves 3 edits to `pants.ini`. You'll need to add one entry in each of the
`pythonpath`, `backend_packages` and `bootstrap_buildfiles` lists:
This involves 2 edits to `pants.ini`. You'll need to add one entry in each of the
`pythonpath` and `backend_packages` lists:
```ini
[DEFAULT]
# Enable our own custom loose-source plugins as well as contribs.
Expand All @@ -58,16 +56,6 @@ Contrib plugins should generally follow 3 basic setup steps:
"pants.contrib.example", # 2
...
]
...
[goals]
bootstrap_buildfiles: [
"%(buildroot)s/BUILD",
...
"%(buildroot)s/contrib/example/BUILD", # 3
...
"%(buildroot)s/examples/BUILD",
"%(buildroot)s/testprojects/BUILD",
]
```

3. When you're ready for your plugin to be distributed, convert your main `python_library` plugin
Expand Down
5 changes: 0 additions & 5 deletions contrib/buildgen/BUILD

This file was deleted.

5 changes: 0 additions & 5 deletions contrib/cpp/BUILD

This file was deleted.

8 changes: 0 additions & 8 deletions contrib/go/BUILD

This file was deleted.

8 changes: 0 additions & 8 deletions contrib/node/BUILD

This file was deleted.

2 changes: 0 additions & 2 deletions contrib/release_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ PKG_GO=(
)
function pkg_go_install_test() {
execute_packaged_pants_with_internal_backends \
"extra_bootstrap_buildfiles='${ROOT}/contrib/go/BUILD'" \
--plugins="['pantsbuild.pants.contrib.go==$(local_version)']" \
test.go contrib/go/examples::
}
Expand All @@ -74,7 +73,6 @@ console.log("type of boolean is: " + typ.BOOLEAN);
EOF
) | \
execute_packaged_pants_with_internal_backends \
"extra_bootstrap_buildfiles='${ROOT}/contrib/node/BUILD'" \
--plugins="['pantsbuild.pants.contrib.node==$(local_version)']" \
repl.node contrib/node/examples::
}
Expand Down
6 changes: 0 additions & 6 deletions contrib/scrooge/BUILD

This file was deleted.

7 changes: 0 additions & 7 deletions contrib/spindle/BUILD

This file was deleted.

21 changes: 0 additions & 21 deletions examples/BUILD

This file was deleted.

1 change: 0 additions & 1 deletion migrations/options/src/python/migrate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
migrations = {
('backends', 'packages'): ('DEFAULT', 'backend_packages'),
('backends', 'plugins'): ('DEFAULT', 'plugins'),
('DEFAULT', 'bootstrap_buildfiles'): ('goals', 'bootstrap_buildfiles'),

('jvm', 'missing_deps_target_whitelist'): ('compile.jvm-dep-check', 'missing_deps_whitelist'),
('jvm', 'jdk_paths'): ('jvm-distributions', 'paths'),
Expand Down
14 changes: 0 additions & 14 deletions pants.ini
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,6 @@ read_from = ["%(local_artifact_cache)s"]
write_to = ["%(local_artifact_cache)s"]


[goals]
bootstrap_buildfiles: [
"%(buildroot)s/BUILD",
"%(buildroot)s/contrib/buildgen/BUILD",
"%(buildroot)s/contrib/cpp/BUILD",
"%(buildroot)s/contrib/go/BUILD",
"%(buildroot)s/contrib/node/BUILD",
"%(buildroot)s/contrib/scrooge/BUILD",
"%(buildroot)s/contrib/spindle/BUILD",
"%(buildroot)s/examples/BUILD",
"%(buildroot)s/testprojects/BUILD",
]


[ivy]
# A custom ivysettings.xml file to allow for consumption from a local .m2 repository.
# If you don't need access to a local .m2 repository, remove this setting to use the default.
Expand Down
67 changes: 9 additions & 58 deletions src/docs/setup_repo.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,66 +66,17 @@ perhaps change some version numbers to fit your situation.
it uses; so, if the version you specify does not match either of those expectations, pants will
fail when it tries to call the tool.

Configure Code Layout with `source_root`, `maven_layout`
--------------------------------------------------------

Maybe someday all the world's programmers will agree on the one true
directory structure for source code. Until then, you'll want some
<a pantsref="bdict_source_root">`source_root`</a>
rules to specify which directories hold your code. A
typical programming language has a notion of *base paths* for imports;
you configure pants to tell it those base paths.

If your project's source tree is laid out for Maven, there's a shortcut
function
<a pantsref="bdict_maven_layout">`maven_layout`</a>
that configures source roots for Maven's expected
source code tree structure. See
[`testprojects/maven_layout`](https://github.com/pantsbuild/pants/tree/master/testprojects/maven_layout)
for examples of using this style source tree.

### Organized by Language

If your top-level `BUILD` file is `top/BUILD` and your main Java code is
in `top/src/java/com/foo/` and your Java tests are in
`top/src/javatest/com/foo/`, then your top-level `BUILD` file might look
like:

:::python
# top/BUILD
source_root('src/java')
source_root('src/javatest')
...

Pants can optionally enforce that only certain target types are allowed
under each source root:

:::python
# top/BUILD
source_root('src/java', annotation_processor, doc, jvm_binary, java_library, page)
source_root('src/javatest', doc, java_library, java_tests, page)
...
Set up source roots
-------------------

### Organized by Project
Maybe some day all the world's programmers will agree on the one true directory structure for
source code. Until then, Pants must deduce where the 'root' of a source tree is, so it can
correctly set up import paths, correctly bundle code etc.

If your top-level `BUILD` file is `top/BUILD` and the Java code for your
Theodore and Hank projects live in `top/theodore/src/java/com/foo/`,
then your top-level `BUILD` file might not contain any `source_root`
statements. Instead, `theodore/BUILD` and `hank/BUILD` might look like:

:::python
# top/(project)/BUILD
source_root('src/java')
source_root('src/javatest')
...

Or:

:::python
# top/(project)/BUILD
source_root('src/java', annotation_processor, doc, jvm_binary, java_library, page)
source_root('src/javatest', doc, java_library, java_tests, page)
...
In all typical cases, Pants can deduce the source roots automatically based on naming conventions.
E.g., `src/<lang>`, `src/main/<lang>`, `test/<lang>`, `src/test/<lang>`, `3rdparty/lang` and so on.
However if your source roots don't conform to any of the default patterns, you can add your own
patterns. See ` ./pants help-advanced source` for details.

Setting up `BUILD` files
------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/python/pants/backend/project_info/tasks/ide_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ def register_options(cls, register):
help='Includes scala sources in the project; otherwise compiles them and adds them '
'to the project classpath.')
register('--use-source-root', action='store_true', default=False,
help='Use source_root() settings to collapse sourcepaths in project and determine '
help='Use source roots to collapse sourcepaths in project and determine '
'which paths are used for tests. This is usually what you want if your repo '
' uses a maven style directory layout.')
register('--infer-test-from-siblings', action='store_true',
deprecated_version='0.0.57',
deprecated_hint='Setting test attribute on paths is now handled automatically.',
help='When determining if a path should be added to the IDE, check to see if any of '
'its sibling source_root() entries define test targets. This is usually what '
'its sibling source roots define test targets. This is usually what '
'you want so that resource directories under test source roots are picked up as '
'test paths.')
register('--debug_port', type=int, default=5005,
Expand Down
3 changes: 3 additions & 0 deletions src/python/pants/bin/goal_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def register_options(cls, register):
super(SourceRootBootstrapper, cls).register_options(register)
# TODO: Get rid of this in favor of source root registration at backend load time.
register('--bootstrap-buildfiles', advanced=True, type=list_option, default=[],
deprecated_version='0.0.59',
deprecated_hint='bootstrap BUILD files are no longer necessary or supported. '
'Source roots are configured in pants.ini or by default.',
help='Initialize state by evaluating these buildfiles.')

def bootstrap(self, address_mapper, build_file_parser):
Expand Down
18 changes: 0 additions & 18 deletions testprojects/BUILD

This file was deleted.

3 changes: 1 addition & 2 deletions testprojects/maven_layout/junit_resource_collision/BUILD
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

maven_layout()

target(name='junit_resource_collision',
dependencies=[
'testprojects/maven_layout/junit_resource_collision/onedir/src/test/java',
'testprojects/maven_layout/junit_resource_collision/twodir/src/test/java',
],
)
)
4 changes: 0 additions & 4 deletions testprojects/maven_layout/maven_and_pants/BUILD

This file was deleted.

5 changes: 0 additions & 5 deletions testprojects/maven_layout/protolib-external-test/BUILD

This file was deleted.

5 changes: 0 additions & 5 deletions testprojects/maven_layout/protolib-test/BUILD

This file was deleted.

4 changes: 0 additions & 4 deletions testprojects/maven_layout/resource_collision/example_a/BUILD

This file was deleted.

4 changes: 0 additions & 4 deletions testprojects/maven_layout/resource_collision/example_b/BUILD

This file was deleted.

4 changes: 0 additions & 4 deletions testprojects/maven_layout/resource_collision/example_c/BUILD

This file was deleted.

4 changes: 0 additions & 4 deletions testprojects/maven_layout/resource_collision/lib/BUILD

This file was deleted.

1 change: 0 additions & 1 deletion tests/python/pants_test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ python_tests(
sources = ['test_maven_layout.py'],
dependencies = [
':base_test',
'src/python/pants/backend/maven_layout',
'src/python/pants/build_graph',
'src/python/pants/source',
'tests/python/pants_test/subsystem:subsystem_utils',
Expand Down
Loading

0 comments on commit ba0450a

Please sign in to comment.