Skip to content

Commit

Permalink
Add --globs and replace V1 goal
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Arellano committed Aug 20, 2019
1 parent 9356a5e commit 7e30b9c
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 428 deletions.
2 changes: 0 additions & 2 deletions src/python/pants/backend/project_info/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from pants.backend.project_info.tasks.dependencies import Dependencies
from pants.backend.project_info.tasks.depmap import Depmap
from pants.backend.project_info.tasks.export import Export
from pants.backend.project_info.tasks.filedeps import FileDeps
from pants.backend.project_info.tasks.idea_plugin_gen import IdeaPluginGen
from pants.goal.task_registrar import TaskRegistrar as task

Expand All @@ -20,7 +19,6 @@ def register_goals():

task(name='depmap', action=Depmap).install()
task(name='dependencies', action=Dependencies).install()
task(name='filedeps', action=FileDeps).install('filedeps')


def rules():
Expand Down
13 changes: 0 additions & 13 deletions src/python/pants/backend/project_info/tasks/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ target(
':dependencies',
':depmap',
':export',
':filedeps',
':idea_plugin_gen',
],
)
Expand Down Expand Up @@ -60,18 +59,6 @@ python_library(
],
)

python_library(
name = 'filedeps',
sources = ['filedeps.py'],
dependencies = [
'src/python/pants/backend/jvm/targets:jvm',
'src/python/pants/backend/jvm/targets:scala',
'src/python/pants/base:build_environment',
'src/python/pants/build_graph',
'src/python/pants/task',
],
)

python_library(
name = 'idea_plugin_gen',
sources = ['idea_plugin_gen.py'],
Expand Down
64 changes: 0 additions & 64 deletions src/python/pants/backend/project_info/tasks/filedeps.py

This file was deleted.

15 changes: 11 additions & 4 deletions src/python/pants/rules/core/filedeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,26 @@ class Filedeps(LineOriented, Goal):
closure of targets are also included.
"""

# TODO: Until this implements `--globs`, this can't claim the name `filedeps`!
name = 'fast-filedeps'
name = 'filedeps'

@classmethod
def register_options(cls, register):
super().register_options(register)
register(
'--absolute', type=bool, default=True,
help='If True, output with absolute path; else, output with path relative to the build root.'
help='If True, output with absolute path; else, output with path relative to the build root'
)
register(
'--globs', type=bool,
help='Instead of outputting filenames, output globs (ignoring excludes)'
)


@console_rule(Filedeps, [Console, Filedeps.Options, TransitiveHydratedTargets])
def file_deps(console, filedeps_options, transitive_hydrated_targets):

absolute = filedeps_options.values.absolute
globs = filedeps_options.values.globs

unique_rel_paths = set()
build_root = get_buildroot()
Expand All @@ -41,7 +45,10 @@ def file_deps(console, filedeps_options, transitive_hydrated_targets):
if hydrated_target.address.rel_path:
unique_rel_paths.add(hydrated_target.address.rel_path)
if hasattr(hydrated_target.adaptor, "sources"):
unique_rel_paths.update(hydrated_target.adaptor.sources.snapshot.files)
target_sources = hydrated_target.adaptor.sources
unique_rel_paths.update(
target_sources.snapshot.files if not globs else target_sources.filespec["globs"]
)

with Filedeps.line_oriented(filedeps_options, console) as (print_stdout, _):
for rel_path in sorted(unique_rel_paths):
Expand Down
13 changes: 0 additions & 13 deletions tests/python/pants_test/backend/project_info/tasks/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,6 @@ python_tests(
timeout = 480,
)

python_tests(
name = 'filedeps',
sources = ['test_filedeps.py'],
dependencies = [
'src/python/pants/backend/codegen:plugin',
'src/python/pants/backend/jvm:plugin',
'src/python/pants/backend/jvm/targets:java',
'src/python/pants/backend/project_info/tasks:filedeps',
'src/python/pants/build_graph',
'tests/python/pants_test:task_test_base',
],
)

python_tests(
name = 'idea_plugin_integration',
sources = ['test_idea_plugin_integration.py'],
Expand Down
Loading

0 comments on commit 7e30b9c

Please sign in to comment.