Skip to content

Commit

Permalink
Move Shader from pants.java to the jvm backend.
Browse files Browse the repository at this point in the history
As things stood, the core pants.java utilties had to depend on the jvm
backend, forcing backends like python to have to do said same
transitively.  All uses of the Shader are in the jvm backend, so the
move is clean.

Testing Done:
CI went green here:
  https://travis-ci.org/pantsbuild/pants/builds/79552477

Bugs closed: 2154, 2159

Reviewed at https://rbcommons.com/s/twitter/r/2788/
  • Loading branch information
jsirois committed Sep 10, 2015
1 parent 8e119c2 commit 97d3bb6
Show file tree
Hide file tree
Showing 18 changed files with 68 additions and 66 deletions.
2 changes: 1 addition & 1 deletion src/python/pants/backend/jvm/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ python_library(
':ossrh_publication_metadata',
':repository',
'src/python/pants/backend/core/tasks:group_task',
'src/python/pants/backend/jvm/subsystems:shader',
'src/python/pants/backend/jvm/targets:all',
'src/python/pants/backend/jvm/tasks:all',
'src/python/pants/base:build_file_aliases',
'src/python/pants/goal',
'src/python/pants/goal:task_registrar',
'src/python/pants/java/jar:shader',
],
)

Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/jvm/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from pants.backend.jvm.ossrh_publication_metadata import (Developer, License,
OSSRHPublicationMetadata, Scm)
from pants.backend.jvm.repository import Repository
from pants.backend.jvm.subsystems.shader import Shading
from pants.backend.jvm.targets.annotation_processor import AnnotationProcessor
from pants.backend.jvm.targets.benchmark import Benchmark
from pants.backend.jvm.targets.credentials import Credentials
Expand Down Expand Up @@ -52,7 +53,6 @@
from pants.base.build_file_aliases import BuildFileAliases
from pants.goal.goal import Goal
from pants.goal.task_registrar import TaskRegistrar as task
from pants.java.jar.shader import Shading


def build_file_aliases():
Expand Down
15 changes: 14 additions & 1 deletion src/python/pants/backend/jvm/subsystems/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,17 @@ python_library(
'src/python/pants/option',
'src/python/pants/subsystem',
],
)
)

python_library(
name = 'shader',
sources = ['shader.py'],
dependencies = [
'src/python/pants/backend/jvm/targets:jvm',
'src/python/pants/backend/jvm/tasks:jvm_tool_task_mixin',
'src/python/pants/java/distribution',
'src/python/pants/java:executor',
'src/python/pants/subsystem',
'src/python/pants/util:contextutil',
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from collections import namedtuple
from contextlib import contextmanager

from pants.backend.jvm.subsystems.jvm_tool_mixin import JvmToolMixin
from pants.backend.jvm.targets.jar_dependency import JarDependency
from pants.backend.jvm.tasks.jvm_tool_task_mixin import JvmToolMixin
from pants.java.distribution.distribution import DistributionLocator
from pants.java.executor import SubprocessExecutor
from pants.subsystem.subsystem import Subsystem, SubsystemError
Expand Down
12 changes: 6 additions & 6 deletions src/python/pants/backend/jvm/tasks/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ python_library(
dependencies = [
':ivy_task_mixin',
':jar_task',
'src/python/pants/backend/jvm/subsystems:jvm_tool_mixin',
'src/python/pants/backend/jvm/subsystems:shader',
'src/python/pants/base:cache_manager',
'src/python/pants/base:exceptions',
'src/python/pants/base:workunit',
'src/python/pants/ivy',
'src/python/pants/java:executor',
'src/python/pants/java:util',
'src/python/pants/java/jar:shader',
'src/python/pants/backend/jvm/subsystems:jvm_tool_mixin',
'src/python/pants/util:dirutil',
'src/python/pants/util:memo',
],
Expand Down Expand Up @@ -110,9 +110,9 @@ python_library(
dependencies = [
'3rdparty/python/twitter/commons:twitter.common.collections',
':nailgun_task',
'src/python/pants/backend/jvm/subsystems:shader',
'src/python/pants/backend/jvm/targets:jvm',
'src/python/pants/base:exceptions',
'src/python/pants/java/jar:shader',
'src/python/pants/option',
'src/python/pants/process',
'src/python/pants/util:dirutil',
Expand Down Expand Up @@ -274,12 +274,12 @@ python_library(
':jvm_task',
':jvm_tool_task_mixin',
'src/python/pants/backend/core/tasks:task',
'src/python/pants/backend/jvm/subsystems:shader',
'src/python/pants/backend/jvm/targets:java',
'src/python/pants/backend/jvm/targets:jvm',
'src/python/pants/base:build_environment',
'src/python/pants/base:workunit',
'src/python/pants/binaries:binary_util',
'src/python/pants/java/jar:shader',
'src/python/pants/java:util',
'src/python/pants/util:contextutil',
'src/python/pants/util:dirutil',
Expand All @@ -291,11 +291,11 @@ python_library(
name = 'jvm_binary_task',
sources = ['jvm_binary_task.py'],
dependencies = [
':jar_task',
'3rdparty/python/twitter/commons:twitter.common.collections',
':jar_task',
'src/python/pants/backend/jvm/subsystems:shader',
'src/python/pants/backend/jvm/targets:jvm',
'src/python/pants/base:exceptions',
'src/python/pants/java/jar:shader',
'src/python/pants/util:contextutil',
'src/python/pants/util:fileutil',
'src/python/pants/util:memo',
Expand Down
3 changes: 1 addition & 2 deletions src/python/pants/backend/jvm/tasks/bootstrap_jvm_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from textwrap import dedent

from pants.backend.jvm.subsystems.jvm_tool_mixin import JvmToolMixin
from pants.backend.jvm.targets.jar_dependency import JarDependency
from pants.backend.jvm.subsystems.shader import Shader
from pants.backend.jvm.targets.jar_library import JarLibrary
from pants.backend.jvm.tasks.ivy_task_mixin import IvyResolveFingerprintStrategy, IvyTaskMixin
from pants.backend.jvm.tasks.jar_task import JarTask
Expand All @@ -25,7 +25,6 @@
from pants.ivy.ivy_subsystem import IvySubsystem
from pants.java import util
from pants.java.executor import Executor
from pants.java.jar.shader import Shader
from pants.util.dirutil import safe_mkdir_for
from pants.util.memo import memoized_property

Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/jvm/tasks/checkstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

from twitter.common.collections import OrderedSet

from pants.backend.jvm.subsystems.shader import Shader
from pants.backend.jvm.targets.jar_dependency import JarDependency
from pants.backend.jvm.tasks.nailgun_task import NailgunTask
from pants.base.exceptions import TaskError
from pants.java.jar.shader import Shader
from pants.option.custom_types import dict_option, file_option
from pants.process.xargs import Xargs
from pants.util.dirutil import safe_open
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/jvm/tasks/junit_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from six.moves import range
from twitter.common.collections import OrderedSet

from pants.backend.jvm.subsystems.shader import Shader
from pants.backend.jvm.targets.jar_dependency import JarDependency
from pants.backend.jvm.targets.java_tests import JavaTests as junit_tests
from pants.backend.jvm.targets.jvm_target import JvmTarget
Expand All @@ -26,7 +27,6 @@
from pants.base.workunit import WorkUnitLabel
from pants.binaries import binary_util
from pants.java.distribution.distribution import DistributionLocator
from pants.java.jar.shader import Shader
from pants.util.contextutil import temporary_file_path
from pants.util.dirutil import (relativize_paths, safe_delete, safe_mkdir, safe_open, safe_rmtree,
touch)
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/jvm/tasks/jvm_binary_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

from twitter.common.collections.orderedset import OrderedSet

from pants.backend.jvm.subsystems.shader import Shader
from pants.backend.jvm.targets.jvm_binary import JvmBinary
from pants.backend.jvm.tasks.jar_task import JarTask
from pants.base.exceptions import TaskError
from pants.java.jar.shader import Shader
from pants.java.util import execute_runner
from pants.util.contextutil import temporary_dir
from pants.util.fileutil import atomic_copy
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/jvm/tasks/jvm_compile/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ python_library(
':analysis_tools',
':jvm_compile',
'src/python/pants/backend/jvm/subsystems:scala_platform',
'src/python/pants/backend/jvm/subsystems:shader',
'src/python/pants/backend/jvm/targets:jvm',
'src/python/pants/backend/jvm/targets:scala',
'src/python/pants/base:exceptions',
'src/python/pants/base:hash_utils',
'src/python/pants/base:workunit',
'src/python/pants/java/jar:shader',
'src/python/pants/option',
'src/python/pants/util:contextutil',
'src/python/pants/util:dirutil',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from xml.etree import ElementTree

from pants.backend.jvm.subsystems.scala_platform import ScalaPlatform
from pants.backend.jvm.subsystems.shader import Shader
from pants.backend.jvm.targets.jar_dependency import JarDependency
from pants.backend.jvm.tasks.jvm_compile.analysis_tools import AnalysisTools
from pants.backend.jvm.tasks.jvm_compile.jvm_compile import JvmCompile
Expand All @@ -21,7 +22,6 @@
from pants.base.hash_utils import hash_file
from pants.base.workunit import WorkUnitLabel
from pants.java.distribution.distribution import DistributionLocator
from pants.java.jar.shader import Shader
from pants.option.custom_types import dict_option
from pants.util.contextutil import open_zip
from pants.util.dirutil import relativize_paths, safe_open
Expand Down
20 changes: 1 addition & 19 deletions src/python/pants/java/jar/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,4 @@ python_library(
dependencies=[
'3rdparty/python:six',
]
)

python_library(
name='shader',
sources=['shader.py'],
dependencies=[
# TODO(John Sirois): This is a bad dependency; either Shader should move to the jvm backend
# or JarDependency should move here. Keep in mind the Shader should process JvmBinary targets
# directly, which suggests the Shader -> jvm backend move.
# See: https://github.com/pantsbuild/pants/issues/2154
'src/python/pants/backend/jvm/targets:jvm',
'src/python/pants/backend/jvm/tasks:jvm_tool_task_mixin',

'src/python/pants/java/distribution',
'src/python/pants/java:executor',
'src/python/pants/subsystem',
'src/python/pants/util:contextutil',
]
)
)
35 changes: 35 additions & 0 deletions tests/python/pants_test/backend/jvm/subsystems/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

target(
name='subsystems',
dependencies=[
':shader'
]
)

python_tests(
name='shader',
sources=['test_shader.py'],
dependencies=[
'src/python/pants/backend/jvm/subsystems:shader',
'src/python/pants/java/distribution',
'src/python/pants/java:executor',
'src/python/pants/util:contextutil',
'src/python/pants/util:dirutil',
'tests/python/pants_test/subsystem:subsystem_utils',
]
)

python_tests(
name='shader_integration',
sources=['test_shader_integration.py'],
dependencies=[
'src/python/pants/fs',
'src/python/pants/java/distribution',
'src/python/pants/java:executor',
'src/python/pants/util:contextutil',
'tests/python/pants_test/subsystem:subsystem_utils',
'tests/python/pants_test:int-test',
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import tempfile
import unittest

from pants.backend.jvm.subsystems.shader import Shader, Shading
from pants.java.distribution.distribution import DistributionLocator
from pants.java.executor import SubprocessExecutor
from pants.java.jar.shader import Shader, Shading
from pants.util.contextutil import open_zip
from pants.util.dirutil import safe_delete
from pants_test.subsystem.subsystem_util import subsystem_instance
Expand Down
2 changes: 1 addition & 1 deletion tests/python/pants_test/backend/jvm/tasks/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ python_tests(
sources = ['test_bootstrap_jvm_tools.py'],
dependencies = [
'src/python/pants/backend/core/tasks:task',
'src/python/pants/backend/jvm/subsystems:shader',
'src/python/pants/backend/jvm/targets:jvm',
'src/python/pants/backend/jvm/tasks:bootstrap_jvm_tools',
'src/python/pants/backend/jvm/tasks:jvm_tool_task_mixin',
'src/python/pants/java/distribution',
'src/python/pants/java:executor',
'src/python/pants/java/jar:shader',
'src/python/pants/util:contextutil',
'tests/python/pants_test/jvm:jvm_tool_task_test_base',
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
from contextlib import contextmanager

from pants.backend.core.tasks.task import Task
from pants.backend.jvm.subsystems.shader import Shading
from pants.backend.jvm.targets.jar_dependency import JarDependency
from pants.backend.jvm.targets.jar_library import JarLibrary
from pants.backend.jvm.tasks.bootstrap_jvm_tools import BootstrapJvmTools
from pants.backend.jvm.tasks.jvm_tool_task_mixin import JvmToolTaskMixin
from pants.java.distribution.distribution import DistributionLocator
from pants.java.executor import SubprocessExecutor
from pants.java.jar.shader import Shading
from pants.util.contextutil import open_zip
from pants_test.jvm.jvm_tool_task_test_base import JvmToolTaskTestBase
from pants_test.subsystem.subsystem_util import subsystem_instance
Expand Down
27 changes: 0 additions & 27 deletions tests/python/pants_test/java/jar/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ target(
name = 'jar',
dependencies = [
':manifest',
':shader'
]
)

Expand All @@ -16,29 +15,3 @@ python_tests(
'src/python/pants/java/jar:manifest',
]
)

python_tests(
name = 'shader',
sources = ['test_shader.py'],
dependencies = [
'src/python/pants/java/distribution',
'src/python/pants/java/jar:shader',
'src/python/pants/java:executor',
'src/python/pants/util:contextutil',
'src/python/pants/util:dirutil',
'tests/python/pants_test/subsystem:subsystem_utils',
]
)

python_tests(
name='shader_integration',
sources=['test_shader_integration.py'],
dependencies=[
'src/python/pants/fs',
'src/python/pants/java/distribution',
'src/python/pants/java:executor',
'src/python/pants/util:contextutil',
'tests/python/pants_test/subsystem:subsystem_utils',
'tests/python/pants_test:int-test',
],
)

0 comments on commit 97d3bb6

Please sign in to comment.