From 8ea25c26e863af84f081ace36b16b5c0f57a0aff Mon Sep 17 00:00:00 2001 From: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com> Date: Fri, 15 May 2020 09:26:16 -0700 Subject: [PATCH] Remove deprecated contrib plugins (#9762) Refer to https://groups.google.com/forum/#!topic/pants-devel/ngMZRIJvwHM. [ci skip-rust-tests] [ci skip-jvm-tests] --- BUILD | 8 - BUILD.tools | 34 -- contrib/BUILD | 8 - contrib/avro/BUILD | 7 - contrib/avro/README.md | 6 - contrib/avro/src/python/pants/__init__.py | 1 - .../avro/src/python/pants/contrib/__init__.py | 1 - .../avro/src/python/pants/contrib/avro/BUILD | 29 -- .../src/python/pants/contrib/avro/__init__.py | 1 - .../src/python/pants/contrib/avro/register.py | 27 -- .../python/pants/contrib/avro/target_types.py | 13 - .../python/pants/contrib/avro/targets/BUILD | 10 - .../pants/contrib/avro/targets/__init__.py | 1 - .../contrib/avro/targets/java_avro_library.py | 17 - .../src/python/pants/contrib/avro/tasks/BUILD | 17 - .../pants/contrib/avro/tasks/__init__.py | 1 - .../pants/contrib/avro/tasks/avro_gen.py | 92 ------ .../avro/org/pantsbuild/contrib/avro/BUILD | 12 - .../org/pantsbuild/contrib/avro/simple.avdl | 41 --- .../org/pantsbuild/contrib/avro/user.avsc | 9 - .../contrib/avro/AvroJavaGenTest.java | 54 ---- .../java/org/pantsbuild/contrib/avro/BUILD | 10 - .../avro/tests/python/pants_test/__init__.py | 0 .../python/pants_test/contrib/__init__.py | 0 .../pants_test/contrib/avro/__init__.py | 0 .../pants_test/contrib/avro/tasks/BUILD | 24 -- .../pants_test/contrib/avro/tasks/__init__.py | 0 .../contrib/avro/tasks/test_avro_gen.py | 107 ------- .../avro/tasks/test_avro_gen_integration.py | 87 ----- contrib/cpp/BUILD | 7 - contrib/cpp/README.md | 4 - contrib/cpp/examples/src/cpp/calcsqrt/BUILD | 9 - contrib/cpp/examples/src/cpp/calcsqrt/main.cc | 16 - contrib/cpp/examples/src/cpp/example/BUILD | 9 - .../cpp/examples/src/cpp/example/hello/BUILD | 10 - .../examples/src/cpp/example/hello/hello.cc | 17 - .../examples/src/cpp/example/hello/hello.h | 14 - contrib/cpp/examples/src/cpp/example/main.cc | 6 - contrib/cpp/src/python/pants/__init__.py | 1 - .../cpp/src/python/pants/contrib/__init__.py | 1 - .../cpp/src/python/pants/contrib/cpp/BUILD | 28 -- .../src/python/pants/contrib/cpp/__init__.py | 0 .../src/python/pants/contrib/cpp/register.py | 33 -- .../python/pants/contrib/cpp/target_types.py | 44 --- .../python/pants/contrib/cpp/targets/BUILD | 18 -- .../pants/contrib/cpp/targets/__init__.py | 0 .../pants/contrib/cpp/targets/cpp_binary.py | 25 -- .../pants/contrib/cpp/targets/cpp_library.py | 8 - .../pants/contrib/cpp/targets/cpp_target.py | 23 -- .../src/python/pants/contrib/cpp/tasks/BUILD | 22 -- .../pants/contrib/cpp/tasks/__init__.py | 0 .../contrib/cpp/tasks/cpp_binary_create.py | 92 ------ .../pants/contrib/cpp/tasks/cpp_compile.py | 108 ------- .../contrib/cpp/tasks/cpp_library_create.py | 67 ---- .../python/pants/contrib/cpp/tasks/cpp_run.py | 32 -- .../pants/contrib/cpp/tasks/cpp_task.py | 53 --- .../python/pants/contrib/cpp/toolchain/BUILD | 6 - .../pants/contrib/cpp/toolchain/__init__.py | 0 .../contrib/cpp/toolchain/cpp_toolchain.py | 63 ---- .../cpp/tests/python/pants_test/__init__.py | 1 - .../python/pants_test/contrib/__init__.py | 1 - .../tests/python/pants_test/contrib/cpp/BUILD | 27 -- .../contrib/cpp/test_cpp_integration.py | 86 ----- .../contrib/cpp/test_cpp_toolchain.py | 45 --- contrib/errorprone/BUILD | 7 - contrib/errorprone/README.md | 71 ---- .../errorprone/src/python/pants/__init__.py | 1 - .../src/python/pants/contrib/__init__.py | 1 - .../src/python/pants/contrib/errorprone/BUILD | 15 - .../pants/contrib/errorprone/__init__.py | 0 .../pants/contrib/errorprone/register.py | 18 -- .../pants/contrib/errorprone/tasks/BUILD | 15 - .../contrib/errorprone/tasks/__init__.py | 0 .../contrib/errorprone/tasks/errorprone.py | 227 ------------- .../errorprone/ArrayToStringError.java | 13 - .../org/pantsbuild/contrib/errorprone/BUILD | 22 -- .../pantsbuild/contrib/errorprone/Empty.java | 6 - .../contrib/errorprone/NoWarnings.java | 10 - .../errorprone/ReferenceEqualityWarning.java | 12 - .../python/pants_test/contrib/__init__.py | 1 - .../pants_test/contrib/errorprone/__init__.py | 1 - .../pants_test/contrib/errorprone/tasks/BUILD | 24 -- .../contrib/errorprone/tasks/__init__.py | 0 .../errorprone/tasks/test_errorprone.py | 16 - .../tasks/test_errorprone_integration.py | 133 -------- contrib/findbugs/BUILD | 7 - contrib/findbugs/README.md | 91 ------ contrib/findbugs/src/python/pants/__init__.py | 1 - .../src/python/pants/contrib/__init__.py | 1 - .../src/python/pants/contrib/findbugs/BUILD | 15 - .../python/pants/contrib/findbugs/__init__.py | 0 .../python/pants/contrib/findbugs/register.py | 17 - .../python/pants/contrib/findbugs/tasks/BUILD | 18 -- .../pants/contrib/findbugs/tasks/__init__.py | 0 .../pants/contrib/findbugs/tasks/findbugs.py | 303 ------------------ .../contrib/findbugs/AllWarnings.java | 18 -- .../org/pantsbuild/contrib/findbugs/BUILD | 47 --- .../pantsbuild/contrib/findbugs/Empty.java | 6 - .../contrib/findbugs/HighWarning.java | 12 - .../contrib/findbugs/LowWarning.java | 10 - .../contrib/findbugs/NoWarnings.java | 10 - .../contrib/findbugs/NormalWarning.java | 11 - .../tests/python/pants_test/__init__.py | 1 - .../python/pants_test/contrib/__init__.py | 1 - .../pants_test/contrib/findbugs/__init__.py | 0 .../pants_test/contrib/findbugs/tasks/BUILD | 24 -- .../contrib/findbugs/tasks/__init__.py | 0 .../contrib/findbugs/tasks/test_findbugs.py | 16 - .../tasks/test_findbugs_integration.py | 143 --------- .../src/python/pants/__init__.py | 1 - .../src/python/pants/contrib/__init__.py | 1 - .../pants/contrib/googlejavaformat/BUILD | 22 -- .../contrib/googlejavaformat/__init__.py | 0 .../googlejavaformat/googlejavaformat.py | 106 ------ .../contrib/googlejavaformat/register.py | 22 -- .../contrib/googlejavaformat/subsystem.py | 19 -- .../tests/python/pants_test/__init__.py | 0 .../python/pants_test/contrib/__init__.py | 0 .../pants_test/contrib/googlejavaformat/BUILD | 14 - .../contrib/googlejavaformat/__init__.py | 0 .../googlejavaformat/test_googlejavaformat.py | 105 ------ contrib/jax_ws/BUILD | 7 - contrib/jax_ws/README.md | 61 ---- contrib/jax_ws/src/python/pants/__init__.py | 1 - .../src/python/pants/contrib/__init__.py | 1 - .../src/python/pants/contrib/jax_ws/BUILD | 28 -- .../python/pants/contrib/jax_ws/__init__.py | 0 .../python/pants/contrib/jax_ws/register.py | 27 -- .../pants/contrib/jax_ws/target_types.py | 25 -- .../python/pants/contrib/jax_ws/targets/BUILD | 10 - .../pants/contrib/jax_ws/targets/__init__.py | 0 .../contrib/jax_ws/targets/jax_ws_library.py | 25 -- .../python/pants/contrib/jax_ws/tasks/BUILD | 14 - .../pants/contrib/jax_ws/tasks/__init__.py | 0 .../pants/contrib/jax_ws/tasks/jax_ws_gen.py | 94 ------ .../tests/python/pants_test/__init__.py | 1 - .../python/pants_test/contrib/__init__.py | 1 - .../pants_test/contrib/jax_ws/__init__.py | 0 .../pants_test/contrib/jax_ws/tasks/BUILD | 25 -- .../contrib/jax_ws/tasks/__init__.py | 0 .../contrib/jax_ws/tasks/test_jax_ws_gen.py | 16 - .../tasks/test_jax_ws_gen_integration.py | 116 ------- .../wsdl/org/pantsbuild/contrib/jax_ws/BUILD | 9 - .../contrib/jax_ws/HelloService.wsdl | 41 --- contrib/release_packages.sh | 63 ---- .../scalajs/3rdparty/jvm/org/scala-js/BUILD | 19 -- contrib/scalajs/BUILD | 10 - contrib/scalajs/README.md | 4 - .../scalajs/example/factfinder/BUILD | 9 - .../example/factfinder/Factfinder.scala | 15 - contrib/scalajs/src/python/pants/__init__.py | 1 - .../src/python/pants/contrib/__init__.py | 1 - .../src/python/pants/contrib/scalajs/BUILD | 31 -- .../python/pants/contrib/scalajs/__init__.py | 0 .../python/pants/contrib/scalajs/register.py | 41 --- .../pants/contrib/scalajs/subsystems/BUILD | 13 - .../contrib/scalajs/subsystems/__init__.py | 0 .../scalajs/subsystems/scala_js_platform.py | 64 ---- .../pants/contrib/scalajs/target_types.py | 29 -- .../pants/contrib/scalajs/targets/BUILD | 15 - .../pants/contrib/scalajs/targets/__init__.py | 0 .../scalajs/targets/scala_js_binary.py | 14 - .../scalajs/targets/scala_js_library.py | 31 -- .../scalajs/targets/scala_js_target.py | 59 ---- .../python/pants/contrib/scalajs/tasks/BUILD | 14 - .../pants/contrib/scalajs/tasks/__init__.py | 0 .../contrib/scalajs/tasks/scala_js_link.py | 115 ------- .../scalajs/tasks/scala_js_zinc_compile.py | 42 --- .../tests/python/pants_test/__init__.py | 1 - .../python/pants_test/contrib/__init__.py | 1 - .../pants_test/contrib/scalajs/__init__.py | 0 .../pants_test/contrib/scalajs/tasks/BUILD | 13 - .../contrib/scalajs/tasks/__init__.py | 0 .../tasks/test_scalajs_repl_integration.py | 29 -- .../scalajs/example/factfinder/BUILD | 11 - .../example/factfinder/FactfinderSpec.scala | 23 -- contrib/thrifty/src/python/pants/__init__.py | 1 - .../src/python/pants/contrib/__init__.py | 1 - .../src/python/pants/contrib/thrifty/BUILD | 27 -- .../python/pants/contrib/thrifty/__init__.py | 0 .../pants/contrib/thrifty/java_thrifty_gen.py | 89 ----- .../contrib/thrifty/java_thrifty_library.py | 16 - .../python/pants/contrib/thrifty/register.py | 29 -- .../pants/contrib/thrifty/target_types.py | 17 - .../java/org/pantsbuild/contrib/thrifty/BUILD | 9 - .../contrib/thrifty/ThriftyStructTest.java | 27 -- .../pants_test/pants/contrib/thrifty/BUILD | 10 - .../pants/contrib/thrifty/test_thrifty_gen.py | 69 ---- .../pantsbuild/contrib/thrifty/client/BUILD | 8 - .../contrib/thrifty/client/clientlog.thrift | 11 - .../pantsbuild/contrib/thrifty/common/BUILD | 4 - .../contrib/thrifty/common/common.thrift | 9 - .../scala/org/pantsbuild/example/fact/BUILD | 3 - pants.toml | 44 --- src/python/pants/base/deprecated.py | 13 - src/python/pants/releases/packages.py | 32 -- .../testutil/pants_run_integration_test.py | 2 +- .../jvm/tasks/test_checkstyle_integration.py | 10 +- 198 files changed, 2 insertions(+), 4727 deletions(-) delete mode 100644 contrib/avro/BUILD delete mode 100644 contrib/avro/README.md delete mode 100644 contrib/avro/src/python/pants/__init__.py delete mode 100644 contrib/avro/src/python/pants/contrib/__init__.py delete mode 100644 contrib/avro/src/python/pants/contrib/avro/BUILD delete mode 100644 contrib/avro/src/python/pants/contrib/avro/__init__.py delete mode 100644 contrib/avro/src/python/pants/contrib/avro/register.py delete mode 100644 contrib/avro/src/python/pants/contrib/avro/target_types.py delete mode 100644 contrib/avro/src/python/pants/contrib/avro/targets/BUILD delete mode 100644 contrib/avro/src/python/pants/contrib/avro/targets/__init__.py delete mode 100644 contrib/avro/src/python/pants/contrib/avro/targets/java_avro_library.py delete mode 100644 contrib/avro/src/python/pants/contrib/avro/tasks/BUILD delete mode 100644 contrib/avro/src/python/pants/contrib/avro/tasks/__init__.py delete mode 100644 contrib/avro/src/python/pants/contrib/avro/tasks/avro_gen.py delete mode 100644 contrib/avro/tests/avro/org/pantsbuild/contrib/avro/BUILD delete mode 100644 contrib/avro/tests/avro/org/pantsbuild/contrib/avro/simple.avdl delete mode 100644 contrib/avro/tests/avro/org/pantsbuild/contrib/avro/user.avsc delete mode 100644 contrib/avro/tests/java/org/pantsbuild/contrib/avro/AvroJavaGenTest.java delete mode 100644 contrib/avro/tests/java/org/pantsbuild/contrib/avro/BUILD delete mode 100644 contrib/avro/tests/python/pants_test/__init__.py delete mode 100644 contrib/avro/tests/python/pants_test/contrib/__init__.py delete mode 100644 contrib/avro/tests/python/pants_test/contrib/avro/__init__.py delete mode 100644 contrib/avro/tests/python/pants_test/contrib/avro/tasks/BUILD delete mode 100644 contrib/avro/tests/python/pants_test/contrib/avro/tasks/__init__.py delete mode 100644 contrib/avro/tests/python/pants_test/contrib/avro/tasks/test_avro_gen.py delete mode 100644 contrib/avro/tests/python/pants_test/contrib/avro/tasks/test_avro_gen_integration.py delete mode 100644 contrib/cpp/BUILD delete mode 100644 contrib/cpp/README.md delete mode 100644 contrib/cpp/examples/src/cpp/calcsqrt/BUILD delete mode 100644 contrib/cpp/examples/src/cpp/calcsqrt/main.cc delete mode 100644 contrib/cpp/examples/src/cpp/example/BUILD delete mode 100644 contrib/cpp/examples/src/cpp/example/hello/BUILD delete mode 100644 contrib/cpp/examples/src/cpp/example/hello/hello.cc delete mode 100644 contrib/cpp/examples/src/cpp/example/hello/hello.h delete mode 100644 contrib/cpp/examples/src/cpp/example/main.cc delete mode 100644 contrib/cpp/src/python/pants/__init__.py delete mode 100644 contrib/cpp/src/python/pants/contrib/__init__.py delete mode 100644 contrib/cpp/src/python/pants/contrib/cpp/BUILD delete mode 100644 contrib/cpp/src/python/pants/contrib/cpp/__init__.py delete mode 100644 contrib/cpp/src/python/pants/contrib/cpp/register.py delete mode 100644 contrib/cpp/src/python/pants/contrib/cpp/target_types.py delete mode 100644 contrib/cpp/src/python/pants/contrib/cpp/targets/BUILD delete mode 100644 contrib/cpp/src/python/pants/contrib/cpp/targets/__init__.py delete mode 100644 contrib/cpp/src/python/pants/contrib/cpp/targets/cpp_binary.py delete mode 100644 contrib/cpp/src/python/pants/contrib/cpp/targets/cpp_library.py delete mode 100644 contrib/cpp/src/python/pants/contrib/cpp/targets/cpp_target.py delete mode 100644 contrib/cpp/src/python/pants/contrib/cpp/tasks/BUILD delete mode 100644 contrib/cpp/src/python/pants/contrib/cpp/tasks/__init__.py delete mode 100644 contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_binary_create.py delete mode 100644 contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_compile.py delete mode 100644 contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_library_create.py delete mode 100644 contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_run.py delete mode 100644 contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_task.py delete mode 100644 contrib/cpp/src/python/pants/contrib/cpp/toolchain/BUILD delete mode 100644 contrib/cpp/src/python/pants/contrib/cpp/toolchain/__init__.py delete mode 100644 contrib/cpp/src/python/pants/contrib/cpp/toolchain/cpp_toolchain.py delete mode 100644 contrib/cpp/tests/python/pants_test/__init__.py delete mode 100644 contrib/cpp/tests/python/pants_test/contrib/__init__.py delete mode 100644 contrib/cpp/tests/python/pants_test/contrib/cpp/BUILD delete mode 100644 contrib/cpp/tests/python/pants_test/contrib/cpp/test_cpp_integration.py delete mode 100644 contrib/cpp/tests/python/pants_test/contrib/cpp/test_cpp_toolchain.py delete mode 100644 contrib/errorprone/BUILD delete mode 100644 contrib/errorprone/README.md delete mode 100644 contrib/errorprone/src/python/pants/__init__.py delete mode 100644 contrib/errorprone/src/python/pants/contrib/__init__.py delete mode 100644 contrib/errorprone/src/python/pants/contrib/errorprone/BUILD delete mode 100644 contrib/errorprone/src/python/pants/contrib/errorprone/__init__.py delete mode 100644 contrib/errorprone/src/python/pants/contrib/errorprone/register.py delete mode 100644 contrib/errorprone/src/python/pants/contrib/errorprone/tasks/BUILD delete mode 100644 contrib/errorprone/src/python/pants/contrib/errorprone/tasks/__init__.py delete mode 100644 contrib/errorprone/src/python/pants/contrib/errorprone/tasks/errorprone.py delete mode 100644 contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/ArrayToStringError.java delete mode 100644 contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/BUILD delete mode 100644 contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/Empty.java delete mode 100644 contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/NoWarnings.java delete mode 100644 contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/ReferenceEqualityWarning.java delete mode 100644 contrib/errorprone/tests/python/pants_test/contrib/__init__.py delete mode 100644 contrib/errorprone/tests/python/pants_test/contrib/errorprone/__init__.py delete mode 100644 contrib/errorprone/tests/python/pants_test/contrib/errorprone/tasks/BUILD delete mode 100644 contrib/errorprone/tests/python/pants_test/contrib/errorprone/tasks/__init__.py delete mode 100644 contrib/errorprone/tests/python/pants_test/contrib/errorprone/tasks/test_errorprone.py delete mode 100644 contrib/errorprone/tests/python/pants_test/contrib/errorprone/tasks/test_errorprone_integration.py delete mode 100644 contrib/findbugs/BUILD delete mode 100644 contrib/findbugs/README.md delete mode 100644 contrib/findbugs/src/python/pants/__init__.py delete mode 100644 contrib/findbugs/src/python/pants/contrib/__init__.py delete mode 100644 contrib/findbugs/src/python/pants/contrib/findbugs/BUILD delete mode 100644 contrib/findbugs/src/python/pants/contrib/findbugs/__init__.py delete mode 100644 contrib/findbugs/src/python/pants/contrib/findbugs/register.py delete mode 100644 contrib/findbugs/src/python/pants/contrib/findbugs/tasks/BUILD delete mode 100644 contrib/findbugs/src/python/pants/contrib/findbugs/tasks/__init__.py delete mode 100644 contrib/findbugs/src/python/pants/contrib/findbugs/tasks/findbugs.py delete mode 100644 contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/AllWarnings.java delete mode 100644 contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/BUILD delete mode 100644 contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/Empty.java delete mode 100644 contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/HighWarning.java delete mode 100644 contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/LowWarning.java delete mode 100644 contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/NoWarnings.java delete mode 100644 contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/NormalWarning.java delete mode 100644 contrib/findbugs/tests/python/pants_test/__init__.py delete mode 100644 contrib/findbugs/tests/python/pants_test/contrib/__init__.py delete mode 100644 contrib/findbugs/tests/python/pants_test/contrib/findbugs/__init__.py delete mode 100644 contrib/findbugs/tests/python/pants_test/contrib/findbugs/tasks/BUILD delete mode 100644 contrib/findbugs/tests/python/pants_test/contrib/findbugs/tasks/__init__.py delete mode 100644 contrib/findbugs/tests/python/pants_test/contrib/findbugs/tasks/test_findbugs.py delete mode 100644 contrib/findbugs/tests/python/pants_test/contrib/findbugs/tasks/test_findbugs_integration.py delete mode 100644 contrib/googlejavaformat/src/python/pants/__init__.py delete mode 100644 contrib/googlejavaformat/src/python/pants/contrib/__init__.py delete mode 100644 contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/BUILD delete mode 100644 contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/__init__.py delete mode 100644 contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/googlejavaformat.py delete mode 100644 contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/register.py delete mode 100644 contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/subsystem.py delete mode 100644 contrib/googlejavaformat/tests/python/pants_test/__init__.py delete mode 100644 contrib/googlejavaformat/tests/python/pants_test/contrib/__init__.py delete mode 100644 contrib/googlejavaformat/tests/python/pants_test/contrib/googlejavaformat/BUILD delete mode 100644 contrib/googlejavaformat/tests/python/pants_test/contrib/googlejavaformat/__init__.py delete mode 100644 contrib/googlejavaformat/tests/python/pants_test/contrib/googlejavaformat/test_googlejavaformat.py delete mode 100644 contrib/jax_ws/BUILD delete mode 100644 contrib/jax_ws/README.md delete mode 100644 contrib/jax_ws/src/python/pants/__init__.py delete mode 100644 contrib/jax_ws/src/python/pants/contrib/__init__.py delete mode 100644 contrib/jax_ws/src/python/pants/contrib/jax_ws/BUILD delete mode 100644 contrib/jax_ws/src/python/pants/contrib/jax_ws/__init__.py delete mode 100644 contrib/jax_ws/src/python/pants/contrib/jax_ws/register.py delete mode 100644 contrib/jax_ws/src/python/pants/contrib/jax_ws/target_types.py delete mode 100644 contrib/jax_ws/src/python/pants/contrib/jax_ws/targets/BUILD delete mode 100644 contrib/jax_ws/src/python/pants/contrib/jax_ws/targets/__init__.py delete mode 100644 contrib/jax_ws/src/python/pants/contrib/jax_ws/targets/jax_ws_library.py delete mode 100644 contrib/jax_ws/src/python/pants/contrib/jax_ws/tasks/BUILD delete mode 100644 contrib/jax_ws/src/python/pants/contrib/jax_ws/tasks/__init__.py delete mode 100644 contrib/jax_ws/src/python/pants/contrib/jax_ws/tasks/jax_ws_gen.py delete mode 100644 contrib/jax_ws/tests/python/pants_test/__init__.py delete mode 100644 contrib/jax_ws/tests/python/pants_test/contrib/__init__.py delete mode 100644 contrib/jax_ws/tests/python/pants_test/contrib/jax_ws/__init__.py delete mode 100644 contrib/jax_ws/tests/python/pants_test/contrib/jax_ws/tasks/BUILD delete mode 100644 contrib/jax_ws/tests/python/pants_test/contrib/jax_ws/tasks/__init__.py delete mode 100644 contrib/jax_ws/tests/python/pants_test/contrib/jax_ws/tasks/test_jax_ws_gen.py delete mode 100644 contrib/jax_ws/tests/python/pants_test/contrib/jax_ws/tasks/test_jax_ws_gen_integration.py delete mode 100644 contrib/jax_ws/tests/wsdl/org/pantsbuild/contrib/jax_ws/BUILD delete mode 100644 contrib/jax_ws/tests/wsdl/org/pantsbuild/contrib/jax_ws/HelloService.wsdl delete mode 100644 contrib/scalajs/3rdparty/jvm/org/scala-js/BUILD delete mode 100644 contrib/scalajs/BUILD delete mode 100644 contrib/scalajs/README.md delete mode 100644 contrib/scalajs/examples/src/scala/org/pantsbuild/scalajs/example/factfinder/BUILD delete mode 100644 contrib/scalajs/examples/src/scala/org/pantsbuild/scalajs/example/factfinder/Factfinder.scala delete mode 100644 contrib/scalajs/src/python/pants/__init__.py delete mode 100644 contrib/scalajs/src/python/pants/contrib/__init__.py delete mode 100644 contrib/scalajs/src/python/pants/contrib/scalajs/BUILD delete mode 100644 contrib/scalajs/src/python/pants/contrib/scalajs/__init__.py delete mode 100644 contrib/scalajs/src/python/pants/contrib/scalajs/register.py delete mode 100644 contrib/scalajs/src/python/pants/contrib/scalajs/subsystems/BUILD delete mode 100644 contrib/scalajs/src/python/pants/contrib/scalajs/subsystems/__init__.py delete mode 100644 contrib/scalajs/src/python/pants/contrib/scalajs/subsystems/scala_js_platform.py delete mode 100644 contrib/scalajs/src/python/pants/contrib/scalajs/target_types.py delete mode 100644 contrib/scalajs/src/python/pants/contrib/scalajs/targets/BUILD delete mode 100644 contrib/scalajs/src/python/pants/contrib/scalajs/targets/__init__.py delete mode 100644 contrib/scalajs/src/python/pants/contrib/scalajs/targets/scala_js_binary.py delete mode 100644 contrib/scalajs/src/python/pants/contrib/scalajs/targets/scala_js_library.py delete mode 100644 contrib/scalajs/src/python/pants/contrib/scalajs/targets/scala_js_target.py delete mode 100644 contrib/scalajs/src/python/pants/contrib/scalajs/tasks/BUILD delete mode 100644 contrib/scalajs/src/python/pants/contrib/scalajs/tasks/__init__.py delete mode 100644 contrib/scalajs/src/python/pants/contrib/scalajs/tasks/scala_js_link.py delete mode 100644 contrib/scalajs/src/python/pants/contrib/scalajs/tasks/scala_js_zinc_compile.py delete mode 100644 contrib/scalajs/tests/python/pants_test/__init__.py delete mode 100644 contrib/scalajs/tests/python/pants_test/contrib/__init__.py delete mode 100644 contrib/scalajs/tests/python/pants_test/contrib/scalajs/__init__.py delete mode 100644 contrib/scalajs/tests/python/pants_test/contrib/scalajs/tasks/BUILD delete mode 100644 contrib/scalajs/tests/python/pants_test/contrib/scalajs/tasks/__init__.py delete mode 100644 contrib/scalajs/tests/python/pants_test/contrib/scalajs/tasks/test_scalajs_repl_integration.py delete mode 100644 contrib/scalajs/tests/scala/org/pantsbuild/scalajs/example/factfinder/BUILD delete mode 100644 contrib/scalajs/tests/scala/org/pantsbuild/scalajs/example/factfinder/FactfinderSpec.scala delete mode 100644 contrib/thrifty/src/python/pants/__init__.py delete mode 100644 contrib/thrifty/src/python/pants/contrib/__init__.py delete mode 100644 contrib/thrifty/src/python/pants/contrib/thrifty/BUILD delete mode 100644 contrib/thrifty/src/python/pants/contrib/thrifty/__init__.py delete mode 100644 contrib/thrifty/src/python/pants/contrib/thrifty/java_thrifty_gen.py delete mode 100644 contrib/thrifty/src/python/pants/contrib/thrifty/java_thrifty_library.py delete mode 100644 contrib/thrifty/src/python/pants/contrib/thrifty/register.py delete mode 100644 contrib/thrifty/src/python/pants/contrib/thrifty/target_types.py delete mode 100644 contrib/thrifty/tests/java/org/pantsbuild/contrib/thrifty/BUILD delete mode 100644 contrib/thrifty/tests/java/org/pantsbuild/contrib/thrifty/ThriftyStructTest.java delete mode 100644 contrib/thrifty/tests/python/pants_test/pants/contrib/thrifty/BUILD delete mode 100644 contrib/thrifty/tests/python/pants_test/pants/contrib/thrifty/test_thrifty_gen.py delete mode 100644 contrib/thrifty/tests/thrift/org/pantsbuild/contrib/thrifty/client/BUILD delete mode 100644 contrib/thrifty/tests/thrift/org/pantsbuild/contrib/thrifty/client/clientlog.thrift delete mode 100644 contrib/thrifty/tests/thrift/org/pantsbuild/contrib/thrifty/common/BUILD delete mode 100644 contrib/thrifty/tests/thrift/org/pantsbuild/contrib/thrifty/common/common.thrift diff --git a/BUILD b/BUILD index ae05e199681..429e005fed6 100644 --- a/BUILD +++ b/BUILD @@ -16,9 +16,6 @@ files( files( name = 'build_tools', sources = ['BUILD.tools'], - dependencies = [ - ':scalajs_3rdparty_directory', - ], ) files( @@ -31,11 +28,6 @@ files( sources = ['.isort.cfg'], ) -files( - name = 'scalajs_3rdparty_directory', - sources = ['contrib/scalajs/3rdparty/**/*'], -) - files( name = 'pants_toml', sources = ['pants.toml'], diff --git a/BUILD.tools b/BUILD.tools index 88463c4d5cc..a4e3b8e999f 100644 --- a/BUILD.tools +++ b/BUILD.tools @@ -1,29 +1,6 @@ # JVM artifacts that Pants itself depends on. # http://pantsbuild.github.io/dev_tasks.html#jvm-tool-bootstrapping -target( - name = 'scala-js-cli', - dependencies=[ - 'contrib/scalajs/3rdparty/jvm/org/scala-js:cli' - ], -) - -target( - name = 'scala-js-compiler', - dependencies=[ - 'contrib/scalajs/3rdparty/jvm/org/scala-js:compiler', - 'contrib/scalajs/3rdparty/jvm/org/scala-js:library', - ], -) - -target( - name = 'scala-js-library', - dependencies = [ - 'contrib/scalajs/3rdparty/jvm/org/scala-js:library', - ], -) - - # TODO: Attempting to use these targets fails because BootstrapJvmTools.get_alternate_target_roots() # doesn't descend into dependent target directories and uses the same build_graph it starts with. # target( @@ -84,14 +61,3 @@ jar_library( url='https://raw.githubusercontent.com/toolchainlabs/binhost/master/java/javac/9+181-r4173-1/javac-9+181-r4173-1.jar'), ], ) - -# Runtime dependencies for the Avro Java generated code. -avro_rev = '1.8.2' - -jar_library( - name = 'avro-java-runtime', - jars = [ - jar(org='org.apache.avro', name='avro', rev=avro_rev), - jar(org='org.apache.avro', name='avro-ipc', rev=avro_rev), - ], -) diff --git a/contrib/BUILD b/contrib/BUILD index 1dd003d1c2a..b5fd4b34bfc 100644 --- a/contrib/BUILD +++ b/contrib/BUILD @@ -4,24 +4,16 @@ target( name = 'plugins', dependencies = [ - 'contrib/avro/src/python/pants/contrib/avro:plugin', 'contrib/awslambda/python/src/python/pants/contrib/awslambda/python:plugin', 'contrib/buildgen/src/python/pants/contrib/buildgen:plugin', 'contrib/buildrefactor/src/python/pants/contrib/buildrefactor:plugin', 'contrib/codeanalysis/src/python/pants/contrib/codeanalysis:plugin', 'contrib/confluence/src/python/pants/contrib/confluence:plugin', - 'contrib/cpp/src/python/pants/contrib/cpp:plugin', - 'contrib/errorprone/src/python/pants/contrib/errorprone:plugin', - 'contrib/findbugs/src/python/pants/contrib/findbugs:plugin', 'contrib/go/src/python/pants/contrib/go:plugin', - 'contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat:plugin', - 'contrib/jax_ws/src/python/pants/contrib/jax_ws:plugin', 'contrib/mypy/src/python/pants/contrib/mypy:plugin', 'contrib/node/src/python/pants/contrib/node:plugin', 'contrib/python/src/python/pants/contrib/python/checks:plugin', - 'contrib/scalajs/src/python/pants/contrib/scalajs:plugin', 'contrib/scrooge/src/python/pants/contrib/scrooge:plugin', - 'contrib/thrifty/src/python/pants/contrib/thrifty:plugin', ] ) diff --git a/contrib/avro/BUILD b/contrib/avro/BUILD deleted file mode 100644 index 634ec42bb7d..00000000000 --- a/contrib/avro/BUILD +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -files( - name='avro_tests_directory', - sources=['tests/avro/**/*'], -) diff --git a/contrib/avro/README.md b/contrib/avro/README.md deleted file mode 100644 index 98b4cf354d3..00000000000 --- a/contrib/avro/README.md +++ /dev/null @@ -1,6 +0,0 @@ -Avro code generation support -============================ - -This Pants plugin generates Java code from Avro schema (.avsc), protocol (.avpr), -and IDL (.avdl) files. Use the `java_avro_library` target with any of those -files as sources. diff --git a/contrib/avro/src/python/pants/__init__.py b/contrib/avro/src/python/pants/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/avro/src/python/pants/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/avro/src/python/pants/contrib/__init__.py b/contrib/avro/src/python/pants/contrib/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/avro/src/python/pants/contrib/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/avro/src/python/pants/contrib/avro/BUILD b/contrib/avro/src/python/pants/contrib/avro/BUILD deleted file mode 100644 index e65f54b0e53..00000000000 --- a/contrib/avro/src/python/pants/contrib/avro/BUILD +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -contrib_plugin( - name='plugin', - sources=['register.py', '__init__.py'], - dependencies=[ - ':target_types', - 'contrib/avro/src/python/pants/contrib/avro/targets', - 'contrib/avro/src/python/pants/contrib/avro/tasks', - 'src/python/pants/build_graph', - 'src/python/pants/goal:task_registrar', - ], - distribution_name='pantsbuild.pants.contrib.avro', - description='Avro Java code generation support for pants (deprecated)', - build_file_aliases=True, - register_goals=True, - tags = {"partially_type_checked"}, -) - -python_library( - name='target_types', - sources=['target_types.py'], - dependencies=[ - 'src/python/pants/backend/jvm:target_types', - 'src/python/pants/engine:target', - ], - tags = {"type_checked"}, -) diff --git a/contrib/avro/src/python/pants/contrib/avro/__init__.py b/contrib/avro/src/python/pants/contrib/avro/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/avro/src/python/pants/contrib/avro/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/avro/src/python/pants/contrib/avro/register.py b/contrib/avro/src/python/pants/contrib/avro/register.py deleted file mode 100644 index e59996604cc..00000000000 --- a/contrib/avro/src/python/pants/contrib/avro/register.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -"""Code generation from the Apache Avro format into Java targets (deprecated).""" - -from pants.base.deprecated import _deprecated_contrib_plugin -from pants.build_graph.build_file_aliases import BuildFileAliases -from pants.goal.task_registrar import TaskRegistrar as task - -from pants.contrib.avro.target_types import JavaAvroLibrary -from pants.contrib.avro.targets.java_avro_library import JavaAvroLibrary as JavaAvroLibraryV1 -from pants.contrib.avro.tasks.avro_gen import AvroJavaGenTask - - -def build_file_aliases(): - return BuildFileAliases(targets={JavaAvroLibraryV1.alias(): JavaAvroLibraryV1}) - - -_deprecated_contrib_plugin("pantsbuild.pants.contrib.avro") - - -def register_goals(): - task(name="avro-java", action=AvroJavaGenTask).install("gen") - - -def target_types(): - return [JavaAvroLibrary] diff --git a/contrib/avro/src/python/pants/contrib/avro/target_types.py b/contrib/avro/src/python/pants/contrib/avro/target_types.py deleted file mode 100644 index b15f0588baa..00000000000 --- a/contrib/avro/src/python/pants/contrib/avro/target_types.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.backend.jvm.target_types import COMMON_JVM_FIELDS -from pants.engine.target import Sources, Target - - -class JavaAvroLibrary(Target): - """A Java library generated from Avro schema, protocol, or IDL files.""" - - alias = "java_avro_library" - core_fields = (*COMMON_JVM_FIELDS, Sources) - v1_only = True diff --git a/contrib/avro/src/python/pants/contrib/avro/targets/BUILD b/contrib/avro/src/python/pants/contrib/avro/targets/BUILD deleted file mode 100644 index 4fe2b4b4356..00000000000 --- a/contrib/avro/src/python/pants/contrib/avro/targets/BUILD +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_library( - dependencies = [ - 'src/python/pants/backend/jvm/targets:jvm', - 'src/python/pants/base:payload', - ], - tags = {"partially_type_checked"}, -) diff --git a/contrib/avro/src/python/pants/contrib/avro/targets/__init__.py b/contrib/avro/src/python/pants/contrib/avro/targets/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/avro/src/python/pants/contrib/avro/targets/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/avro/src/python/pants/contrib/avro/targets/java_avro_library.py b/contrib/avro/src/python/pants/contrib/avro/targets/java_avro_library.py deleted file mode 100644 index c63e73fdd76..00000000000 --- a/contrib/avro/src/python/pants/contrib/avro/targets/java_avro_library.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.backend.jvm.targets.jvm_target import JvmTarget -from pants.base.payload import Payload - - -class JavaAvroLibrary(JvmTarget): - """Defines a target that builds Java code from Avro schema, protocol, or IDL files.""" - - def __init__(self, payload=None, **kwargs): - payload = payload or Payload() - super().__init__(payload=payload, **kwargs) - - @classmethod - def alias(cls): - return "java_avro_library" diff --git a/contrib/avro/src/python/pants/contrib/avro/tasks/BUILD b/contrib/avro/src/python/pants/contrib/avro/tasks/BUILD deleted file mode 100644 index e1bc9f215b9..00000000000 --- a/contrib/avro/src/python/pants/contrib/avro/tasks/BUILD +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_library( - dependencies = [ - 'contrib/avro/src/python/pants/contrib/avro/targets', - 'src/python/pants/backend/jvm/targets:java', - 'src/python/pants/backend/jvm/tasks:nailgun_task', - 'src/python/pants/base:exceptions', - 'src/python/pants/build_graph', - 'src/python/pants/java/jar', - 'src/python/pants/option', - 'src/python/pants/task', - 'src/python/pants/util:memo', - ], - tags = {"partially_type_checked"}, -) diff --git a/contrib/avro/src/python/pants/contrib/avro/tasks/__init__.py b/contrib/avro/src/python/pants/contrib/avro/tasks/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/avro/src/python/pants/contrib/avro/tasks/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/avro/src/python/pants/contrib/avro/tasks/avro_gen.py b/contrib/avro/src/python/pants/contrib/avro/tasks/avro_gen.py deleted file mode 100644 index 3a3d0582646..00000000000 --- a/contrib/avro/src/python/pants/contrib/avro/tasks/avro_gen.py +++ /dev/null @@ -1,92 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -import os - -from pants.backend.jvm.targets.java_library import JavaLibrary -from pants.backend.jvm.tasks.nailgun_task import NailgunTask -from pants.base.exceptions import TaskError -from pants.java.jar.jar_dependency import JarDependency -from pants.task.simple_codegen_task import SimpleCodegenTask -from pants.util.memo import memoized_property - -from pants.contrib.avro.targets.java_avro_library import JavaAvroLibrary - -AVRO_REV = "1.8.2" - - -class AvroJavaGenTask(SimpleCodegenTask, NailgunTask): - """Compile Avro schema, protocol, and IDL files to Java code.""" - - sources_globs = ("**/*",) - - @classmethod - def register_options(cls, register): - super().register_options(register) - # pylint: disable=no-member - cls.register_jvm_tool( - register, - "avro-tools", - classpath=[JarDependency(org="org.apache.avro", name="avro-tools", rev=AVRO_REV)], - ) - register( - "--runtime-deps", - advanced=True, - type=list, - fingerprint=True, - default=["//:avro-java-runtime"], - help="A list of address specs pointing to dependencies of Avro generated code.", - ) - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - - @memoized_property - def avro_runtime_deps(self): - return self.resolve_deps(self.get_options().runtime_deps) - - def synthetic_target_type(self, target): - return JavaLibrary - - def synthetic_target_extra_dependencies(self, target, target_workdir): - return self.avro_runtime_deps - - def synthetic_target_extra_exports(self, target, target_workdir): - return self.avro_runtime_deps - - def is_gentarget(self, target): - return isinstance(target, JavaAvroLibrary) - - def _avro(self, args): - result = self.runjava( - classpath=self.tool_classpath("avro-tools"), main="org.apache.avro.tool.Main", args=args - ) - if result != 0: - raise TaskError("avro-tools failed with exit status {}".format(result)) - - def _compile_schema(self, source, workdir): - self._avro(["compile", "schema", source, workdir]) - - def _compile_protocol(self, source, workdir): - self._avro(["compile", "protocol", source, workdir]) - - def _compile_idl(self, source, workdir): - idl_filename = os.path.basename(source) - idl_base_filename, _ = os.path.splitext(idl_filename) - protocol_file = os.path.join(workdir, idl_base_filename + ".avpr") - self._avro(["idl", source, protocol_file]) - self._compile_protocol(protocol_file, workdir) - - def execute_codegen(self, target, target_workdir): - for source in target.sources_relative_to_buildroot(): - if source.endswith(".avsc"): - self._compile_schema(source, target_workdir) - elif source.endswith(".avpr"): - self._compile_protocol(source, target_workdir) - elif source.endswith(".avdl"): - self._compile_idl(source, target_workdir) - else: - raise TaskError( - "File {} is not supported. The Avro task only supports " - "Avro schema (.avsc), protocol (.avpr), and IDL (.avdl) files.".format(source) - ) diff --git a/contrib/avro/tests/avro/org/pantsbuild/contrib/avro/BUILD b/contrib/avro/tests/avro/org/pantsbuild/contrib/avro/BUILD deleted file mode 100644 index 475b20c3ec1..00000000000 --- a/contrib/avro/tests/avro/org/pantsbuild/contrib/avro/BUILD +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -java_avro_library( - name='simple', - sources=['simple.avdl'], -) - -java_avro_library( - name='user', - sources=['user.avsc'], -) diff --git a/contrib/avro/tests/avro/org/pantsbuild/contrib/avro/simple.avdl b/contrib/avro/tests/avro/org/pantsbuild/contrib/avro/simple.avdl deleted file mode 100644 index e806070e911..00000000000 --- a/contrib/avro/tests/avro/org/pantsbuild/contrib/avro/simple.avdl +++ /dev/null @@ -1,41 +0,0 @@ -/** - * From https://avro.apache.org/docs/current/idl.html - * An example protocol in Avro IDL - */ -@namespace("org.pantsbuild.contrib.avro") -protocol Simple { - - @aliases(["org.foo.KindOf"]) - enum Kind { - FOO, - BAR, // the bar enum value - BAZ - } - - fixed MD5(16); - - record TestRecord { - @order("ignore") - string name; - - @order("descending") - Kind kind; - - MD5 hash; - - union { MD5, null} @aliases(["hash"]) nullableHash; - - array arrayOfLongs; - } - - error TestError { - string message; - } - - string hello(string greeting); - TestRecord echo(TestRecord `record`); - int add(int arg1, int arg2); - bytes echoBytes(bytes data); - void `error`() throws TestError; - void ping() oneway; -} \ No newline at end of file diff --git a/contrib/avro/tests/avro/org/pantsbuild/contrib/avro/user.avsc b/contrib/avro/tests/avro/org/pantsbuild/contrib/avro/user.avsc deleted file mode 100644 index 284fb8ada1e..00000000000 --- a/contrib/avro/tests/avro/org/pantsbuild/contrib/avro/user.avsc +++ /dev/null @@ -1,9 +0,0 @@ -{"namespace": "org.pantsbuild.contrib.avro", - "type": "record", - "name": "User", - "fields": [ - {"name": "name", "type": "string"}, - {"name": "favorite_number", "type": ["int", "null"]}, - {"name": "favorite_color", "type": ["string", "null"]} - ] -} diff --git a/contrib/avro/tests/java/org/pantsbuild/contrib/avro/AvroJavaGenTest.java b/contrib/avro/tests/java/org/pantsbuild/contrib/avro/AvroJavaGenTest.java deleted file mode 100644 index 1b87ec4c81b..00000000000 --- a/contrib/avro/tests/java/org/pantsbuild/contrib/avro/AvroJavaGenTest.java +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -// Licensed under the Apache License, Version 2.0 (see LICENSE). - -package org.pantsbuild.contrib.avro; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; -import org.pantsbuild.contrib.avro.User; -import org.pantsbuild.contrib.avro.MD5; -import org.pantsbuild.contrib.avro.TestRecord; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -public class AvroJavaGenTest { - @Test - public void testSchemaGen() { - User user = User.newBuilder() - .setName("Test User") - .setFavoriteColor("blue") - .setFavoriteNumber(10) - .build(); - - assertEquals("Test User", user.getName()); - assertEquals("blue", user.getFavoriteColor()); - assertEquals(10, user.getFavoriteNumber().intValue()); - } - - @Test - public void testIdlGen() { - List arrayOfLongs = new ArrayList(); - arrayOfLongs.add(1L); - arrayOfLongs.add(2L); - arrayOfLongs.add(3L); - - TestRecord testRecord = TestRecord.newBuilder() - .setName("Name") - .setKind(Kind.BAR) - .setHash(new MD5(new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15})) - .setNullableHash(null) - .setArrayOfLongs(arrayOfLongs) - .build(); - - assertEquals("Name", testRecord.getName()); - assertEquals(Kind.BAR, testRecord.getKind()); - assertArrayEquals(new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, - testRecord.getHash().bytes()); - assertNull(testRecord.getNullableHash()); - assertEquals(arrayOfLongs, testRecord.getArrayOfLongs()); - } -} diff --git a/contrib/avro/tests/java/org/pantsbuild/contrib/avro/BUILD b/contrib/avro/tests/java/org/pantsbuild/contrib/avro/BUILD deleted file mode 100644 index 760159a72a7..00000000000 --- a/contrib/avro/tests/java/org/pantsbuild/contrib/avro/BUILD +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -junit_tests( - dependencies=[ - '3rdparty:junit', - 'contrib/avro/tests/avro/org/pantsbuild/contrib/avro:simple', - 'contrib/avro/tests/avro/org/pantsbuild/contrib/avro:user', - ], -) diff --git a/contrib/avro/tests/python/pants_test/__init__.py b/contrib/avro/tests/python/pants_test/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/avro/tests/python/pants_test/contrib/__init__.py b/contrib/avro/tests/python/pants_test/contrib/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/avro/tests/python/pants_test/contrib/avro/__init__.py b/contrib/avro/tests/python/pants_test/contrib/avro/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/avro/tests/python/pants_test/contrib/avro/tasks/BUILD b/contrib/avro/tests/python/pants_test/contrib/avro/tasks/BUILD deleted file mode 100644 index e349b1e5524..00000000000 --- a/contrib/avro/tests/python/pants_test/contrib/avro/tasks/BUILD +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_tests( - name='avro_java_gen', - sources=['test_avro_gen.py'], - dependencies=[ - 'contrib/avro/src/python/pants/contrib/avro/targets', - 'contrib/avro/src/python/pants/contrib/avro/tasks', - 'src/python/pants/build_graph:build_graph', - 'src/python/pants/testutil/jvm:nailgun_task_test_base', - ], - tags = {'partially_type_checked'}, -) - -python_tests( - name='avro_java_gen_integration', - sources=['test_avro_gen_integration.py'], - dependencies=[ - 'src/python/pants/testutil:int-test', - 'contrib/avro:avro_tests_directory', - ], - tags={'integration', 'partially_type_checked'}, -) diff --git a/contrib/avro/tests/python/pants_test/contrib/avro/tasks/__init__.py b/contrib/avro/tests/python/pants_test/contrib/avro/tasks/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/avro/tests/python/pants_test/contrib/avro/tasks/test_avro_gen.py b/contrib/avro/tests/python/pants_test/contrib/avro/tasks/test_avro_gen.py deleted file mode 100644 index d68824f5935..00000000000 --- a/contrib/avro/tests/python/pants_test/contrib/avro/tasks/test_avro_gen.py +++ /dev/null @@ -1,107 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from textwrap import dedent -from typing import List - -from pants.build_graph.build_file_aliases import BuildFileAliases -from pants.testutil.jvm.nailgun_task_test_base import NailgunTaskTestBase - -from pants.contrib.avro.targets.java_avro_library import JavaAvroLibrary -from pants.contrib.avro.tasks.avro_gen import AvroJavaGenTask - - -class MockAvroJavaGenTest(AvroJavaGenTask): - _test_cmd_log: List[List[str]] = [] # List of lists for commands run by the task under test. - - # Overide this method and record the command that would have been run. - def _avro(self, args): - self._test_cmd_log.append(args) - - def _test_reset(self): - self._test_cmd_log = [] - - -class AvroJavaGenTest(NailgunTaskTestBase): - @classmethod - def task_type(cls): - return MockAvroJavaGenTest - - @classmethod - def alias_groups(cls): - return ( - super() - .alias_groups() - .merge(BuildFileAliases(targets={"java_avro_library": JavaAvroLibrary})) - ) - - def _test_avro(self, target_spec): - target = self.target(target_spec) - context = self.context(target_roots=[target]) - task = self.prepare_execute(context) - task._test_reset() - task.execute() - return task - - def test_avro_java_gen(self): - # Disable lookup of avro-tools since not used for this unit test. - self.set_options(runtime_deps=[]) - - self.add_to_build_file( - "avro-build", - dedent( - """ - java_avro_library(name='avro-schema', - sources=['src/avro/schema.avsc'], - ) - java_avro_library(name='avro-protocol', - sources=['src/avro/protocol.avpl'], - ) - java_avro_library(name='avro-idl', - sources=['src/avro/record.avdl'], - ) - """ - ), - ) - - self.create_file( - relpath="avro-build/src/avro/schema.avsc", - contents=dedent( - """ - { - "namespace": "", - "type": "record", - "name": "Person", - "fields": [ - {"name": "name", "type": "string"}, - {"name": "age", "type": "int"} - ] - } - """ - ), - ) - - self.create_file( - relpath="avro-build/src/avro/record.avdl", - contents=dedent( - """ - protocol Test { - void test(); - } - """ - ), - ) - - task = self._test_avro("avro-build:avro-schema") - self.assertEqual(len(task._test_cmd_log), 1) - self.assertEqual( - task._test_cmd_log[0][:-1], ["compile", "schema", "avro-build/src/avro/schema.avsc"] - ) - - task = self._test_avro("avro-build:avro-idl") - self.assertEqual(len(task._test_cmd_log), 2) - self.assertEqual(task._test_cmd_log[0][:-1], ["idl", "avro-build/src/avro/record.avdl"]) - generated_protocol_json_file = task._test_cmd_log[0][-1] - self.assertEqual( - task._test_cmd_log[1][:-1], ["compile", "protocol", generated_protocol_json_file] - ) diff --git a/contrib/avro/tests/python/pants_test/contrib/avro/tasks/test_avro_gen_integration.py b/contrib/avro/tests/python/pants_test/contrib/avro/tasks/test_avro_gen_integration.py deleted file mode 100644 index 3a369d45f0c..00000000000 --- a/contrib/avro/tests/python/pants_test/contrib/avro/tasks/test_avro_gen_integration.py +++ /dev/null @@ -1,87 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -import os - -from pants.testutil.pants_run_integration_test import PantsRunIntegrationTest - - -class AvroJavaGenTest(PantsRunIntegrationTest): - @classmethod - def hermetic(cls): - return True - - def run_pants_with_workdir( - self, - command, - workdir, - config=None, - stdin_data=None, - extra_env=None, - build_root=None, - tee_output=False, - **kwargs - ): - full_config = { - "GLOBAL": { - "pythonpath": ["%(buildroot)s/contrib/avro/src/python"], - "backend_packages": [ - "pants.backend.codegen", - "pants.backend.jvm", - "pants.contrib.avro", - ], - } - } - if config: - for scope, scoped_cfgs in config.items(): - updated = full_config.get(scope, {}) - updated.update(scoped_cfgs) - full_config[scope] = updated - return super().run_pants_with_workdir( - command=command, - workdir=workdir, - config=full_config, - stdin_data=stdin_data, - extra_env=extra_env, - build_root=build_root, - tee_output=build_root, - **kwargs - ) - - @staticmethod - def avro_test_target(target_name): - return "contrib/avro/tests/avro/org/pantsbuild/contrib/avro:{}".format(target_name) - - @staticmethod - def get_gen_root(workdir, target_spec): - spec_as_dir_name = target_spec.replace("/", ".").replace(":", ".") - return os.path.join(workdir, "gen", "avro-java", "current", spec_as_dir_name, "current") - - def test_schema_gen(self): - target_spec = self.avro_test_target("user") - with self.pants_results(["gen", target_spec]) as pants_run: - self.assert_success(pants_run) - - output_root = self.get_gen_root(pants_run.workdir, target_spec) - actual_files = set( - os.listdir(os.path.join(output_root, "org", "pantsbuild", "contrib", "avro")) - ) - self.assertEqual({"User.java"}, actual_files) - - def test_idl_gen(self): - target_spec = self.avro_test_target("simple") - with self.pants_results(["gen", target_spec]) as pants_run: - self.assert_success(pants_run) - - output_root = self.get_gen_root(pants_run.workdir, target_spec) - expected_files = { - "Kind.java", - "MD5.java", - "Simple.java", - "TestError.java", - "TestRecord.java", - } - actual_files = set( - os.listdir(os.path.join(output_root, "org", "pantsbuild", "contrib", "avro")) - ) - self.assertEqual(expected_files, actual_files) diff --git a/contrib/cpp/BUILD b/contrib/cpp/BUILD deleted file mode 100644 index 59d9f3fcae9..00000000000 --- a/contrib/cpp/BUILD +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -files( - name='examples_directory', - sources=['examples/**/*'], -) diff --git a/contrib/cpp/README.md b/contrib/cpp/README.md deleted file mode 100644 index 13088af12cd..00000000000 --- a/contrib/cpp/README.md +++ /dev/null @@ -1,4 +0,0 @@ -Pants plugins to support C++ -============================ - -Compile and link static libraries and statically linked binaries from C++ code. diff --git a/contrib/cpp/examples/src/cpp/calcsqrt/BUILD b/contrib/cpp/examples/src/cpp/calcsqrt/BUILD deleted file mode 100644 index 06e40609ac5..00000000000 --- a/contrib/cpp/examples/src/cpp/calcsqrt/BUILD +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -cpp_binary( - sources=['main.cc'], - libraries=['m'], -) - diff --git a/contrib/cpp/examples/src/cpp/calcsqrt/main.cc b/contrib/cpp/examples/src/cpp/calcsqrt/main.cc deleted file mode 100644 index 8644828ff25..00000000000 --- a/contrib/cpp/examples/src/cpp/calcsqrt/main.cc +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -double CalcSqrt(double d) { - return sqrt(d); -} - -int main() { - double d = 100.0; - double s = CalcSqrt(d); - if (s < 10.0 - std::numeric_limits::epsilon() || - s > 10.0 + std::numeric_limits::epsilon()) { - return 1; - } - return 0; -} diff --git a/contrib/cpp/examples/src/cpp/example/BUILD b/contrib/cpp/examples/src/cpp/example/BUILD deleted file mode 100644 index ced521bb8a2..00000000000 --- a/contrib/cpp/examples/src/cpp/example/BUILD +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -cpp_binary( - name='hello_pants', - sources=['main.cc'], - dependencies=['contrib/cpp/examples/src/cpp/example/hello'], -) diff --git a/contrib/cpp/examples/src/cpp/example/hello/BUILD b/contrib/cpp/examples/src/cpp/example/hello/BUILD deleted file mode 100644 index 5eee9289260..00000000000 --- a/contrib/cpp/examples/src/cpp/example/hello/BUILD +++ /dev/null @@ -1,10 +0,0 @@ -# coding=utf-8 -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -cpp_library( - sources=[ - 'hello.cc', - 'hello.h', - ], -) diff --git a/contrib/cpp/examples/src/cpp/example/hello/hello.cc b/contrib/cpp/examples/src/cpp/example/hello/hello.cc deleted file mode 100644 index d122ad65476..00000000000 --- a/contrib/cpp/examples/src/cpp/example/hello/hello.cc +++ /dev/null @@ -1,17 +0,0 @@ -#include - -#include "hello.h" - -namespace example { -namespace hello { - -Hello::Hello() { - std::cout << "Hello, pants!\n"; -} - -Hello::~Hello() { - std::cout << "Goodbye, pants!\n"; -} - -} // namespace hello -} // namespace example diff --git a/contrib/cpp/examples/src/cpp/example/hello/hello.h b/contrib/cpp/examples/src/cpp/example/hello/hello.h deleted file mode 100644 index 84706327979..00000000000 --- a/contrib/cpp/examples/src/cpp/example/hello/hello.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -namespace example { -namespace hello { - -class Hello { - public: - Hello(); - - virtual ~Hello(); -}; - -} // namespace hello -} // namespace example diff --git a/contrib/cpp/examples/src/cpp/example/main.cc b/contrib/cpp/examples/src/cpp/example/main.cc deleted file mode 100644 index fee6187263d..00000000000 --- a/contrib/cpp/examples/src/cpp/example/main.cc +++ /dev/null @@ -1,6 +0,0 @@ -#include "example/hello/hello.h" - -int main() { - example::hello::Hello hello; - return 0; -} diff --git a/contrib/cpp/src/python/pants/__init__.py b/contrib/cpp/src/python/pants/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/cpp/src/python/pants/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/cpp/src/python/pants/contrib/__init__.py b/contrib/cpp/src/python/pants/contrib/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/cpp/src/python/pants/contrib/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/cpp/src/python/pants/contrib/cpp/BUILD b/contrib/cpp/src/python/pants/contrib/cpp/BUILD deleted file mode 100644 index 7989aea7f7d..00000000000 --- a/contrib/cpp/src/python/pants/contrib/cpp/BUILD +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -contrib_plugin( - name='plugin', - dependencies=[ - ':target_types', - 'contrib/cpp/src/python/pants/contrib/cpp/targets', - 'contrib/cpp/src/python/pants/contrib/cpp/tasks', - 'contrib/cpp/src/python/pants/contrib/cpp/toolchain', - 'src/python/pants/build_graph', - 'src/python/pants/goal:task_registrar', - ], - distribution_name='pantsbuild.pants.contrib.cpp', - description='C++ pants plugin (deprecated).', - build_file_aliases=True, - register_goals=True, - tags = {"partially_type_checked"}, -) - -python_library( - name='target_types', - sources=['target_types.py'], - dependencies=[ - 'src/python/pants/engine:target', - ], - tags = {"type_checked"}, -) diff --git a/contrib/cpp/src/python/pants/contrib/cpp/__init__.py b/contrib/cpp/src/python/pants/contrib/cpp/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/cpp/src/python/pants/contrib/cpp/register.py b/contrib/cpp/src/python/pants/contrib/cpp/register.py deleted file mode 100644 index cb795da7604..00000000000 --- a/contrib/cpp/src/python/pants/contrib/cpp/register.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -"""Support for C++ (deprecated).""" - -from pants.base.deprecated import _deprecated_contrib_plugin -from pants.build_graph.build_file_aliases import BuildFileAliases -from pants.goal.task_registrar import TaskRegistrar as task - -from pants.contrib.cpp.target_types import CppBinary, CppLibrary -from pants.contrib.cpp.targets.cpp_binary import CppBinary as CppBinaryV1 -from pants.contrib.cpp.targets.cpp_library import CppLibrary as CppLibraryV1 -from pants.contrib.cpp.tasks.cpp_binary_create import CppBinaryCreate -from pants.contrib.cpp.tasks.cpp_compile import CppCompile -from pants.contrib.cpp.tasks.cpp_library_create import CppLibraryCreate -from pants.contrib.cpp.tasks.cpp_run import CppRun - -_deprecated_contrib_plugin("pantsbuild.pants.contrib.cpp") - - -def build_file_aliases(): - return BuildFileAliases(targets={"cpp_library": CppLibraryV1, "cpp_binary": CppBinaryV1}) - - -def register_goals(): - task(name="cpp", action=CppCompile).install("compile") - task(name="cpplib", action=CppLibraryCreate).install("binary") - task(name="cpp", action=CppBinaryCreate).install("binary") - task(name="cpp", action=CppRun).install("run") - - -def target_types(): - return [CppBinary, CppLibrary] diff --git a/contrib/cpp/src/python/pants/contrib/cpp/target_types.py b/contrib/cpp/src/python/pants/contrib/cpp/target_types.py deleted file mode 100644 index 17d5db5fe70..00000000000 --- a/contrib/cpp/src/python/pants/contrib/cpp/target_types.py +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.engine.target import ( - COMMON_TARGET_FIELDS, - Dependencies, - Sources, - StringSequenceField, - Target, -) - -# ----------------------------------------------------------------------------------------------- -# `cpp_binary` target -# ----------------------------------------------------------------------------------------------- - - -class CppExternalLibraries(StringSequenceField): - """Libraries that this target depends on that are not pants targets. - - For example, 'm' or 'rt' that are expected to be installed on the local system. - """ - - alias = "libraries" - - -class CppBinary(Target): - """A C++ binary.""" - - alias = "cpp_binary" - core_fields = (*COMMON_TARGET_FIELDS, Dependencies, Sources, CppExternalLibraries) - v1_only = True - - -# ----------------------------------------------------------------------------------------------- -# `cpp_library` target -# ----------------------------------------------------------------------------------------------- - - -class CppLibrary(Target): - """A statically linked C++ library.""" - - alias = "cpp_library" - core_fields = (*COMMON_TARGET_FIELDS, Dependencies, Sources) - v1_only = True diff --git a/contrib/cpp/src/python/pants/contrib/cpp/targets/BUILD b/contrib/cpp/src/python/pants/contrib/cpp/targets/BUILD deleted file mode 100644 index e0e3f7de584..00000000000 --- a/contrib/cpp/src/python/pants/contrib/cpp/targets/BUILD +++ /dev/null @@ -1,18 +0,0 @@ -# coding=utf-8 -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_library( - sources=[ - 'cpp_binary.py', - 'cpp_library.py', - 'cpp_target.py', - ], - dependencies=[ - 'src/python/pants/base:build_environment', - 'src/python/pants/base:exceptions', - 'src/python/pants/base:payload_field', - 'src/python/pants/build_graph', - ], - tags = {"partially_type_checked"}, -) diff --git a/contrib/cpp/src/python/pants/contrib/cpp/targets/__init__.py b/contrib/cpp/src/python/pants/contrib/cpp/targets/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/cpp/src/python/pants/contrib/cpp/targets/cpp_binary.py b/contrib/cpp/src/python/pants/contrib/cpp/targets/cpp_binary.py deleted file mode 100644 index 1d2b11c58d8..00000000000 --- a/contrib/cpp/src/python/pants/contrib/cpp/targets/cpp_binary.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.base.payload import Payload -from pants.base.payload_field import PrimitiveField - -from pants.contrib.cpp.targets.cpp_target import CppTarget - - -class CppBinary(CppTarget): - """A C++ binary.""" - - def __init__(self, libraries=None, payload=None, **kwargs): - """ - :param libraries: Libraries that this target depends on that are not pants targets. - For example, 'm' or 'rt' that are expected to be installed on the local system. - :type libraries: List of libraries to link against. - """ - payload = payload or Payload() - payload.add_field("libraries", PrimitiveField(libraries)) - super().__init__(payload=payload, **kwargs) - - @property - def libraries(self): - return self.payload.get_field_value("libraries") diff --git a/contrib/cpp/src/python/pants/contrib/cpp/targets/cpp_library.py b/contrib/cpp/src/python/pants/contrib/cpp/targets/cpp_library.py deleted file mode 100644 index 6e13afeb68f..00000000000 --- a/contrib/cpp/src/python/pants/contrib/cpp/targets/cpp_library.py +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.contrib.cpp.targets.cpp_target import CppTarget - - -class CppLibrary(CppTarget): - """A statically linked C++ library.""" diff --git a/contrib/cpp/src/python/pants/contrib/cpp/targets/cpp_target.py b/contrib/cpp/src/python/pants/contrib/cpp/targets/cpp_target.py deleted file mode 100644 index 215ad29066e..00000000000 --- a/contrib/cpp/src/python/pants/contrib/cpp/targets/cpp_target.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.base.payload import Payload -from pants.build_graph.target import Target - - -class CppTarget(Target): - """A base class for all cpp targets.""" - - def __init__(self, address=None, payload=None, sources=None, **kwargs): - """ - :param sources: Source code files to build. Paths are relative to the BUILD file's directory. - :type sources: :class:`pants.source.wrapped_globs.FilesetWithSpec` - """ - payload = payload or Payload() - payload.add_field( - "sources", - self.create_sources_field( - sources=sources, sources_rel_path=address.spec_path, key_arg="sources" - ), - ) - super().__init__(address=address, payload=payload, **kwargs) diff --git a/contrib/cpp/src/python/pants/contrib/cpp/tasks/BUILD b/contrib/cpp/src/python/pants/contrib/cpp/tasks/BUILD deleted file mode 100644 index 06f43a48b69..00000000000 --- a/contrib/cpp/src/python/pants/contrib/cpp/tasks/BUILD +++ /dev/null @@ -1,22 +0,0 @@ -# coding=utf-8 -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_library( - sources=[ - 'cpp_compile.py', - 'cpp_binary_create.py', - 'cpp_library_create.py', - 'cpp_run.py', - 'cpp_task.py', - ], - dependencies=[ - 'contrib/cpp/src/python/pants/contrib/cpp/targets:targets', - 'contrib/cpp/src/python/pants/contrib/cpp/toolchain:toolchain', - 'src/python/pants/base:exceptions', - 'src/python/pants/base:workunit', - 'src/python/pants/task', - 'src/python/pants/util:dirutil', - ], - tags = {"partially_type_checked"}, -) diff --git a/contrib/cpp/src/python/pants/contrib/cpp/tasks/__init__.py b/contrib/cpp/src/python/pants/contrib/cpp/tasks/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_binary_create.py b/contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_binary_create.py deleted file mode 100644 index 973fa2c3774..00000000000 --- a/contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_binary_create.py +++ /dev/null @@ -1,92 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -import os - -from pants.base.workunit import WorkUnitLabel - -from pants.contrib.cpp.tasks.cpp_task import CppTask - - -class CppBinaryCreate(CppTask): - """Builds an executable file from C++ sources and libraries.""" - - @classmethod - def register_options(cls, register): - super().register_options(register) - register("--ld-options", help="Append these options to the link command line.") - - @classmethod - def product_types(cls): - return ["exe", "deployable_archives"] - - @classmethod - def prepare(cls, options, round_manager): - super().prepare(options, round_manager) - round_manager.require("lib") - round_manager.require("objs") - - @property - def cache_target_dirs(self): - return True - - def execute(self): - with self.context.new_workunit(name="cpp-binary", labels=[WorkUnitLabel.TASK]): - targets = self.context.targets(self.is_binary) - with self.invalidated(targets, invalidate_dependents=True) as invalidation_check: - binary_mapping = self.context.products.get("exe") - deployable_archives_mapping = self.context.products.get("deployable_archives") - for vt in invalidation_check.all_vts: - binary_path = os.path.join(vt.results_dir, vt.target.name) - if not vt.valid: - self._create_binary(vt.target, binary_path) - binary_mapping.add(vt.target, vt.results_dir).append(binary_path) - deployable_archives_mapping.add(vt.target, os.path.dirname(binary_path)).append( - os.path.basename(binary_path) - ) - - def _create_binary(self, target, binary_path): - objects = [] - for basedir, objs in self.context.products.get("objs").get(target).items(): - objects.extend([os.path.join(basedir, obj) for obj in objs]) - self._link_binary(target, binary_path, objects) - self.context.log.info(f"Built c++ binary: {binary_path}") - - def _libname(self, libpath): - """Converts a full library filepath to the library's name. - - Ex: /path/to/libhello.a --> hello - """ - # Cut off 'lib' at the beginning of filename, and '.a' at end. - return os.path.basename(libpath)[3:-2] - - def _link_binary(self, target, binary_path, objects): - cmd = [self.cpp_toolchain.compiler] - - library_dirs = [] - libraries = [] - - # TODO(dhamon): should this use self.context.products.get('lib').get(binary).items() - def add_library(target): - product_map = self.context.products.get("lib").get(target) - if product_map: - for dir, libs in product_map.items(): - library_dirs.append(dir) - libraries.extend((self._libname(l) for l in libs)) - - target.walk(add_library) - - if target.libraries: - libraries.extend(target.libraries) - - cmd.extend(objects) - cmd.extend((f"-L{L}" for L in library_dirs)) - cmd.extend((f"-l{l}" for l in libraries)) - cmd.extend(["-o" + binary_path]) - if self.get_options().ld_options is not None: - cmd.extend((f"-Wl,{o}" for o in self.get_options().ld_options.split(" "))) - - with self.context.new_workunit( - name="cpp-link", labels=[WorkUnitLabel.COMPILER] - ) as workunit: - self.run_command(cmd, workunit) diff --git a/contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_compile.py b/contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_compile.py deleted file mode 100644 index 1f806c90833..00000000000 --- a/contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_compile.py +++ /dev/null @@ -1,108 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -import os - -from pants.base.build_environment import get_buildroot -from pants.base.workunit import WorkUnitLabel -from pants.util.dirutil import safe_mkdir_for - -from pants.contrib.cpp.tasks.cpp_task import CppTask - - -class CppCompile(CppTask): - """Compile C++ sources into object files.""" - - @classmethod - def register_options(cls, register): - super().register_options(register) - register( - "--cc-options", - advanced=True, - type=list, - default=[], - fingerprint=True, - help="Append these options to the compiler command line.", - ) - register( - "--cc-extensions", - advanced=True, - type=list, - fingerprint=True, - default=[".cc", ".cxx", ".cpp"], - help=( - "The list of extensions to consider when determining if a file is a " - "C++ source file." - ), - ) - - @classmethod - def product_types(cls): - return ["objs"] - - @property - def cache_target_dirs(self): - return True - - def execute(self): - """Compile all sources in a given target to object files.""" - - def is_cc(source): - _, ext = os.path.splitext(source) - return ext in self.get_options().cc_extensions - - targets = self.context.targets(self.is_cpp) - - # Compile source files to objects. - with self.invalidated(targets, invalidate_dependents=True) as invalidation_check: - obj_mapping = self.context.products.get("objs") - for vt in invalidation_check.all_vts: - for source in vt.target.sources_relative_to_buildroot(): - if is_cc(source): - if not vt.valid: - with self.context.new_workunit( - name="cpp-compile", labels=[WorkUnitLabel.MULTITOOL] - ): - # TODO: Parallelise the compilation. - # TODO: Only recompile source files that have changed since the - # object file was last written. Also use the output from - # gcc -M to track dependencies on headers. - self._compile(vt.target, vt.results_dir, source) - objpath = self._objpath(vt.target, vt.results_dir, source) - obj_mapping.add(vt.target, vt.results_dir).append(objpath) - - def _objpath(self, target, results_dir, source): - abs_source_root = os.path.join(get_buildroot(), target.target_base) - abs_source = os.path.join(get_buildroot(), source) - rel_source = os.path.relpath(abs_source, abs_source_root) - root, _ = os.path.splitext(rel_source) - obj_name = root + ".o" - - return os.path.join(results_dir, obj_name) - - def _compile(self, target, results_dir, source): - """Compile given source to an object file.""" - obj = self._objpath(target, results_dir, source) - safe_mkdir_for(obj) - - abs_source = os.path.join(get_buildroot(), source) - - # TODO: include dir should include dependent work dir when headers are copied there. - include_dirs = [] - for dep in target.dependencies: - if self.is_library(dep): - include_dirs.extend([os.path.join(get_buildroot(), dep.target_base)]) - - cmd = [self.cpp_toolchain.compiler] - cmd.extend(["-c"]) - cmd.extend((f"-I{i}" for i in include_dirs)) - cmd.extend(["-o" + obj, abs_source]) - cmd.extend(self.get_options().cc_options) - - # TODO: submit_async_work with self.run_command, [(cmd)] as a Work object. - with self.context.new_workunit( - name="cpp-compile", labels=[WorkUnitLabel.COMPILER] - ) as workunit: - self.run_command(cmd, workunit) - - self.context.log.info(f"Built c++ object: {obj}") diff --git a/contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_library_create.py b/contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_library_create.py deleted file mode 100644 index 9194aa3e96d..00000000000 --- a/contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_library_create.py +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -import os - -from pants.base.workunit import WorkUnitLabel - -from pants.contrib.cpp.tasks.cpp_task import CppTask - - -class CppLibraryCreate(CppTask): - """Builds a static library from C++ sources.""" - - @classmethod - def product_types(cls): - return ["lib"] - - @classmethod - def prepare(cls, options, round_manager): - super().prepare(options, round_manager) - round_manager.require("objs") - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - - @property - def cache_target_dirs(self): - return True - - def execute(self): - with self.context.new_workunit(name="cpp-library", labels=[WorkUnitLabel.TASK]): - targets = self.context.targets(self.is_library) - with self.invalidated(targets, invalidate_dependents=True) as invalidation_check: - lib_mapping = self.context.products.get("lib") - for vt in invalidation_check.all_vts: - if not vt.valid: - self._create_library(vt.target, vt.results_dir) - lib_mapping.add(vt.target, vt.results_dir).append( - self._libpath(vt.target, vt.results_dir) - ) - - def _create_library(self, target, results_dir): - objects = [] - for basedir, objs in self.context.products.get("objs").get(target).items(): - objects = [os.path.join(basedir, obj) for obj in objs] - # TODO: copy public headers to work dir. - output = self._link_library(target, results_dir, objects) - self.context.log.info(f"Built c++ library: {output}") - return output - - def _libpath(self, target, results_dir): - return os.path.join(results_dir, "lib" + target.name + ".a") - - def _link_library(self, target, results_dir, objects): - output = self._libpath(target, results_dir) - - cmd = [self.cpp_toolchain.register_tool("ar")] - cmd.extend(["rcs"]) - cmd.extend([output]) - cmd.extend(objects) - - with self.context.new_workunit( - name="cpp-link", labels=[WorkUnitLabel.COMPILER] - ) as workunit: - self.run_command(cmd, workunit) - - return output diff --git a/contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_run.py b/contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_run.py deleted file mode 100644 index 834652827c5..00000000000 --- a/contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_run.py +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.base.workunit import WorkUnitLabel - -from pants.contrib.cpp.targets.cpp_binary import CppBinary -from pants.contrib.cpp.tasks.cpp_task import CppTask - - -class CppRun(CppTask): - """Runs a C++ binary.""" - - @classmethod - def supports_passthru_args(cls): - return True - - @classmethod - def prepare(cls, options, round_manager): - super().prepare(options, round_manager) - # Require that an executable has been built. - round_manager.require_data("exe") - - def execute(self): - binary_target = self.require_single_root_target() - if isinstance(binary_target, CppBinary): - with self.context.new_workunit(name="cpp-run", labels=[WorkUnitLabel.RUN]) as workunit: - cmd = [ - self.context.products.get_only("exe", binary_target), - *self.get_passthru_args(), - *self.get_options().args, - ] - self.run_command(cmd, workunit) diff --git a/contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_task.py b/contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_task.py deleted file mode 100644 index 3ed56c30d4b..00000000000 --- a/contrib/cpp/src/python/pants/contrib/cpp/tasks/cpp_task.py +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -import subprocess - -from pants.base.exceptions import TaskError -from pants.task.task import Task - -from pants.contrib.cpp.targets.cpp_binary import CppBinary -from pants.contrib.cpp.targets.cpp_library import CppLibrary -from pants.contrib.cpp.targets.cpp_target import CppTarget -from pants.contrib.cpp.toolchain.cpp_toolchain import CppToolchain - - -class CppTask(Task): - @staticmethod - def is_cpp(target): - return isinstance(target, CppTarget) - - @staticmethod - def is_library(target): - return isinstance(target, CppLibrary) - - @staticmethod - def is_binary(target): - return isinstance(target, CppBinary) - - @classmethod - def register_options(cls, register): - super().register_options(register) - register( - "--compiler", - advanced=True, - fingerprint=True, - help="Set a specific compiler to use (eg, g++-4.8, clang++)", - ) - - def execute(self): - raise NotImplementedError("execute must be implemented by subclasses of CppTask") - - def run_command(self, cmd, workunit): - try: - self.context.log.debug(f"Executing: {cmd}") - # TODO: capture stdout/stderr and redirect to log - subprocess.check_call( - cmd, stdout=workunit.output("stdout"), stderr=workunit.output("stderr") - ) - except subprocess.CalledProcessError as e: - raise TaskError(f"Execution failed: {e!r}") - - @property - def cpp_toolchain(self): - return CppToolchain(self.get_options().compiler) diff --git a/contrib/cpp/src/python/pants/contrib/cpp/toolchain/BUILD b/contrib/cpp/src/python/pants/contrib/cpp/toolchain/BUILD deleted file mode 100644 index 2a119cd4f70..00000000000 --- a/contrib/cpp/src/python/pants/contrib/cpp/toolchain/BUILD +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_library( - tags = {"partially_type_checked"}, -) diff --git a/contrib/cpp/src/python/pants/contrib/cpp/toolchain/__init__.py b/contrib/cpp/src/python/pants/contrib/cpp/toolchain/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/cpp/src/python/pants/contrib/cpp/toolchain/cpp_toolchain.py b/contrib/cpp/src/python/pants/contrib/cpp/toolchain/cpp_toolchain.py deleted file mode 100644 index 37577751c0a..00000000000 --- a/contrib/cpp/src/python/pants/contrib/cpp/toolchain/cpp_toolchain.py +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -import os - - -class CppToolchain: - """Represents the cpp toolchain on the local system.""" - - class Error(Exception): - """Indicates an invalid cpp toolchain.""" - - def __init__(self, compiler=None): - """Create a cpp toolchain and cache tools for quick retrieval.""" - self._validated_tools = {} - self._compiler = compiler - - @property - def compiler(self): - if "compiler" in self._validated_tools: - return self._validated_tools["compiler"] - - _compiler = self._compiler or os.environ.get("CXX") - if _compiler is None: - raise self.Error('Please set the CXX environment variable or the "compiler" option.') - return self.register_tool(name="compiler", tool=_compiler) - - def register_tool(self, tool, name=None): - """Check tool and see if it is installed in the local cpp toolchain. - - All cpp tasks should request their tools using this method. Tools are validated - and cached for quick lookup. - - :param string tool: Name or path of program tool, eg 'g++' - :param string name: Logical name of tool, eg 'compiler'. If not supplied defaults to basename - of `tool` - """ - name = name or os.path.basename(tool) - if name in self._validated_tools: - return self._validated_tools[name] - - def which(program): - def is_exe(fpath): - return os.path.isfile(fpath) and os.access(fpath, os.X_OK) - - fpath, fname = os.path.split(program) - if fpath: - if is_exe(program): - return program - else: - for path in os.environ["PATH"].split(os.pathsep): - path = path.strip('"') - exe_file = os.path.join(path, program) - if is_exe(exe_file): - return exe_file - - return None - - tool_path = which(tool) - if tool_path is None: - raise self.Error(f"Failed to locate {tool}. Please install.") - self._validated_tools[name] = tool_path - return tool_path diff --git a/contrib/cpp/tests/python/pants_test/__init__.py b/contrib/cpp/tests/python/pants_test/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/cpp/tests/python/pants_test/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/cpp/tests/python/pants_test/contrib/__init__.py b/contrib/cpp/tests/python/pants_test/contrib/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/cpp/tests/python/pants_test/contrib/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/cpp/tests/python/pants_test/contrib/cpp/BUILD b/contrib/cpp/tests/python/pants_test/contrib/cpp/BUILD deleted file mode 100644 index dafe60c4741..00000000000 --- a/contrib/cpp/tests/python/pants_test/contrib/cpp/BUILD +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_tests( - name='cpp_integration', - sources=[ - 'test_cpp_integration.py' - ], - dependencies=[ - 'contrib/cpp/src/python/pants/contrib/cpp/toolchain:toolchain', - 'src/python/pants/util:contextutil', - 'src/python/pants/testutil:int-test', - ], - tags={'integration', 'partially_type_checked'}, -) - -python_tests( - name='cpp_toolchain', - sources=['test_cpp_toolchain.py'], - dependencies=[ - 'contrib/cpp/src/python/pants/contrib/cpp/toolchain:toolchain', - 'contrib/cpp:examples_directory', - 'src/python/pants/util:contextutil', - 'src/python/pants/util:dirutil', - ], - tags = {"partially_type_checked"}, -) diff --git a/contrib/cpp/tests/python/pants_test/contrib/cpp/test_cpp_integration.py b/contrib/cpp/tests/python/pants_test/contrib/cpp/test_cpp_integration.py deleted file mode 100644 index 115b3fcbea0..00000000000 --- a/contrib/cpp/tests/python/pants_test/contrib/cpp/test_cpp_integration.py +++ /dev/null @@ -1,86 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from unittest import skipUnless - -from pants.testutil.pants_run_integration_test import PantsRunIntegrationTest - -from pants.contrib.cpp.toolchain.cpp_toolchain import CppToolchain - - -def have_compiler(): - try: - CppToolchain().compiler - return True - except CppToolchain.Error: - return False - - -class CppIntegrationTest(PantsRunIntegrationTest): - """Integration test for cpp which builds libraries and builds and runs binaries.""" - - TEST_SIMPLE_BINARY_TARGET = "contrib/cpp/examples/src/cpp/example:hello_pants" - TEST_BINARY_WITH_LIBRARY_TARGET = "contrib/cpp/examples/src/cpp/calcsqrt" - TEST_LIBRARY_TARGET = "contrib/cpp/examples/src/cpp/example/hello" - TEST_RUN_TARGET = TEST_SIMPLE_BINARY_TARGET - - skipUnlessHaveCompiler = skipUnless( - have_compiler(), reason="cpp integration tests require compiler" - ) - - @skipUnlessHaveCompiler - def test_cpp_library(self): - self._binary_test(self.TEST_LIBRARY_TARGET) - - @skipUnlessHaveCompiler - def test_cpp_library_compile(self): - self._compile_test(self.TEST_LIBRARY_TARGET) - - @skipUnlessHaveCompiler - def test_cpp_binary(self): - self._binary_test(self.TEST_SIMPLE_BINARY_TARGET) - - @skipUnlessHaveCompiler - def test_cpp_binary_compile(self): - self._compile_test(self.TEST_SIMPLE_BINARY_TARGET) - - @skipUnlessHaveCompiler - def test_cpp_binary_with_library(self): - self._binary_test(self.TEST_BINARY_WITH_LIBRARY_TARGET) - - @skipUnlessHaveCompiler - def test_cpp_binary_with_library_compile(self): - self._compile_test(self.TEST_BINARY_WITH_LIBRARY_TARGET) - - @skipUnlessHaveCompiler - def test_cpp_run(self): - pants_run = self.run_pants(["run", self.TEST_RUN_TARGET]) - self.assert_success(pants_run) - self.assertIn("[cpp-run]\nHello, pants!\nGoodbye, pants!\n", pants_run.stdout_data) - - def _run_with_cache(self, task, target): - with self.temporary_cachedir() as cache: - args = [ - "clean-all", - task, - f"--cache-write-to=['{cache}']", - f"--cache-read-from=['{cache}']", - target, - "-ldebug", - ] - - pants_run = self.run_pants(args) - self.assert_success(pants_run) - self.assertIn("No cached artifacts", pants_run.stdout_data) - self.assertIn("Caching artifacts", pants_run.stdout_data) - - pants_run = self.run_pants(args) - self.assert_success(pants_run) - self.assertIn("Using cached artifacts", pants_run.stdout_data) - self.assertNotIn("No cached artifacts", pants_run.stdout_data) - - def _binary_test(self, target): - self._run_with_cache("binary", target) - - def _compile_test(self, target): - self._run_with_cache("compile", target) diff --git a/contrib/cpp/tests/python/pants_test/contrib/cpp/test_cpp_toolchain.py b/contrib/cpp/tests/python/pants_test/contrib/cpp/test_cpp_toolchain.py deleted file mode 100644 index b412c82bd7e..00000000000 --- a/contrib/cpp/tests/python/pants_test/contrib/cpp/test_cpp_toolchain.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -import os -import unittest -from contextlib import contextmanager - -from pants.util.contextutil import environment_as, temporary_dir -from pants.util.dirutil import chmod_plus_x, touch - -from pants.contrib.cpp.toolchain.cpp_toolchain import CppToolchain - - -class CppToolchainTest(unittest.TestCase): - @contextmanager - def tool(self, name): - with temporary_dir() as tool_root: - tool_path = os.path.join(tool_root, name) - touch(tool_path) - chmod_plus_x(tool_path) - new_path = os.pathsep.join([tool_root] + os.environ.get("PATH", "").split(os.pathsep)) - with environment_as(PATH=new_path): - yield tool_path - - def test_default_compiler_from_environ(self): - with self.tool("g++") as tool_path: - with environment_as(CXX="g++"): - self.assertEqual(CppToolchain().compiler, tool_path) - self.assertEqual( - CppToolchain().compiler, - CppToolchain().register_tool(name="compiler", tool=tool_path), - ) - - def test_invalid_compiler(self): - cpp_toolchain = CppToolchain(compiler="not-a-command") - with self.assertRaises(CppToolchain.Error): - cpp_toolchain.compiler - - def test_tool_registration(self): - with self.tool("good-tool") as tool_path: - self.assertEqual(tool_path, CppToolchain().register_tool(name="foo", tool="good-tool")) - - def test_invalid_tool_registration(self): - with self.assertRaises(CppToolchain.Error): - CppToolchain().register_tool("not-a-command") diff --git a/contrib/errorprone/BUILD b/contrib/errorprone/BUILD deleted file mode 100644 index 1192fcfd607..00000000000 --- a/contrib/errorprone/BUILD +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -files( - name='java_tests_directory', - sources=['tests/java/**/*'], -) diff --git a/contrib/errorprone/README.md b/contrib/errorprone/README.md deleted file mode 100644 index 2fea3a0dab1..00000000000 --- a/contrib/errorprone/README.md +++ /dev/null @@ -1,71 +0,0 @@ -# Pants plugin for Error Prone - -The Error Prone plugin runs static analysis on Java source files and looks for various -[bug patterns](http://errorprone.info/bugpatterns) not reported by the standard javac compiler. - -A full description of Error Prone can be found on the [Error Prone web page](http://errorprone.info/). - -One notable difference between this plugin and other Error Prone integrations is this plugin does not replace the javac executable used for compilation. Instead, it runs the Error Prone javac as a separate task after regular javac compilation is run. This is obviously slower than running the compiler once but it avoids a trickier integration with the Pants incremental compilation tool [Zinc](https://github.com/sbt/zinc). - - -## Installation - -Error Prone support is provided by a plugin distributed to [pypi] -(https://pypi.org/pypi/pantsbuild.pants.contrib.errorprone). -Assuming you have already [installed pants](http://www.pantsbuild.org/install.html), you'll need to -add the Error Prone plugin in your `pants.toml`, like so: -```toml -[GLOBAL] -pants_version = "1.26.0" - -plugins = [ - 'pantsbuild.pants.contrib.errorprone==%(pants_version)s', -] -``` - -The version of Error Prone used by the plugin requires Java 8 to run. If you want to run Error Prone with Java 7 you will need to use version 2.0.5 or earlier. Using Java 7 may require changes to the bootclasspath to override certain classes from `rt.jar`. See [this github issue](https://github.com/google/error-prone/issues/287) for more details. - -You can override the version of Error Prone by adding the following to the `BUILD.tools` file -```python -# Override the default version of Error Prone shipped with Pants -jar_library(name = 'errorprone', - jars = [ - jar(org = 'com.google.errorprone', name = 'error_prone_core', rev = '2.0.5'), - ], -) -``` - -## Running - -When you run `./pants compile` Error Prone is executed after the compile step and will run on any targets that contain java files. - -``` -./pants compile -... - 00:07:42 00:00 [compile] - 00:07:42 00:00 [zinc] - 00:07:42 00:00 [jvm-dep-check] - 00:07:42 00:00 [checkstyle] - 00:07:42 00:00 [errorprone] - Invalidated 7 targets. - 00:07:42 00:00 [errorprone] -... -``` - -## Options - -You can exclude targets with `--compile-errorprone-exclude-patterns` and globally suppress specific Error Prone checks with `--compile-errorprone-command-line-options`. - -Here are example `pants.toml` settings that exclude several test targets and disable the `DefaultCharset` bug pattern. - -```toml -[compile.errorprone] -command_line_options = [ - # See http://errorprone.info/bugpatterns for all patterns - '-Xep:DefaultCharset:OFF', -] -exclude_patterns = [ - 'tests/java/org/pantsbuild/tools/junit/.*', - 'testprojects/src/java/org/pantsbuild/testproject/annotation/main:main', -] -``` diff --git a/contrib/errorprone/src/python/pants/__init__.py b/contrib/errorprone/src/python/pants/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/errorprone/src/python/pants/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/errorprone/src/python/pants/contrib/__init__.py b/contrib/errorprone/src/python/pants/contrib/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/errorprone/src/python/pants/contrib/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/errorprone/src/python/pants/contrib/errorprone/BUILD b/contrib/errorprone/src/python/pants/contrib/errorprone/BUILD deleted file mode 100644 index 3512a4d3971..00000000000 --- a/contrib/errorprone/src/python/pants/contrib/errorprone/BUILD +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -contrib_plugin( - name='plugin', - dependencies=[ - 'contrib/errorprone/src/python/pants/contrib/errorprone/tasks', - 'src/python/pants/build_graph', - 'src/python/pants/goal:task_registrar', - ], - distribution_name='pantsbuild.pants.contrib.errorprone', - description='Error Prone pants plugin (deprecated)', - register_goals=True, - tags = {"partially_type_checked"}, -) diff --git a/contrib/errorprone/src/python/pants/contrib/errorprone/__init__.py b/contrib/errorprone/src/python/pants/contrib/errorprone/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/errorprone/src/python/pants/contrib/errorprone/register.py b/contrib/errorprone/src/python/pants/contrib/errorprone/register.py deleted file mode 100644 index 2f8d6f1ce8d..00000000000 --- a/contrib/errorprone/src/python/pants/contrib/errorprone/register.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -"""Linter for Java (deprecated). - -See https://errorprone.info. -""" - -from pants.base.deprecated import _deprecated_contrib_plugin -from pants.goal.task_registrar import TaskRegistrar as task - -from pants.contrib.errorprone.tasks.errorprone import ErrorProne - -_deprecated_contrib_plugin("pantsbuild.pants.contrib.errorprone") - - -def register_goals(): - task(name="errorprone", action=ErrorProne).install("compile") diff --git a/contrib/errorprone/src/python/pants/contrib/errorprone/tasks/BUILD b/contrib/errorprone/src/python/pants/contrib/errorprone/tasks/BUILD deleted file mode 100644 index 980481be9e5..00000000000 --- a/contrib/errorprone/src/python/pants/contrib/errorprone/tasks/BUILD +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_library( - dependencies=[ - 'src/python/pants/backend/jvm/subsystems:shader', - 'src/python/pants/backend/jvm/targets:java', - 'src/python/pants/backend/jvm/tasks:nailgun_task', - 'src/python/pants/java/jar', - 'src/python/pants/base:exceptions', - 'src/python/pants/base:workunit', - 'src/python/pants/util:dirutil', - ], - tags = {"partially_type_checked"}, -) diff --git a/contrib/errorprone/src/python/pants/contrib/errorprone/tasks/__init__.py b/contrib/errorprone/src/python/pants/contrib/errorprone/tasks/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/errorprone/src/python/pants/contrib/errorprone/tasks/errorprone.py b/contrib/errorprone/src/python/pants/contrib/errorprone/tasks/errorprone.py deleted file mode 100644 index 67f5658ea5e..00000000000 --- a/contrib/errorprone/src/python/pants/contrib/errorprone/tasks/errorprone.py +++ /dev/null @@ -1,227 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -import os -import re - -from pants.backend.jvm import argfile -from pants.backend.jvm.subsystems.shader import Shader -from pants.backend.jvm.tasks.nailgun_task import NailgunTask -from pants.base.exceptions import TaskError -from pants.base.revision import Revision -from pants.base.workunit import WorkUnitLabel -from pants.java.jar.jar_dependency import JarDependency -from pants.util.dirutil import safe_mkdir -from pants.util.memo import memoized_property -from pants.util.strutil import safe_shlex_split - - -class ErrorProne(NailgunTask): - """Check Java code for Error Prone violations. - - See http://errorprone.info/ for more details. - """ - - _ERRORPRONE_MAIN = "com.google.errorprone.ErrorProneCompiler" - _JAVA_SOURCE_EXTENSION = ".java" - - @classmethod - def register_options(cls, register): - super().register_options(register) - - register("--skip", type=bool, help="Skip Error Prone.") - register( - "--transitive", - default=False, - type=bool, - help="Run Error Prone against transitive dependencies of targets " - "specified on the command line.", - ) - register( - "--command-line-options", - type=list, - default=[], - fingerprint=True, - help="Command line options passed to Error Prone", - ) - register( - "--exclude-patterns", - type=list, - default=[], - fingerprint=True, - help="Patterns for targets to be excluded from analysis.", - ) - - cls.register_jvm_tool( - register, - "errorprone", - classpath=[ - JarDependency(org="com.google.errorprone", name="error_prone_core", rev="2.3.1"), - ], - main=cls._ERRORPRONE_MAIN, - custom_rules=[Shader.exclude_package("com.google.errorprone", recursive=True)], - ) - - # The javac version should be kept in sync with the version used by errorprone above. - cls.register_jvm_tool( - register, - "errorprone-javac", - classpath=[ - JarDependency(org="com.google.errorprone", name="javac", rev="9+181-r4173-1"), - ], - ) - - @classmethod - def prepare(cls, options, round_manager): - super().prepare(options, round_manager) - round_manager.require_data("runtime_classpath") - - @memoized_property - def _exclude_patterns(self): - return [re.compile(x) for x in set(self.get_options().exclude_patterns or [])] - - def _is_errorprone_target(self, target): - if not target.has_sources(self._JAVA_SOURCE_EXTENSION): - self.context.log.debug( - "Skipping [{}] because it has no {} sources".format( - target.address.spec, self._JAVA_SOURCE_EXTENSION - ) - ) - return False - if target.is_synthetic: - self.context.log.debug( - "Skipping [{}] because it is a synthetic target".format(target.address.spec) - ) - return False - for pattern in self._exclude_patterns: - if pattern.search(target.address.spec): - self.context.log.debug( - "Skipping [{}] because it matches exclude pattern '{}'".format( - target.address.spec, pattern.pattern - ) - ) - return False - return True - - @property - def cache_target_dirs(self): - return True - - def execute(self): - if self.get_options().skip: - return - - if self.get_options().transitive: - targets = self.context.targets(self._is_errorprone_target) - else: - targets = [t for t in self.context.target_roots if self._is_errorprone_target(t)] - - targets = list(set(targets)) - - target_count = 0 - errorprone_failed = False - with self.invalidated(targets, invalidate_dependents=True) as invalidation_check: - total_targets = len(invalidation_check.invalid_vts) - for vt in invalidation_check.invalid_vts: - target_count += 1 - self.context.log.info( - "[{}/{}] {}".format( - str(target_count).rjust(len(str(total_targets))), - total_targets, - vt.target.address.spec, - ) - ) - - result = self.errorprone(vt.target) - if result != 0: - errorprone_failed = True - if self.get_options().fail_fast: - break - else: - vt.update() - - if errorprone_failed: - raise TaskError("ErrorProne checks failed") - - def calculate_sources(self, target): - return { - source - for source in target.sources_relative_to_buildroot() - if source.endswith(self._JAVA_SOURCE_EXTENSION) - } - - def errorprone(self, target): - runtime_classpaths = self.context.products.get_data("runtime_classpath") - runtime_classpath = [ - jar for conf, jar in runtime_classpaths.get_for_targets(target.closure(bfs=True)) - ] - - output_dir = os.path.join(self.workdir, target.id) - safe_mkdir(output_dir) - runtime_classpath.append(output_dir) - - # Try to run errorprone with the same java version as the target - # The minimum JDK for errorprone is JDK 1.8 - min_jdk_version = max(target.platform.target_level, Revision.lenient("1.8")) - if min_jdk_version.components[0] == 1: - max_jdk_version = Revision( - min_jdk_version.components[0], min_jdk_version.components[1], "9999" - ) - else: - max_jdk_version = Revision(min_jdk_version.components[0], "9999") - self.set_distribution( - minimum_version=min_jdk_version, maximum_version=max_jdk_version, jdk=True - ) - - jvm_options = self.get_options().jvm_options[:] - if self.dist.version < Revision.lenient("9"): - # For Java 8 we need to add the errorprone javac jar to the bootclasspath to - # avoid the "java.lang.NoSuchFieldError: ANNOTATION_PROCESSOR_MODULE_PATH" error - # See https://github.com/google/error-prone/issues/653 for more information - jvm_options.extend( - ["-Xbootclasspath/p:{}".format(self.tool_classpath("errorprone-javac")[0])] - ) - - args = [ - "-d", - output_dir, - ] - - # Errorprone does not recognize source or target 10 yet - if target.platform.source_level < Revision.lenient("10"): - args.extend(["-source", str(target.platform.source_level)]) - - if target.platform.target_level < Revision.lenient("10"): - args.extend(["-target", str(target.platform.target_level)]) - - errorprone_classpath_file = os.path.join( - self.workdir, "{}.classpath".format(os.path.basename(output_dir)) - ) - with open(errorprone_classpath_file, "w") as f: - f.write("-classpath ") - f.write(":".join(runtime_classpath)) - args.append("@{}".format(errorprone_classpath_file)) - - for opt in self.get_options().command_line_options: - args.extend(safe_shlex_split(opt)) - - with argfile.safe_args( - self.calculate_sources(target), self.get_options() - ) as batched_sources: - args.extend(batched_sources) - result = self.runjava( - classpath=self.tool_classpath("errorprone"), - main=self._ERRORPRONE_MAIN, - jvm_options=jvm_options, - args=args, - workunit_name="errorprone", - workunit_labels=[WorkUnitLabel.LINT], - ) - - self.context.log.debug( - "java {main} ... exited with result ({result})".format( - main=self._ERRORPRONE_MAIN, result=result - ) - ) - - return result diff --git a/contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/ArrayToStringError.java b/contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/ArrayToStringError.java deleted file mode 100644 index 94a22232f65..00000000000 --- a/contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/ArrayToStringError.java +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -// Licensed under the Apache License, Version 2.0 (see LICENSE). - -package org.pantsbuild.contrib.errorprone; - -public class ArrayToStringError { - public static void main(String[] args) { - int[] a = {1, 2, 3}; - if (a.toString().isEmpty()) { - System.out.println("int array string is empty"); - } - } -} diff --git a/contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/BUILD b/contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/BUILD deleted file mode 100644 index e9c8539171d..00000000000 --- a/contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/BUILD +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -java_library( - name='none', - sources=['NoWarnings.java'] -) - -java_library( - name='empty', - sources=['Empty.java'] -) - -java_library( - name='warning', - sources=['ReferenceEqualityWarning.java'] -) - -java_library( - name='error', - sources=['ArrayToStringError.java'] -) diff --git a/contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/Empty.java b/contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/Empty.java deleted file mode 100644 index 4def356de4b..00000000000 --- a/contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/Empty.java +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -// Licensed under the Apache License, Version 2.0 (see LICENSE). - -package org.pantsbuild.contrib.errorprone; - -// We should not throw an error when the source file is empty diff --git a/contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/NoWarnings.java b/contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/NoWarnings.java deleted file mode 100644 index dfd19ad1773..00000000000 --- a/contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/NoWarnings.java +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -// Licensed under the Apache License, Version 2.0 (see LICENSE). - -package org.pantsbuild.contrib.errorprone; - -public class NoWarnings { - public static void main(String[] args) { - System.out.println("No Error Prone warnings"); - } -} diff --git a/contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/ReferenceEqualityWarning.java b/contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/ReferenceEqualityWarning.java deleted file mode 100644 index ed1aa93f5ca..00000000000 --- a/contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone/ReferenceEqualityWarning.java +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -// Licensed under the Apache License, Version 2.0 (see LICENSE). - -package org.pantsbuild.contrib.errorprone; - -public class ReferenceEqualityWarning { - public static void main(String[] args) { - if (args[0] == "one") { - System.out.println("You should use equals() instead"); - } - } -} diff --git a/contrib/errorprone/tests/python/pants_test/contrib/__init__.py b/contrib/errorprone/tests/python/pants_test/contrib/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/errorprone/tests/python/pants_test/contrib/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/errorprone/tests/python/pants_test/contrib/errorprone/__init__.py b/contrib/errorprone/tests/python/pants_test/contrib/errorprone/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/errorprone/tests/python/pants_test/contrib/errorprone/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/errorprone/tests/python/pants_test/contrib/errorprone/tasks/BUILD b/contrib/errorprone/tests/python/pants_test/contrib/errorprone/tasks/BUILD deleted file mode 100644 index b1a54d16b11..00000000000 --- a/contrib/errorprone/tests/python/pants_test/contrib/errorprone/tasks/BUILD +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_tests( - sources=['test_errorprone.py'], - dependencies=[ - 'contrib/errorprone/src/python/pants/contrib/errorprone/tasks', - 'src/python/pants/testutil/jvm:nailgun_task_test_base', - 'src/python/pants/testutil/option', - 'src/python/pants/testutil:test_base', - ], - tags = {'partially_type_checked'}, -) - -python_tests( - name='integration', - sources=['test_errorprone_integration.py'], - dependencies=[ - 'src/python/pants/testutil:int-test', - 'contrib/errorprone:java_tests_directory', - ], - tags={'integration', 'partially_type_checked'}, - timeout=420, -) diff --git a/contrib/errorprone/tests/python/pants_test/contrib/errorprone/tasks/__init__.py b/contrib/errorprone/tests/python/pants_test/contrib/errorprone/tasks/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/errorprone/tests/python/pants_test/contrib/errorprone/tasks/test_errorprone.py b/contrib/errorprone/tests/python/pants_test/contrib/errorprone/tasks/test_errorprone.py deleted file mode 100644 index dc8e47ec060..00000000000 --- a/contrib/errorprone/tests/python/pants_test/contrib/errorprone/tasks/test_errorprone.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.testutil.jvm.nailgun_task_test_base import NailgunTaskTestBase - -from pants.contrib.errorprone.tasks.errorprone import ErrorProne - - -class ErrorProneTest(NailgunTaskTestBase): - @classmethod - def task_type(cls): - return ErrorProne - - def test_no_sources(self): - task = self.prepare_execute(self.context()) - self.assertEqual(None, task.execute()) diff --git a/contrib/errorprone/tests/python/pants_test/contrib/errorprone/tasks/test_errorprone_integration.py b/contrib/errorprone/tests/python/pants_test/contrib/errorprone/tasks/test_errorprone_integration.py deleted file mode 100644 index 631085a2044..00000000000 --- a/contrib/errorprone/tests/python/pants_test/contrib/errorprone/tasks/test_errorprone_integration.py +++ /dev/null @@ -1,133 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.testutil.pants_run_integration_test import PantsRunIntegrationTest - - -class ErrorProneTest(PantsRunIntegrationTest): - @classmethod - def hermetic(cls): - return True - - def run_pants(self, command, config=None, stdin_data=None, extra_env=None, **kwargs): - full_config = { - "GLOBAL": { - "pythonpath": ["%(buildroot)s/contrib/errorprone/src/python"], - "backend_packages": [ - "pants.backend.codegen", - "pants.backend.jvm", - "pants.contrib.errorprone", - ], - }, - "jvm-platform": { - "default_platform": "java8", - "platforms": {"java8": {"source": "8", "target": "8", "args": []}}, - }, - } - if config: - for scope, scoped_cfgs in config.items(): - updated = full_config.get(scope, {}) - updated.update(scoped_cfgs) - full_config[scope] = updated - return super().run_pants(command, full_config, stdin_data, extra_env, **kwargs) - - def test_no_warnings(self): - cmd = ["compile", "contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone:none"] - pants_run = self.run_pants(cmd) - self.assert_success(pants_run) - self.assertNotIn("Exception caught:", pants_run.stderr_data) - self.assertNotIn("warning:", pants_run.stdout_data) - self.assertNotIn("error:", pants_run.stdout_data) - - def test_empty_source_file(self): - cmd = ["compile", "contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone:empty"] - pants_run = self.run_pants(cmd) - self.assert_success(pants_run) - self.assertNotIn("Exception caught:", pants_run.stderr_data) - self.assertNotIn("warning:", pants_run.stdout_data) - self.assertNotIn("error:", pants_run.stdout_data) - - def test_warning(self): - cmd = ["compile", "contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone:warning"] - pants_run = self.run_pants(cmd) - self.assert_success(pants_run) - self.assertNotIn("Exception caught:", pants_run.stderr_data) - self.assertIn( - "warning: [ReferenceEquality] Comparison using reference equality instead of value equality", - pants_run.stdout_data, - ) - self.assertIn( - "(see http://errorprone.info/bugpattern/ReferenceEquality)", pants_run.stdout_data - ) - self.assertNotIn("error:", pants_run.stdout_data) - self.assertIn("1 warning", pants_run.stdout_data) - - def test_error(self): - cmd = ["compile", "contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone:error"] - pants_run = self.run_pants(cmd) - self.assert_failure(pants_run) - self.assertIn( - "error: [ArrayToString] Calling toString on an array does not provide useful information", - pants_run.stdout_data, - ) - self.assertIn( - "(see http://errorprone.info/bugpattern/ArrayToString)", pants_run.stdout_data - ) - self.assertNotIn("warning:", pants_run.stdout_data) - self.assertIn("1 error", pants_run.stdout_data) - - def test_warning_gets_cached(self): - with self.temporary_cachedir() as cache: - args = [ - "compile", - "--cache-write", - "--cache-write-to=['{}']".format(cache), - "--cache-read", - "--cache-read-from=['{}']".format(cache), - "contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone:warning", - ] - - pants_run = self.run_pants(args) - self.assert_success(pants_run) - self.assertNotIn("Exception caught:", pants_run.stderr_data) - self.assertIn("[errorprone]", pants_run.stdout_data) - self.assertIn("No cached artifacts", pants_run.stdout_data) - self.assertIn("1 warning", pants_run.stdout_data) - self.assertIn("SUCCESS", pants_run.stdout_data) - - pants_run = self.run_pants(args) - self.assert_success(pants_run) - self.assertNotIn("Exception caught:", pants_run.stderr_data) - self.assertIn("[errorprone]", pants_run.stdout_data) - self.assertIn("Using cached artifacts", pants_run.stdout_data) - self.assertNotIn("No cached artifacts", pants_run.stdout_data) - self.assertNotIn("1 warning", pants_run.stdout_data) - self.assertIn("SUCCESS", pants_run.stdout_data) - - def test_error_does_not_get_cached(self): - with self.temporary_cachedir() as cache: - args = [ - "compile", - "--cache-write", - "--cache-write-to=['{}']".format(cache), - "--cache-read", - "--cache-read-from=['{}']".format(cache), - "contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone:error", - ] - - pants_run = self.run_pants(args) - self.assert_failure(pants_run) - self.assertNotIn("Exception caught:", pants_run.stderr_data) - self.assertIn("[errorprone]", pants_run.stdout_data) - self.assertIn("No cached artifacts", pants_run.stdout_data) - self.assertIn("1 error", pants_run.stdout_data) - self.assertIn("FAILURE: ErrorProne checks failed", pants_run.stdout_data) - - pants_run = self.run_pants(args) - - self.assert_failure(pants_run) - self.assertNotIn("Exception caught:", pants_run.stderr_data) - self.assertIn("[errorprone]", pants_run.stdout_data) - self.assertIn("Using cached artifacts", pants_run.stdout_data) - self.assertIn("1 error", pants_run.stdout_data) - self.assertIn("FAILURE: ErrorProne checks failed", pants_run.stdout_data) diff --git a/contrib/findbugs/BUILD b/contrib/findbugs/BUILD deleted file mode 100644 index 1192fcfd607..00000000000 --- a/contrib/findbugs/BUILD +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -files( - name='java_tests_directory', - sources=['tests/java/**/*'], -) diff --git a/contrib/findbugs/README.md b/contrib/findbugs/README.md deleted file mode 100644 index 6274593d142..00000000000 --- a/contrib/findbugs/README.md +++ /dev/null @@ -1,91 +0,0 @@ -# Pants plugin for FindBugs - -The FindBugs plugin runs FindBugs bytecode analysis on Java class files and looks for various -[bug patterns](http://findbugs.sourceforge.net/bugDescriptions.html) not reported by the compiler. - -A full description of FindBugs can be found on the [FindBugs home page](http://findbugs.sourceforge.net/factSheet.html). - -This plugin uses FindBugs 3.0.1 which requires Java 1.7.0 or later to run. - - -## Installation - -FindBugs support is provided by a plugin distributed to [pypi] -(https://pypi.org/pypi/pantsbuild.pants.contrib.findbugs). -Assuming you have already [installed pants](http://www.pantsbuild.org/install.html), you'll need to -add the FindBugs plugin in your `pants.toml`, like so: -```toml -[GLOBAL] -pants_version = "1.26.0" - -plugins = [ - 'pantsbuild.pants.contrib.findbugs==%(pants_version)s', -] -``` - -## Running - -When you run `./pants compile` the plugin is executed after the compile step and will run FindBugs -on any `java_library` or `junit_tests` targets. - -``` -./pants compile -... - 00:07:42 00:00 [compile] - 00:07:42 00:00 [zinc] - 00:07:42 00:00 [jvm-dep-check] - 00:07:42 00:00 [checkstyle] - 00:07:42 00:00 [findbugs] - Invalidated 7 targets. - 00:07:42 00:00 [findbugs] -... -``` - -## Options - -The plugin currently supports the following subset of the [FindBugs command line options](http://findbugs.sourceforge.net/manual/running.html#commandLineOptions). - -``` ---compile-findbugs-effort= (one of: [min, less, default, more, max] default: 'default') - Effort of the bug finders. ---compile-findbugs-exclude-filter-file= (default: None) - Exclude bugs matching given filter ---compile-findbugs-include-filter-file= (default: None) - Include only bugs matching given filter ---compile-findbugs-max-rank= (default: None) - Maximum bug ranking to record [1..20]. ---[no-]compile-findbugs-nested (default: True) - Analyze nested jar/zip archives ---[no-]compile-findbugs-relaxed (default: False) - Relaxed reporting mode ---compile-findbugs-threshold= (one of: [low, medium, high, experimental] default: 'medium') - Effort of the bug finders. -``` - -The plugin will not fail the build unless you enable - -``` ---[no-]compile-findbugs-fail-on-error (default: False) - Fail the build on an error. -``` - -If you enable this option then you may also want to set `--compile-findbugs-max-rank` so the build will -only fail for bugs above a certain rank. - -Alternatively you can exclude files with the `--compile-findbugs-exclude-patterns` and setup a findbugsExclude.xml file -to filter out specific bug reports. The format of the exclude file is documented on the [FindBugs site](http://findbugs.sourceforge.net/manual/filter.html). - -Here are example settings that fail the build only for highly ranked bugs and exclude all test files - -```toml -[compile.findbugs] -max_rank = 4 -fail_on_error = true -exclude_patterns = [".*/tests/java/.*"] -``` - -## Reporting - -The task will report bugs to stdout as it runs. Alternatively, if you want to process or store the -XML files generated by FindBugs they will be available under `.pants.d/compile/findbugs` after you run the -plugin. diff --git a/contrib/findbugs/src/python/pants/__init__.py b/contrib/findbugs/src/python/pants/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/findbugs/src/python/pants/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/findbugs/src/python/pants/contrib/__init__.py b/contrib/findbugs/src/python/pants/contrib/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/findbugs/src/python/pants/contrib/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/findbugs/src/python/pants/contrib/findbugs/BUILD b/contrib/findbugs/src/python/pants/contrib/findbugs/BUILD deleted file mode 100644 index fd1fc1d8af8..00000000000 --- a/contrib/findbugs/src/python/pants/contrib/findbugs/BUILD +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -contrib_plugin( - name='plugin', - dependencies=[ - 'contrib/findbugs/src/python/pants/contrib/findbugs/tasks', - 'src/python/pants/build_graph', - 'src/python/pants/goal:task_registrar', - ], - distribution_name='pantsbuild.pants.contrib.findbugs', - description='FindBugs pants plugin (deprecated)', - register_goals=True, - tags = {"partially_type_checked"}, -) diff --git a/contrib/findbugs/src/python/pants/contrib/findbugs/__init__.py b/contrib/findbugs/src/python/pants/contrib/findbugs/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/findbugs/src/python/pants/contrib/findbugs/register.py b/contrib/findbugs/src/python/pants/contrib/findbugs/register.py deleted file mode 100644 index 0279548ff87..00000000000 --- a/contrib/findbugs/src/python/pants/contrib/findbugs/register.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -"""Linter for Java (deprecated). - -See http://findbugs.sourceforge.net. -""" -from pants.base.deprecated import _deprecated_contrib_plugin -from pants.goal.task_registrar import TaskRegistrar as task - -from pants.contrib.findbugs.tasks.findbugs import FindBugs - -_deprecated_contrib_plugin("pantsbuild.pants.contrib.findbugs") - - -def register_goals(): - task(name="findbugs", action=FindBugs).install("compile") diff --git a/contrib/findbugs/src/python/pants/contrib/findbugs/tasks/BUILD b/contrib/findbugs/src/python/pants/contrib/findbugs/tasks/BUILD deleted file mode 100644 index c14b9b6ea50..00000000000 --- a/contrib/findbugs/src/python/pants/contrib/findbugs/tasks/BUILD +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_library( - dependencies=[ - 'src/python/pants/backend/jvm/subsystems:shader', - 'src/python/pants/backend/jvm/targets:java', - 'src/python/pants/backend/jvm/tasks:nailgun_task', - 'src/python/pants/java/jar', - 'src/python/pants/base:build_environment', - 'src/python/pants/base:exceptions', - 'src/python/pants/base:workunit', - 'src/python/pants/util:dirutil', - 'src/python/pants/util:ordered_set', - 'src/python/pants/util:xml_parser', - ], - tags = {"partially_type_checked"}, -) diff --git a/contrib/findbugs/src/python/pants/contrib/findbugs/tasks/__init__.py b/contrib/findbugs/src/python/pants/contrib/findbugs/tasks/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/findbugs/src/python/pants/contrib/findbugs/tasks/findbugs.py b/contrib/findbugs/src/python/pants/contrib/findbugs/tasks/findbugs.py deleted file mode 100644 index 39527b68d36..00000000000 --- a/contrib/findbugs/src/python/pants/contrib/findbugs/tasks/findbugs.py +++ /dev/null @@ -1,303 +0,0 @@ -# Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -import os -import re - -from pants.backend.jvm.subsystems.shader import Shader -from pants.backend.jvm.targets.java_library import JavaLibrary -from pants.backend.jvm.targets.junit_tests import JUnitTests -from pants.backend.jvm.tasks.nailgun_task import NailgunTask -from pants.base.build_environment import get_buildroot -from pants.base.exceptions import TaskError -from pants.base.revision import Revision -from pants.base.workunit import WorkUnitLabel -from pants.java.jar.jar_dependency import JarDependency -from pants.option.custom_types import file_option -from pants.util.dirutil import safe_mkdir -from pants.util.memo import memoized_property -from pants.util.ordered_set import OrderedSet -from pants.util.xml_parser import XmlParser - - -class FindBugs(NailgunTask): - """Check Java code for findbugs violations.""" - - _FINDBUGS_MAIN = "edu.umd.cs.findbugs.FindBugs2" - _HIGH_PRIORITY_LOWEST_RANK = 4 - _NORMAL_PRIORITY_LOWEST_RANK = 9 - - @classmethod - def register_options(cls, register): - super().register_options(register) - - register("--skip", type=bool, help="Skip findbugs.") - register( - "--transitive", - default=False, - type=bool, - help="Run findbugs against transitive dependencies of targets specified on " - "the command line.", - ) - register( - "--effort", - default="default", - fingerprint=True, - choices=["min", "less", "default", "more", "max"], - help="Effort of the bug finders.", - ) - register( - "--threshold", - default="medium", - fingerprint=True, - choices=["low", "medium", "high", "experimental"], - help="Effort of the bug finders.", - ) - register("--fail-on-error", type=bool, fingerprint=True, help="Fail the build on an error.") - register( - "--max-rank", type=int, fingerprint=True, help="Maximum bug ranking to record [1..20]." - ) - register("--relaxed", type=bool, fingerprint=True, help="Relaxed reporting mode") - register( - "--nested", - type=bool, - default=True, - fingerprint=True, - help="Analyze nested jar/zip archives", - ) - register( - "--exclude-filter-file", - type=file_option, - fingerprint=True, - help="Exclude bugs matching given filter", - ) - register( - "--include-filter-file", - type=file_option, - fingerprint=True, - help="Include only bugs matching given filter", - ) - register( - "--exclude-patterns", - type=list, - default=[], - fingerprint=True, - help="Patterns for targets to be excluded from analysis.", - ) - - cls.register_jvm_tool( - register, - "findbugs", - classpath=[JarDependency(org="com.github.spotbugs", name="spotbugs", rev="3.1.3")], - main=cls._FINDBUGS_MAIN, - custom_rules=[Shader.exclude_package("edu.umd.cs.findbugs", recursive=True)], - ) - - @classmethod - def prepare(cls, options, round_manager): - super().prepare(options, round_manager) - round_manager.require_data("runtime_classpath") - - @property - def cache_target_dirs(self): - return True - - @memoized_property - def _exclude_patterns(self): - return [re.compile(x) for x in set(self.get_options().exclude_patterns or [])] - - def _is_findbugs_target(self, target): - if not isinstance(target, (JavaLibrary, JUnitTests)): - self.context.log.debug( - "Skipping [{}] because it is not a java library or java test".format( - target.address.spec - ) - ) - return False - if target.is_synthetic: - self.context.log.debug( - "Skipping [{}] because it is a synthetic target".format(target.address.spec) - ) - return False - for pattern in self._exclude_patterns: - if pattern.search(target.address.spec): - self.context.log.debug( - "Skipping [{}] because it matches exclude pattern '{}'".format( - target.address.spec, pattern.pattern - ) - ) - return False - return True - - def execute(self): - if self.get_options().skip: - return - - if self.get_options().transitive: - targets = self.context.targets(self._is_findbugs_target) - else: - targets = [t for t in self.context.target_roots if self._is_findbugs_target(t)] - - targets = list(set(targets)) - - bug_counts = {"error": 0, "high": 0, "normal": 0, "low": 0} - target_count = 0 - with self.invalidated(targets, invalidate_dependents=True) as invalidation_check: - total_targets = len(invalidation_check.invalid_vts) - for vt in invalidation_check.invalid_vts: - target_count += 1 - self.context.log.info( - "[{}/{}] {}".format( - str(target_count).rjust(len(str(total_targets))), - total_targets, - vt.target.address.spec, - ) - ) - - target_bug_counts = self.findbugs(vt.target) - if not self.get_options().fail_on_error or sum(target_bug_counts.values()) == 0: - vt.update() - bug_counts = { - k: bug_counts.get(k, 0) + target_bug_counts.get(k, 0) for k in bug_counts.keys() - } - - error_count = bug_counts.pop("error", 0) - bug_counts["total"] = sum(bug_counts.values()) - if error_count + bug_counts["total"] > 0: - self.context.log.info("") - if error_count > 0: - self.context.log.warn("Errors: {}".format(error_count)) - if bug_counts["total"] > 0: - self.context.log.warn( - "Bugs: {total} (High: {high}, Normal: {normal}, Low: {low})".format( - **bug_counts - ) - ) - if self.get_options().fail_on_error: - raise TaskError( - "failed with {bug} bugs and {err} errors".format( - bug=bug_counts["total"], err=error_count - ) - ) - - def findbugs(self, target): - runtime_classpaths = self.context.products.get_data("runtime_classpath") - runtime_classpath = runtime_classpaths.get_for_targets(target.closure(bfs=True)) - aux_classpath = OrderedSet(jar for conf, jar in runtime_classpath if conf == "default") - - target_jars = OrderedSet( - jar for conf, jar in runtime_classpaths.get_for_target(target) if conf == "default" - ) - - bug_counts = {"error": 0, "high": 0, "normal": 0, "low": 0} - - if not target_jars: - self.context.log.info(" No jars to be analyzed") - return bug_counts - - output_dir = os.path.join(self.workdir, target.id) - safe_mkdir(output_dir) - output_file = os.path.join(output_dir, "findbugsXml.xml") - - aux_classpath_file = os.path.join( - self.workdir, "{}.classpath".format(os.path.basename(output_dir)) - ) - with open(aux_classpath_file, "w") as f: - f.write("\n".join(aux_classpath - target_jars)) - - args = [ - "-auxclasspathFromFile", - aux_classpath_file, - "-projectName", - target.address.spec, - "-xml:withMessages", - "-effort:{}".format(self.get_options().effort), - "-{}".format(self.get_options().threshold), - "-nested:{}".format("true" if self.get_options().nested else "false"), - "-output", - output_file, - "-noClassOk", - ] - - if self.get_options().exclude_filter_file: - args.extend( - ["-exclude", os.path.join(get_buildroot(), self.get_options().exclude_filter_file)] - ) - - if self.get_options().include_filter_file: - args.extend( - ["-include", os.path.join(get_buildroot(), self.get_options().include_filter_file)] - ) - - if self.get_options().max_rank: - args.extend(["-maxRank", str(self.get_options().max_rank)]) - - if self.get_options().relaxed: - args.extend(["-relaxed"]) - - if self.debug: - args.extend(["-progress"]) - - args.extend(target_jars) - - # Try to run spotbugs with the same java version as the target - # The minimum JDK for spotbugs is JDK 1.8 - min_jdk_version = max(target.platform.target_level, Revision.lenient("1.8")) - if min_jdk_version.components[0] == 1: - max_jdk_version = Revision( - min_jdk_version.components[0], min_jdk_version.components[1], "9999" - ) - else: - max_jdk_version = Revision(min_jdk_version.components[0], "9999") - - self.set_distribution( - minimum_version=min_jdk_version, maximum_version=max_jdk_version, jdk=True - ) - - result = self.runjava( - classpath=self.tool_classpath("findbugs"), - main=self._FINDBUGS_MAIN, - jvm_options=self.get_options().jvm_options, - args=args, - workunit_name="findbugs", - workunit_labels=[WorkUnitLabel.LINT], - ) - if result != 0: - raise TaskError( - "java {main} ... exited non-zero ({result})".format( - main=self._FINDBUGS_MAIN, result=result - ) - ) - - xml = XmlParser.from_file(output_file) - for error in xml.parsed.getElementsByTagName("Error"): - self.context.log.warn( - "Error: {msg}".format( - msg=error.getElementsByTagName("ErrorMessage")[0].firstChild.data - ) - ) - bug_counts["error"] += 1 - - for bug_instance in xml.parsed.getElementsByTagName("BugInstance"): - bug_rank = bug_instance.getAttribute("rank") - if int(bug_rank) <= self._HIGH_PRIORITY_LOWEST_RANK: - priority = "high" - elif int(bug_rank) <= self._NORMAL_PRIORITY_LOWEST_RANK: - priority = "normal" - else: - priority = "low" - bug_counts[priority] += 1 - - source_line = bug_instance.getElementsByTagName("Class")[0].getElementsByTagName( - "SourceLine" - )[0] - self.context.log.warn( - "Bug[{priority}]: {type} {desc} {line}".format( - priority=priority, - type=bug_instance.getAttribute("type"), - desc=bug_instance.getElementsByTagName("LongMessage")[0].firstChild.data, - line=source_line.getElementsByTagName("Message")[0].firstChild.data, - ) - ) - - return bug_counts diff --git a/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/AllWarnings.java b/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/AllWarnings.java deleted file mode 100644 index baa8a14afc5..00000000000 --- a/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/AllWarnings.java +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). -// Licensed under the Apache License, Version 2.0 (see LICENSE). - -package org.pantsbuild.contrib.findbugs; - -public class AllWarnings { - public static void main(String[] args) { - System.out.println("No FindBugs warnings"); - - System.out.printf("FindBugs Low Warning VA_FORMAT_STRING_USES_NEWLINE: \n"); - - String normal = null; - System.out.printf("FindBugs Normal Warning NP_ALWAYS_NULL: %d", normal.length()); - - String high = "string"; - System.out.println("FindBugs High Warning EC_UNRELATED_TYPES:" + high.equals(high.length())); - } -} diff --git a/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/BUILD b/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/BUILD deleted file mode 100644 index 2dcd23ab85c..00000000000 --- a/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/BUILD +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -java_library( - name='none', - sources=['NoWarnings.java'] -) - -java_library( - name='empty', - sources=['Empty.java'] -) - -java_library( - name='low', - sources=['LowWarning.java'] -) - -java_library( - name='normal', - sources=['NormalWarning.java'] -) - -java_library( - name='high', - sources=['HighWarning.java'] -) - -java_library( - name='no_sources', - sources=[], - dependencies=[ - ':low', - ':normal', - ':high', - ] -) - -target( - name='all', - dependencies=[ - ':none', - ':low', - ':normal', - ':high', - ] -) diff --git a/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/Empty.java b/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/Empty.java deleted file mode 100644 index 8e568943c35..00000000000 --- a/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/Empty.java +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). -// Licensed under the Apache License, Version 2.0 (see LICENSE). - -package org.pantsbuild.contrib.findbugs; - -// We should not throw an error when the source file is empty diff --git a/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/HighWarning.java b/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/HighWarning.java deleted file mode 100644 index 3a30292d134..00000000000 --- a/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/HighWarning.java +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). -// Licensed under the Apache License, Version 2.0 (see LICENSE). - -package org.pantsbuild.contrib.findbugs; - -public class HighWarning { - @SuppressWarnings("EqualsIncompatibleType") - public static void main(String[] args) { - String high = "string"; - System.out.println("FindBugs High Warning EC_UNRELATED_TYPES:" + high.equals(high.length())); - } -} diff --git a/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/LowWarning.java b/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/LowWarning.java deleted file mode 100644 index 21be11d8d94..00000000000 --- a/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/LowWarning.java +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). -// Licensed under the Apache License, Version 2.0 (see LICENSE). - -package org.pantsbuild.contrib.findbugs; - -public class LowWarning { - public static void main(String[] args) { - System.out.printf("FindBugs Low Warning VA_FORMAT_STRING_USES_NEWLINE: \n"); - } -} diff --git a/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/NoWarnings.java b/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/NoWarnings.java deleted file mode 100644 index 3770344dac9..00000000000 --- a/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/NoWarnings.java +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). -// Licensed under the Apache License, Version 2.0 (see LICENSE). - -package org.pantsbuild.contrib.findbugs; - -public class NoWarnings { - public static void main(String[] args) { - System.out.println("No FindBugs warnings"); - } -} diff --git a/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/NormalWarning.java b/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/NormalWarning.java deleted file mode 100644 index 247be2d5b91..00000000000 --- a/contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs/NormalWarning.java +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). -// Licensed under the Apache License, Version 2.0 (see LICENSE). - -package org.pantsbuild.contrib.findbugs; - -public class NormalWarning { - public static void main(String[] args) { - String normal = null; - System.out.printf("FindBugs Normal Warning NP_ALWAYS_NULL: %d", normal.length()); - } -} diff --git a/contrib/findbugs/tests/python/pants_test/__init__.py b/contrib/findbugs/tests/python/pants_test/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/findbugs/tests/python/pants_test/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/findbugs/tests/python/pants_test/contrib/__init__.py b/contrib/findbugs/tests/python/pants_test/contrib/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/findbugs/tests/python/pants_test/contrib/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/findbugs/tests/python/pants_test/contrib/findbugs/__init__.py b/contrib/findbugs/tests/python/pants_test/contrib/findbugs/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/findbugs/tests/python/pants_test/contrib/findbugs/tasks/BUILD b/contrib/findbugs/tests/python/pants_test/contrib/findbugs/tasks/BUILD deleted file mode 100644 index 29683ddda1c..00000000000 --- a/contrib/findbugs/tests/python/pants_test/contrib/findbugs/tasks/BUILD +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_tests( - sources=['test_findbugs.py'], - dependencies=[ - 'contrib/findbugs/src/python/pants/contrib/findbugs/tasks', - 'src/python/pants/testutil/jvm:nailgun_task_test_base', - 'src/python/pants/testutil/option', - 'src/python/pants/testutil:test_base', - ], - tags = {'partially_type_checked'}, -) - -python_tests( - name='integration', - sources=['test_findbugs_integration.py'], - dependencies=[ - 'src/python/pants/testutil:int-test', - 'contrib/findbugs:java_tests_directory', - ], - tags={'integration', 'partially_type_checked'}, - timeout=520, -) diff --git a/contrib/findbugs/tests/python/pants_test/contrib/findbugs/tasks/__init__.py b/contrib/findbugs/tests/python/pants_test/contrib/findbugs/tasks/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/findbugs/tests/python/pants_test/contrib/findbugs/tasks/test_findbugs.py b/contrib/findbugs/tests/python/pants_test/contrib/findbugs/tasks/test_findbugs.py deleted file mode 100644 index 65c44772641..00000000000 --- a/contrib/findbugs/tests/python/pants_test/contrib/findbugs/tasks/test_findbugs.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.testutil.jvm.nailgun_task_test_base import NailgunTaskTestBase - -from pants.contrib.findbugs.tasks.findbugs import FindBugs - - -class FindBugsTest(NailgunTaskTestBase): - @classmethod - def task_type(cls): - return FindBugs - - def test_no_sources(self): - task = self.prepare_execute(self.context()) - self.assertEqual(None, task.execute()) diff --git a/contrib/findbugs/tests/python/pants_test/contrib/findbugs/tasks/test_findbugs_integration.py b/contrib/findbugs/tests/python/pants_test/contrib/findbugs/tasks/test_findbugs_integration.py deleted file mode 100644 index f30d922f4c1..00000000000 --- a/contrib/findbugs/tests/python/pants_test/contrib/findbugs/tasks/test_findbugs_integration.py +++ /dev/null @@ -1,143 +0,0 @@ -# Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from textwrap import dedent - -from pants.base.build_environment import get_buildroot -from pants.testutil.pants_run_integration_test import PantsRunIntegrationTest -from pants.util.contextutil import temporary_file - - -class FindBugsTest(PantsRunIntegrationTest): - @classmethod - def hermetic(cls): - return True - - def run_pants(self, command, config=None, stdin_data=None, extra_env=None, **kwargs): - full_config = { - "GLOBAL": { - "pythonpath": ["%(buildroot)s/contrib/findbugs/src/python"], - "backend_packages": [ - "pants.backend.codegen", - "pants.backend.jvm", - "pants.contrib.findbugs", - ], - }, - "jvm-platform": { - "default_platform": "java8", - "platforms": {"java8": {"source": "8", "target": "8", "args": []}}, - }, - } - if config: - for scope, scoped_cfgs in config.items(): - updated = full_config.get(scope, {}) - updated.update(scoped_cfgs) - full_config[scope] = updated - return super().run_pants(command, full_config, stdin_data, extra_env, **kwargs) - - def test_no_warnings(self): - cmd = ["compile", "contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs:none"] - pants_run = self.run_pants(cmd) - self.assert_success(pants_run) - self.assertNotIn("Bug", pants_run.stdout_data) - self.assertNotIn("Errors:", pants_run.stdout_data) - - def test_empty_source_file(self): - cmd = ["compile", "contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs:empty"] - pants_run = self.run_pants(cmd) - self.assert_success(pants_run) - self.assertNotIn("Bug", pants_run.stdout_data) - self.assertNotIn("Errors:", pants_run.stdout_data) - - def test_low_warning(self): - cmd = ["compile", "contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs:low"] - pants_run = self.run_pants(cmd) - self.assert_success(pants_run) - self.assertIn( - "Bug[low]: VA_FORMAT_STRING_USES_NEWLINE Format string", pants_run.stdout_data - ) - self.assertNotIn("Errors:", pants_run.stdout_data) - self.assertIn("Bugs: 1 (High: 0, Normal: 0, Low: 1)", pants_run.stdout_data) - - def test_all_warnings(self): - cmd = ["compile", "contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs::"] - pants_run = self.run_pants(cmd) - self.assert_success(pants_run) - self.assertIn("Bug[high]: EC_UNRELATED_TYPES", pants_run.stdout_data) - self.assertIn("Bug[normal]: NP_ALWAYS_NULL", pants_run.stdout_data) - self.assertIn("Bug[low]: VA_FORMAT_STRING_USES_NEWLINE", pants_run.stdout_data) - self.assertNotIn("Errors:", pants_run.stdout_data) - self.assertIn("Bugs: 3 (High: 1, Normal: 1, Low: 1)", pants_run.stdout_data) - - def test_max_rank_fail_on_error(self): - cmd = ["compile", "contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs::"] - pants_ini_config = {"compile.findbugs": {"max_rank": 9, "fail_on_error": True}} - pants_run = self.run_pants(cmd, config=pants_ini_config) - self.assert_failure(pants_run) - self.assertIn("Bug[high]:", pants_run.stdout_data) - self.assertIn("Bug[normal]:", pants_run.stdout_data) - self.assertNotIn("Bug[low]:", pants_run.stdout_data) - self.assertIn("FAILURE: failed with 2 bugs and 0 errors", pants_run.stdout_data) - - def test_exclude(self): - cmd = ["compile", "contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs::"] - with temporary_file(root_dir=get_buildroot(), binary_mode=False) as exclude_file: - exclude_file.write( - dedent( - """\ - - - - - - - - - """ - ) - ) - exclude_file.close() - pants_ini_config = {"compile.findbugs": {"exclude_filter_file": exclude_file.name}} - pants_run = self.run_pants(cmd, config=pants_ini_config) - self.assert_success(pants_run) - self.assertIn("Bug[high]:", pants_run.stdout_data) - self.assertNotIn("Bug[normal]:", pants_run.stdout_data) - self.assertIn("Bug[low]:", pants_run.stdout_data) - self.assertNotIn("Errors:", pants_run.stdout_data) - self.assertIn("Bugs: 2 (High: 1, Normal: 0, Low: 1)", pants_run.stdout_data) - - def test_error(self): - cmd = ["compile", "contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs:high"] - with temporary_file(root_dir=get_buildroot(), binary_mode=False) as exclude_file: - exclude_file.write( - dedent( - """\ - - - - """ - ) - ) - exclude_file.close() - pants_ini_config = {"compile.findbugs": {"exclude_filter_file": exclude_file.name}} - pants_run = self.run_pants(cmd, config=pants_ini_config) - self.assert_success(pants_run) - self.assertIn("Bug[high]:", pants_run.stdout_data) - self.assertNotIn("Bug[normal]:", pants_run.stdout_data) - self.assertNotIn("Bug[low]:", pants_run.stdout_data) - self.assertIn("Errors: 1", pants_run.stdout_data) - self.assertIn("Unable to read filter:", pants_run.stdout_data) - self.assertIn('Attribute name "Tag" associated with an element type', pants_run.stdout_data) - self.assertIn("Bugs: 1 (High: 1, Normal: 0, Low: 0)", pants_run.stdout_data) - - def test_transitive(self): - cmd = ["compile", "contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs:all"] - pants_ini_config = {"compile.findbugs": {"transitive": True}} - pants_run = self.run_pants(cmd, config=pants_ini_config) - self.assert_success(pants_run) - self.assertIn("Bug[high]: EC_UNRELATED_TYPES", pants_run.stdout_data) - self.assertIn("Bug[normal]: NP_ALWAYS_NULL", pants_run.stdout_data) - self.assertIn("Bug[low]: VA_FORMAT_STRING_USES_NEWLINE", pants_run.stdout_data) - self.assertNotIn("Errors:", pants_run.stdout_data) - self.assertIn("Bugs: 3 (High: 1, Normal: 1, Low: 1)", pants_run.stdout_data) diff --git a/contrib/googlejavaformat/src/python/pants/__init__.py b/contrib/googlejavaformat/src/python/pants/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/googlejavaformat/src/python/pants/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/googlejavaformat/src/python/pants/contrib/__init__.py b/contrib/googlejavaformat/src/python/pants/contrib/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/googlejavaformat/src/python/pants/contrib/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/BUILD b/contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/BUILD deleted file mode 100644 index 8989038b8f8..00000000000 --- a/contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/BUILD +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_library( - sources=['googlejavaformat.py', 'subsystem.py'], - tags = {'partially_type_checked'}, -) - -contrib_plugin( - name='plugin', - dependencies=[ - ':googlejavaformat', - 'src/python/pants/goal:task_registrar', - ], - tags = {'partially_type_checked'}, - distribution_name='pantsbuild.pants.contrib.googlejavaformat', - description='Google Java Format code formatter pants plugins (deprecated).', - additional_classifiers=[ - 'Topic :: Software Development :: Pre-processors' - ], - register_goals=True, -) diff --git a/contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/__init__.py b/contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/googlejavaformat.py b/contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/googlejavaformat.py deleted file mode 100644 index 1503ac2b261..00000000000 --- a/contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/googlejavaformat.py +++ /dev/null @@ -1,106 +0,0 @@ -# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from abc import abstractmethod - -from pants.backend.jvm.tasks.rewrite_base import RewriteBase -from pants.base.exceptions import TaskError -from pants.java.jar.jar_dependency import JarDependency -from pants.task.fmt_task_mixin import FmtTaskMixin -from pants.task.lint_task_mixin import LintTaskMixin - -from pants.contrib.googlejavaformat.subsystem import GoogleJavaFormat - - -class GoogleJavaFormatBase(RewriteBase): - def _resolve_conflicting_skip(self, *, old_scope: str): - # Skip mypy because this is a temporary hack, and mypy doesn't follow the inheritance chain - # properly. - return self.resolve_conflicting_skip_options( # type: ignore - old_scope=old_scope, - new_scope="google-java-format", - subsystem=GoogleJavaFormat.global_instance(), - ) - - @classmethod - def register_options(cls, register): - super().register_options(register) - cls.register_jvm_tool( - register, - "google-java-format", - classpath=[ - JarDependency( - org="com.google.googlejavaformat", name="google-java-format", rev="1.5" - ) - ], - ) - - @classmethod - def implementation_version(cls): - return super().implementation_version() + [("GoogleJavaFormatBase", 1)] - - @classmethod - def subsystem_dependencies(cls): - return super().subsystem_dependencies() + (GoogleJavaFormat,) - - @classmethod - def target_types(cls): - return ["java_library", "junit_tests"] - - @classmethod - def source_extension(cls): - return ".java" - - def invoke_tool(self, _, target_sources): - args = list(self.additional_args) - args.extend([source for target, source in target_sources]) - return self.runjava( - classpath=self.tool_classpath("google-java-format"), - main="com.google.googlejavaformat.java.Main", - args=args, - workunit_name="google-java-format", - jvm_options=self.get_options().jvm_options, - ) - - @property - @abstractmethod - def additional_args(self): - """List of additional args to supply on the tool command-line.""" - - -class GoogleJavaFormatLintTask(LintTaskMixin, GoogleJavaFormatBase): - """Check if Java source code complies with Google Java Style. - - If the files are not formatted correctly an error is raised including the command to run to - format the files correctly - """ - - sideeffecting = False - additional_args = ["--set-exit-if-changed"] - - @property - def skip_execution(self): - return GoogleJavaFormat.global_instance().options.skip - - def process_result(self, result): - if result != 0: - raise TaskError( - "google-java-format failed with exit code {}; to fix run: " - "`./pants fmt `".format(result), - exit_code=result, - ) - - -class GoogleJavaFormatTask(FmtTaskMixin, GoogleJavaFormatBase): - """Reformat Java source code to comply with Google Java Style.""" - - sideeffecting = True - additional_args = ["-i"] - - @property - def skip_execution(self): - return super().determine_if_skipped(formatter_subsystem=GoogleJavaFormat.global_instance()) - - def process_result(self, result): - if result != 0: - raise TaskError("google-java-format failed to format files", exit_code=result) diff --git a/contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/register.py b/contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/register.py deleted file mode 100644 index 184b9623f3e..00000000000 --- a/contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/register.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -"""Autoformatter for Java to follow Google's Java Style guide (deprecated). - -See https://github.com/google/google-java-format. -""" - -from pants.base.deprecated import _deprecated_contrib_plugin -from pants.goal.task_registrar import TaskRegistrar as task - -from pants.contrib.googlejavaformat.googlejavaformat import ( - GoogleJavaFormatLintTask, - GoogleJavaFormatTask, -) - -_deprecated_contrib_plugin("pantsbuild.pants.contrib.googlejavaformat") - - -def register_goals(): - task(name="google-java-format", action=GoogleJavaFormatTask).install("fmt") - task(name="google-java-format", action=GoogleJavaFormatLintTask).install("lint") diff --git a/contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/subsystem.py b/contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/subsystem.py deleted file mode 100644 index d902c30b7f9..00000000000 --- a/contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/subsystem.py +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.subsystem.subsystem import Subsystem - - -class GoogleJavaFormat(Subsystem): - - options_scope = "google-java-format" - - @classmethod - def register_options(cls, register): - super().register_options(register) - register( - "--skip", - type=bool, - default=False, - help="Don't use `google-java-format` when running `./pants fmt` and `./pants lint`.", - ) diff --git a/contrib/googlejavaformat/tests/python/pants_test/__init__.py b/contrib/googlejavaformat/tests/python/pants_test/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/googlejavaformat/tests/python/pants_test/contrib/__init__.py b/contrib/googlejavaformat/tests/python/pants_test/contrib/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/googlejavaformat/tests/python/pants_test/contrib/googlejavaformat/BUILD b/contrib/googlejavaformat/tests/python/pants_test/contrib/googlejavaformat/BUILD deleted file mode 100644 index fa1478bc683..00000000000 --- a/contrib/googlejavaformat/tests/python/pants_test/contrib/googlejavaformat/BUILD +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_tests( - dependencies = [ - 'contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat', - 'src/python/pants/backend/jvm:plugin', - 'src/python/pants/backend/jvm/targets:java', - 'src/python/pants/base:exceptions', - 'src/python/pants/build_graph', - 'src/python/pants/testutil/jvm:nailgun_task_test_base', - ], - tags = {'partially_type_checked'}, -) diff --git a/contrib/googlejavaformat/tests/python/pants_test/contrib/googlejavaformat/__init__.py b/contrib/googlejavaformat/tests/python/pants_test/contrib/googlejavaformat/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/googlejavaformat/tests/python/pants_test/contrib/googlejavaformat/test_googlejavaformat.py b/contrib/googlejavaformat/tests/python/pants_test/contrib/googlejavaformat/test_googlejavaformat.py deleted file mode 100644 index b3ec5a7a90c..00000000000 --- a/contrib/googlejavaformat/tests/python/pants_test/contrib/googlejavaformat/test_googlejavaformat.py +++ /dev/null @@ -1,105 +0,0 @@ -# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from textwrap import dedent - -from pants.backend.jvm.register import build_file_aliases as register_jvm -from pants.backend.jvm.targets.java_library import JavaLibrary -from pants.base.exceptions import TaskError -from pants.build_graph.register import build_file_aliases as register_core -from pants.testutil.jvm.nailgun_task_test_base import NailgunTaskTestBase - -from pants.contrib.googlejavaformat.googlejavaformat import ( - GoogleJavaFormatLintTask, - GoogleJavaFormatTask, -) - - -class TestBase(NailgunTaskTestBase): - - _BADFORMAT = dedent( - """ - package org.pantsbuild.contrib.googlejavaformat; - class MyClass { - public static void main(String[] args) { - System.out.println("Hello google-java-format!"); - } - } - """ - ) - - _GOODFORMAT = dedent( - """\ - package org.pantsbuild.contrib.googlejavaformat; - - class MyClass { - public static void main(String[] args) { - System.out.println("Hello google-java-format!"); - } - } - """ - ) - - @classmethod - def alias_groups(cls): - return super().alias_groups().merge(register_core().merge(register_jvm())) - - -class GoogleJavaFormatTests(TestBase): - @classmethod - def task_type(cls): - return GoogleJavaFormatTask - - def test_googlejavaformat(self): - javafile = self.create_file( - relpath="src/java/org/pantsbuild/contrib/googlejavaformat/MyClass.java", - contents=self._BADFORMAT, - ) - target = self.make_target( - spec="src/java/org/pantsbuild/contrib/googlejavaformat", - target_type=JavaLibrary, - sources=["MyClass.java"], - ) - self.set_options(only=None) - context = self.context(target_roots=[target]) - self.execute(context) - with open(javafile, "r") as fh: - actual = fh.read() - self.assertEqual(actual, self._GOODFORMAT) - - -class GoogleJavaFormatCheckFormatTests(TestBase): - @classmethod - def task_type(cls): - return GoogleJavaFormatLintTask - - def test_lint_badformat(self): - self.create_file( - relpath="src/java/org/pantsbuild/contrib/googlejavaformat/MyClass.java", - contents=self._BADFORMAT, - ) - target = self.make_target( - spec="src/java/org/pantsbuild/contrib/googlejavaformat", - target_type=JavaLibrary, - sources=["MyClass.java"], - ) - context = self.context(target_roots=[target]) - with self.assertRaises(TaskError) as error: - self.execute(context) - self.assertEqual( - str(error.exception), - "google-java-format failed with exit code 1; to fix run: `./pants fmt `", - ) - - def test_lint_goodformat(self): - self.create_file( - relpath="src/java/org/pantsbuild/contrib/googlejavaformat/MyClass.java", - contents=self._GOODFORMAT, - ) - target = self.make_target( - spec="src/java/org/pantsbuild/contrib/googlejavaformat", - target_type=JavaLibrary, - sources=["MyClass.java"], - ) - context = self.context(target_roots=[target]) - self.execute(context) diff --git a/contrib/jax_ws/BUILD b/contrib/jax_ws/BUILD deleted file mode 100644 index a27d9923f0f..00000000000 --- a/contrib/jax_ws/BUILD +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -files( - name='wsdl_tests_directory', - sources=['tests/wsdl/**/*'], -) diff --git a/contrib/jax_ws/README.md b/contrib/jax_ws/README.md deleted file mode 100644 index c2da2bc7470..00000000000 --- a/contrib/jax_ws/README.md +++ /dev/null @@ -1,61 +0,0 @@ -# Pants plugin for JAX-WS - -The JAX-WS plugin for Pants uses the [wsimport tool](https://jax-ws.java.net/jax-ws-ea3/docs/wsimport.html) to generate web service client stubs from a -Web Services Description Language (WSDL) file for calling a JAX-WS web service. - -## Installation - -JAX-WS support is provided by a plugin distributed to [pypi] -(https://pypi.org/pypi/pantsbuild.pants.contrib.jax_ws). -Assuming you have already [installed pants](http://www.pantsbuild.org/install.html), you'll need to -add the JAX-WS plugin in your `pants.toml`, like so: -```toml -[GLOBAL] -pants_version = "1.26.0" - -plugins = [ - 'pantsbuild.pants.contrib.jax_ws==%(pants_version)s', -] -``` - -## Target Example - -You can now add a `jax_ws_library` target definition to your BUILD file -```python -jax_ws_library(name='hello-service', - sources = [ - 'HelloService.wsdl', - ], - dependencies = [], -) -``` - -and service stubs will be generated for you when you `gen` this target -```bash -$ ./pants gen myproject/src/main/jax_ws:hello-service -``` - -Common jvm_options for jax-rs can be included in your `pants.toml` file -```toml -[gen.jax-ws] -jvm_options = [ - '-Djavax.xml.accessExternalSchema=all' -] -``` - -## Options - -The `jax_ws_library` target definition has the following options -```python -jax_ws_library(name='hello-service', - sources = [ - # wsdl files - ], - xjc_args=[ - # XJC-specific arguments - ], - extra_args=[ - # Additional arguments for wsimport - ], -) -``` diff --git a/contrib/jax_ws/src/python/pants/__init__.py b/contrib/jax_ws/src/python/pants/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/jax_ws/src/python/pants/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/jax_ws/src/python/pants/contrib/__init__.py b/contrib/jax_ws/src/python/pants/contrib/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/jax_ws/src/python/pants/contrib/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/jax_ws/src/python/pants/contrib/jax_ws/BUILD b/contrib/jax_ws/src/python/pants/contrib/jax_ws/BUILD deleted file mode 100644 index aae7c136349..00000000000 --- a/contrib/jax_ws/src/python/pants/contrib/jax_ws/BUILD +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -contrib_plugin( - name='plugin', - dependencies=[ - ':target_types', - 'contrib/jax_ws/src/python/pants/contrib/jax_ws/targets', - 'contrib/jax_ws/src/python/pants/contrib/jax_ws/tasks', - 'src/python/pants/build_graph', - 'src/python/pants/goal:task_registrar', - ], - distribution_name='pantsbuild.pants.contrib.jax_ws', - description='JAX-WS Pants plugin (deprecated)', - build_file_aliases=True, - register_goals=True, - tags = {"partially_type_checked"}, -) - -python_library( - name='target_types', - sources=['target_types.py'], - dependencies=[ - 'src/python/pants/backend/jvm:target_types', - 'src/python/pants/engine:target', - ], - tags = {"type_checked"}, -) diff --git a/contrib/jax_ws/src/python/pants/contrib/jax_ws/__init__.py b/contrib/jax_ws/src/python/pants/contrib/jax_ws/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/jax_ws/src/python/pants/contrib/jax_ws/register.py b/contrib/jax_ws/src/python/pants/contrib/jax_ws/register.py deleted file mode 100644 index 0d92073be73..00000000000 --- a/contrib/jax_ws/src/python/pants/contrib/jax_ws/register.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -"""Generate web service client stubs from a Web Services Description Language (WSDL) file for -calling a JAX-WS web service (deprecated).""" - -from pants.base.deprecated import _deprecated_contrib_plugin -from pants.build_graph.build_file_aliases import BuildFileAliases -from pants.goal.task_registrar import TaskRegistrar as task - -from pants.contrib.jax_ws.target_types import JaxWsLibrary -from pants.contrib.jax_ws.targets.jax_ws_library import JaxWsLibrary as JaxWsLibraryV1 -from pants.contrib.jax_ws.tasks.jax_ws_gen import JaxWsGen - -_deprecated_contrib_plugin("pantsbuild.pants.contrib.jax_ws") - - -def build_file_aliases(): - return BuildFileAliases(targets={"jax_ws_library": JaxWsLibraryV1}) - - -def register_goals(): - task(name="jax-ws", action=JaxWsGen).install("gen") - - -def target_types(): - return [JaxWsLibrary] diff --git a/contrib/jax_ws/src/python/pants/contrib/jax_ws/target_types.py b/contrib/jax_ws/src/python/pants/contrib/jax_ws/target_types.py deleted file mode 100644 index 1a7c5e3eb79..00000000000 --- a/contrib/jax_ws/src/python/pants/contrib/jax_ws/target_types.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.backend.jvm.target_types import COMMON_JVM_FIELDS -from pants.engine.target import Sources, StringSequenceField, Target - - -class JaxWsXjcArgs(StringSequenceField): - """Additional arguments to xjc.""" - - alias = "xjc_args" - - -class JaxWsExtraArgs(StringSequenceField): - """Additional arguments for the CLI.""" - - alias = "extra_args" - - -class JaxWsLibrary(Target): - """A Java library generated from JAX-WS wsdl files.""" - - alias = "jax_ws_library" - core_fields = (*COMMON_JVM_FIELDS, Sources, JaxWsXjcArgs, JaxWsExtraArgs) - v1_only = True diff --git a/contrib/jax_ws/src/python/pants/contrib/jax_ws/targets/BUILD b/contrib/jax_ws/src/python/pants/contrib/jax_ws/targets/BUILD deleted file mode 100644 index 6abdec4a924..00000000000 --- a/contrib/jax_ws/src/python/pants/contrib/jax_ws/targets/BUILD +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_library( - dependencies=[ - 'src/python/pants/base:payload_field', - 'src/python/pants/backend/jvm/targets:java', - ], - tags = {"partially_type_checked"}, -) diff --git a/contrib/jax_ws/src/python/pants/contrib/jax_ws/targets/__init__.py b/contrib/jax_ws/src/python/pants/contrib/jax_ws/targets/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/jax_ws/src/python/pants/contrib/jax_ws/targets/jax_ws_library.py b/contrib/jax_ws/src/python/pants/contrib/jax_ws/targets/jax_ws_library.py deleted file mode 100644 index 859984bde72..00000000000 --- a/contrib/jax_ws/src/python/pants/contrib/jax_ws/targets/jax_ws_library.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.backend.jvm.targets.jvm_target import JvmTarget -from pants.base.payload import Payload -from pants.base.payload_field import PrimitiveField - - -class JaxWsLibrary(JvmTarget): - """Generates a Java library from JAX-WS wsdl files.""" - - def __init__(self, payload=None, xjc_args=None, extra_args=None, **kwargs): - """Generates a Java library from WSDL files using JAX-WS. - - :param list xjc_args: Additional arguments to xjc. - :param list extra_args: Additional arguments for the CLI. - """ - payload = payload or Payload() - payload.add_fields( - { - "xjc_args": PrimitiveField(self.assert_list(xjc_args, key_arg="xjc_args")), - "extra_args": PrimitiveField(self.assert_list(extra_args, key_arg="extra_args")), - } - ) - super().__init__(payload=payload, **kwargs) diff --git a/contrib/jax_ws/src/python/pants/contrib/jax_ws/tasks/BUILD b/contrib/jax_ws/src/python/pants/contrib/jax_ws/tasks/BUILD deleted file mode 100644 index 2c7aeb348f0..00000000000 --- a/contrib/jax_ws/src/python/pants/contrib/jax_ws/tasks/BUILD +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_library( - dependencies=[ - 'contrib/jax_ws/src/python/pants/contrib/jax_ws/targets:targets', - 'src/python/pants/backend/jvm/targets:java', - 'src/python/pants/backend/jvm/tasks:nailgun_task', - 'src/python/pants/base:build_environment', - 'src/python/pants/base:exceptions', - 'src/python/pants/task', - ], - tags = {"partially_type_checked"}, -) diff --git a/contrib/jax_ws/src/python/pants/contrib/jax_ws/tasks/__init__.py b/contrib/jax_ws/src/python/pants/contrib/jax_ws/tasks/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/jax_ws/src/python/pants/contrib/jax_ws/tasks/jax_ws_gen.py b/contrib/jax_ws/src/python/pants/contrib/jax_ws/tasks/jax_ws_gen.py deleted file mode 100644 index 000f39e6dbd..00000000000 --- a/contrib/jax_ws/src/python/pants/contrib/jax_ws/tasks/jax_ws_gen.py +++ /dev/null @@ -1,94 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -import logging -import os -import subprocess - -from pants.backend.jvm.targets.java_library import JavaLibrary -from pants.backend.jvm.tasks.nailgun_task import NailgunTask -from pants.base.exceptions import TaskError -from pants.base.workunit import WorkUnit, WorkUnitLabel -from pants.java.distribution.distribution import DistributionLocator -from pants.task.simple_codegen_task import SimpleCodegenTask - -from pants.contrib.jax_ws.targets.jax_ws_library import JaxWsLibrary - -logger = logging.getLogger(__name__) - - -class JaxWsGen(SimpleCodegenTask, NailgunTask): - """Generates Java files from wsdl files using the JAX-WS compiler.""" - - sources_globs = ("**/*",) - - @classmethod - def register_options(cls, register): - super().register_options(register) - register("--ws-quiet", type=bool, help="Suppress WsImport output") - register("--ws-verbose", type=bool, help="Make WsImport output verbose") - - @classmethod - def subsystem_dependencies(cls): - return super().subsystem_dependencies() + (DistributionLocator,) - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - - def synthetic_target_type(self, target): - return JavaLibrary - - def is_gentarget(self, target): - return isinstance(target, JaxWsLibrary) - - @classmethod - def supported_strategy_types(cls): - return [cls.IsolatedCodegenStrategy] - - def execute_codegen(self, target, target_workdir): - wsdl_directory = target.payload.sources.rel_path - for source in target.payload.sources.source_paths: - url = os.path.join(wsdl_directory, source) - wsimport_cmd = self._build_wsimport_cmd(target, target_workdir, url) - with self.context.new_workunit( - name="wsimport", cmd=" ".join(wsimport_cmd), labels=[WorkUnitLabel.TOOL] - ) as workunit: - self.context.log.debug("Executing {}".format(" ".join(wsimport_cmd))) - return_code = subprocess.Popen( - wsimport_cmd, stdout=workunit.output("stdout"), stderr=workunit.output("stderr") - ).wait() - workunit.set_outcome(WorkUnit.FAILURE if return_code else WorkUnit.SUCCESS) - if return_code: - raise TaskError("wsimport exited non-zero {rc}".format(rc=return_code)) - - def _build_wsimport_cmd(self, target, target_workdir, url): - distribution = DistributionLocator.cached(maximum_version="1.10.999", jdk=True) - # Ported and trimmed down from: - # https://java.net/projects/jax-ws-commons/sources/svn/content/trunk/ - # jaxws-maven-plugin/src/main/java/org/jvnet/jax_ws_commons/jaxws/WsImportMojo.java?rev=1191 - cmd = ["{}/bin/wsimport".format(distribution.real_home)] - if self.get_options().ws_verbose: - cmd.append("-verbose") - if self.get_options().ws_quiet: - cmd.append("-quiet") - cmd.append("-Xnocompile") # Always let pants do the compiling work. - cmd.extend(["-keep", "-s", os.path.abspath(target_workdir)]) - cmd.extend(["-d", os.path.abspath(target_workdir)]) - if target.payload.xjc_args: - cmd.extend( - ("-B{}".format(a) if a.startswith("-") else a) for a in target.payload.xjc_args - ) - cmd.append( - "-B-no-header" - ) # Don't let xjc write out a timestamp, because it'll break caching. - cmd.extend(target.payload.extra_args) - cmd.append(url) - if self.debug: - cmd.append("-Xdebug") - return cmd - - @property - def _copy_target_attributes(self): - """Propagate the provides attribute to the synthetic java_library() target for - publishing.""" - return ["provides"] diff --git a/contrib/jax_ws/tests/python/pants_test/__init__.py b/contrib/jax_ws/tests/python/pants_test/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/jax_ws/tests/python/pants_test/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/jax_ws/tests/python/pants_test/contrib/__init__.py b/contrib/jax_ws/tests/python/pants_test/contrib/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/jax_ws/tests/python/pants_test/contrib/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/jax_ws/tests/python/pants_test/contrib/jax_ws/__init__.py b/contrib/jax_ws/tests/python/pants_test/contrib/jax_ws/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/jax_ws/tests/python/pants_test/contrib/jax_ws/tasks/BUILD b/contrib/jax_ws/tests/python/pants_test/contrib/jax_ws/tasks/BUILD deleted file mode 100644 index eb7644818aa..00000000000 --- a/contrib/jax_ws/tests/python/pants_test/contrib/jax_ws/tasks/BUILD +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_tests( - sources=['test_jax_ws_gen.py'], - dependencies=[ - 'contrib/jax_ws/src/python/pants/contrib/jax_ws/tasks', - 'src/python/pants/testutil/jvm:nailgun_task_test_base', - 'src/python/pants/testutil/option', - 'src/python/pants/testutil:test_base', - ], - tags = {'partially_type_checked'}, -) - -python_tests( - name='integration', - sources=['test_jax_ws_gen_integration.py'], - dependencies=[ - 'src/python/pants/testutil:int-test', - 'src/python/pants/testutil:file_test_util', - 'contrib/jax_ws:wsdl_tests_directory', - ], - tags={'integration', 'partially_type_checked'}, - timeout=300, -) diff --git a/contrib/jax_ws/tests/python/pants_test/contrib/jax_ws/tasks/__init__.py b/contrib/jax_ws/tests/python/pants_test/contrib/jax_ws/tasks/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/jax_ws/tests/python/pants_test/contrib/jax_ws/tasks/test_jax_ws_gen.py b/contrib/jax_ws/tests/python/pants_test/contrib/jax_ws/tasks/test_jax_ws_gen.py deleted file mode 100644 index b4be17ac457..00000000000 --- a/contrib/jax_ws/tests/python/pants_test/contrib/jax_ws/tasks/test_jax_ws_gen.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.testutil.jvm.nailgun_task_test_base import NailgunTaskTestBase - -from pants.contrib.jax_ws.tasks.jax_ws_gen import JaxWsGen - - -class JaxWsGenTest(NailgunTaskTestBase): - @classmethod - def task_type(cls): - return JaxWsGen - - def test_no_sources(self): - task = self.prepare_execute(self.context()) - self.assertEqual(None, task.execute()) diff --git a/contrib/jax_ws/tests/python/pants_test/contrib/jax_ws/tasks/test_jax_ws_gen_integration.py b/contrib/jax_ws/tests/python/pants_test/contrib/jax_ws/tasks/test_jax_ws_gen_integration.py deleted file mode 100644 index 71ffb7ec54f..00000000000 --- a/contrib/jax_ws/tests/python/pants_test/contrib/jax_ws/tasks/test_jax_ws_gen_integration.py +++ /dev/null @@ -1,116 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -import os -from contextlib import contextmanager -from textwrap import dedent - -from pants.testutil.file_test_util import exact_files -from pants.testutil.pants_run_integration_test import PantsRunIntegrationTest -from pants.util.dirutil import safe_open - - -class JaxWsGenTest(PantsRunIntegrationTest): - @classmethod - def hermetic(cls): - return True - - def setUp(self): - super().setUp() - self.full_config = { - "GLOBAL": { - "pythonpath": ["%(buildroot)s/contrib/jax_ws/src/python"], - "backend_packages": [ - "pants.backend.codegen", - "pants.backend.jvm", - "pants.contrib.jax_ws", - ], - }, - "gen.jax-ws": {"jvm_options": ["-Djavax.xml.accessExternalSchema=all"]}, - } - - @staticmethod - def jax_ws_test_target(name): - return "contrib/jax_ws/tests/wsdl/org/pantsbuild/contrib/jax_ws:" + name - - def test_hello_service(self): - with self.temporary_workdir() as workdir: - cmd = ["gen", self.jax_ws_test_target("hello-service")] - pants_run = self.run_pants_with_workdir(cmd, workdir, config=self.full_config) - self.assert_success(pants_run) - self.assertIn("[jax-ws]", pants_run.stdout_data) - - jax_ws_contents = [ - p for p in os.listdir(os.path.join(workdir, "gen", "jax-ws")) if p != "current" - ] - self.assertEqual(len(jax_ws_contents), 1) - hash_dir = jax_ws_contents[0] - - root = os.path.join( - workdir, - "gen", - "jax-ws", - hash_dir, - "contrib.jax_ws.tests.wsdl.org.pantsbuild.contrib.jax_ws.hello-service", - "current", - ) - - self.assertEqual( - sorted( - [ - "com/example/HelloWorldServer.java", - "com/example/HelloWorldServerImplService.java", - ] - ), - sorted(exact_files(root)), - ) - - def test_invalid_service(self): - with self._create_invalid_jax_ws_project() as srcdir: - cmd = ["gen", os.path.join(srcdir, "src/jax_ws/test:invalid-service")] - pants_run = self.run_pants(cmd, config=self.full_config) - self.assert_failure(pants_run) - self.assertIn("[jax-ws]", pants_run.stdout_data) - self.assertIn("[ERROR] wsdl:binding", pants_run.stdout_data) - - @contextmanager - def _create_invalid_jax_ws_project(self): - with self.temporary_sourcedir() as srcdir: - with safe_open(os.path.join(srcdir, "src/jax_ws/test/InvalidService.wsdl"), "w") as fp: - fp.write( - dedent( - """ - - - - - - - - - """ - ).strip() - ) - with safe_open(os.path.join(srcdir, "src/jax_ws/test/BUILD"), "w") as fp: - fp.write( - dedent( - """ - jax_ws_library(name='invalid-service', - sources = [ - 'InvalidService.wsdl', - ], - dependencies = [], - ) - """ - ).strip() - ) - yield srcdir diff --git a/contrib/jax_ws/tests/wsdl/org/pantsbuild/contrib/jax_ws/BUILD b/contrib/jax_ws/tests/wsdl/org/pantsbuild/contrib/jax_ws/BUILD deleted file mode 100644 index 414908c52a7..00000000000 --- a/contrib/jax_ws/tests/wsdl/org/pantsbuild/contrib/jax_ws/BUILD +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -jax_ws_library(name='hello-service', - sources = [ - 'HelloService.wsdl', - ], - dependencies = [], -) diff --git a/contrib/jax_ws/tests/wsdl/org/pantsbuild/contrib/jax_ws/HelloService.wsdl b/contrib/jax_ws/tests/wsdl/org/pantsbuild/contrib/jax_ws/HelloService.wsdl deleted file mode 100644 index 91478733242..00000000000 --- a/contrib/jax_ws/tests/wsdl/org/pantsbuild/contrib/jax_ws/HelloService.wsdl +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/contrib/release_packages.sh b/contrib/release_packages.sh index f6842635175..e365e662b90 100644 --- a/contrib/release_packages.sh +++ b/contrib/release_packages.sh @@ -38,13 +38,6 @@ function pkg_node_install_test() { --explain test | grep "NodeTest_test_node" &> /dev/null } -function pkg_scalajs_install_test() { - local version=$1 - execute_packaged_pants_with_internal_backends \ - --plugins="['pantsbuild.pants.contrib.scalajs==${version}']" \ - --explain compile | grep "scala-js-link" &> /dev/null -} - function pkg_checks_install_test() { local version=$1 execute_packaged_pants_with_internal_backends \ @@ -62,20 +55,6 @@ function pkg_checker_install_test() { -c checker -- --help } -function pkg_findbugs_install_test() { - local version=$1 - execute_packaged_pants_with_internal_backends \ - --plugins="['pantsbuild.pants.contrib.findbugs==${version}']" \ - --explain compile | grep "findbugs" &> /dev/null -} - -function pkg_cpp_install_test() { - local version=$1 - execute_packaged_pants_with_internal_backends \ - --plugins="['pantsbuild.pants.contrib.cpp==${version}']" \ - --explain compile | grep "cpp" &> /dev/null -} - function pkg_confluence_install_test() { local version=$1 execute_packaged_pants_with_internal_backends \ @@ -83,13 +62,6 @@ function pkg_confluence_install_test() { --explain confluence | grep "ConfluencePublish_confluence" &> /dev/null } -function pkg_errorprone_install_test() { - local version=$1 - execute_packaged_pants_with_internal_backends \ - --plugins="['pantsbuild.pants.contrib.errorprone==${version}']" \ - --explain compile | grep "errorprone" &> /dev/null -} - function pkg_codeanalysis_install_test() { local version=$1 execute_packaged_pants_with_internal_backends \ @@ -97,17 +69,6 @@ function pkg_codeanalysis_install_test() { --explain index | grep "kythe" &> /dev/null } -function pkg_jax_ws_install_test() { - local version=$1 - # Ensure our goal and target are installed and exposed. - execute_packaged_pants_with_internal_backends \ - --plugins="['pantsbuild.pants.contrib.jax_ws==${version}']" \ - --explain gen | grep "jax-ws" &> /dev/null - execute_packaged_pants_with_internal_backends \ - --plugins="['pantsbuild.pants.contrib.jax_ws==${version}']" \ - targets | grep "jax_ws_library" &> /dev/null -} - function pkg_mypy_install_test() { local version=$1 execute_packaged_pants_with_internal_backends \ @@ -115,13 +76,6 @@ function pkg_mypy_install_test() { --explain lint | grep "mypy" &> /dev/null } -function pkg_avro_install_test() { - local version=$1 - execute_packaged_pants_with_internal_backends \ - --plugins="['pantsbuild.pants.contrib.avro==${version}']" \ - --explain gen | grep "avro-java" &> /dev/null -} - function pkg_awslambda_python_install_test() { local version=$1 execute_packaged_pants_with_internal_backends \ @@ -129,20 +83,3 @@ function pkg_awslambda_python_install_test() { --backend-packages2="-['pants.backend.awslambda.python']" \ --explain bundle | grep "lambdex" &> /dev/null } - -function pkg_thrifty_install_test() { - local version=$1 - execute_packaged_pants_with_internal_backends \ - --plugins="['pantsbuild.pants.contrib.thrifty==${version}']" \ - --explain gen | grep "thrifty" &> /dev/null -} - -function pkg_googlejavaformat_install_test() { - local version=$1 - execute_packaged_pants_with_internal_backends \ - --plugins="['pantsbuild.pants.contrib.googlejavaformat==${version}']" \ - --explain fmt | grep "google-java-format" &> /dev/null - execute_packaged_pants_with_internal_backends \ - --plugins="['pantsbuild.pants.contrib.googlejavaformat==${version}']" \ - --explain lint | grep "google-java-format" &> /dev/null -} diff --git a/contrib/scalajs/3rdparty/jvm/org/scala-js/BUILD b/contrib/scalajs/3rdparty/jvm/org/scala-js/BUILD deleted file mode 100644 index bea2e4cb41b..00000000000 --- a/contrib/scalajs/3rdparty/jvm/org/scala-js/BUILD +++ /dev/null @@ -1,19 +0,0 @@ -SCALAJS_REV = '0.6.25' - -jar_library(name = 'cli', - jars = [ - scala_jar(org='org.scala-js', name='scalajs-cli', rev=SCALAJS_REV), - ], -) - -jar_library(name = 'compiler', - jars = [ - jar(org='org.scala-js', name='scalajs-compiler_2.12.8', rev=SCALAJS_REV), - ], -) - -jar_library(name = 'library', - jars = [ - scala_jar(org='org.scala-js', name='scalajs-library', rev=SCALAJS_REV), - ], -) diff --git a/contrib/scalajs/BUILD b/contrib/scalajs/BUILD deleted file mode 100644 index c467998205c..00000000000 --- a/contrib/scalajs/BUILD +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -files( - name='examples_directory', - sources=['examples/**/*'], - dependencies=[ - 'examples/src/scala/org/pantsbuild/example:fact_directory', - ], -) diff --git a/contrib/scalajs/README.md b/contrib/scalajs/README.md deleted file mode 100644 index 9de61f9b5ec..00000000000 --- a/contrib/scalajs/README.md +++ /dev/null @@ -1,4 +0,0 @@ -Pants plugin to build scalajs packages -====================================== - -Compile and link scala code into scalajs javascript blobs. diff --git a/contrib/scalajs/examples/src/scala/org/pantsbuild/scalajs/example/factfinder/BUILD b/contrib/scalajs/examples/src/scala/org/pantsbuild/scalajs/example/factfinder/BUILD deleted file mode 100644 index 0f65267a251..00000000000 --- a/contrib/scalajs/examples/src/scala/org/pantsbuild/scalajs/example/factfinder/BUILD +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -scala_js_binary( - dependencies=[ - 'examples/src/scala/org/pantsbuild/example/fact:fact-js', - ], - sources=['*.scala'], -) diff --git a/contrib/scalajs/examples/src/scala/org/pantsbuild/scalajs/example/factfinder/Factfinder.scala b/contrib/scalajs/examples/src/scala/org/pantsbuild/scalajs/example/factfinder/Factfinder.scala deleted file mode 100644 index 1b97f08c48f..00000000000 --- a/contrib/scalajs/examples/src/scala/org/pantsbuild/scalajs/example/factfinder/Factfinder.scala +++ /dev/null @@ -1,15 +0,0 @@ -package org.pantsbuild.scalajs.example.factfinder - -import scala.scalajs.js.annotation.JSExport -import scala.scalajs.js.JSApp - -import org.pantsbuild.example.fact.Factorial - -@JSExport -object Factfinder extends JSApp { - def main(): Unit = println(s"Hello from ScalaJS! ${Factorial(10)}") - - /** NB: exported as Int for ease of use. */ - @JSExport - def fact(i: Int): String = Factorial(i).toString -} diff --git a/contrib/scalajs/src/python/pants/__init__.py b/contrib/scalajs/src/python/pants/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/scalajs/src/python/pants/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/scalajs/src/python/pants/contrib/__init__.py b/contrib/scalajs/src/python/pants/contrib/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/scalajs/src/python/pants/contrib/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/scalajs/src/python/pants/contrib/scalajs/BUILD b/contrib/scalajs/src/python/pants/contrib/scalajs/BUILD deleted file mode 100644 index e5710985f23..00000000000 --- a/contrib/scalajs/src/python/pants/contrib/scalajs/BUILD +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -contrib_plugin( - name='plugin', - dependencies=[ - ':target_types', - 'contrib/node/src/python/pants/contrib/node:plugin', - 'contrib/scalajs/src/python/pants/contrib/scalajs/subsystems', - 'contrib/scalajs/src/python/pants/contrib/scalajs/targets', - 'contrib/scalajs/src/python/pants/contrib/scalajs/tasks', - 'src/python/pants/build_graph', - 'src/python/pants/goal:task_registrar', - ], - tags = {'partially_type_checked'}, - distribution_name='pantsbuild.pants.contrib.scalajs', - description='scala.js support for pants (deprecated).', - build_file_aliases=True, - register_goals=True, - global_subsystems=True -) - -python_library( - name='target_types', - sources=['target_types.py'], - dependencies=[ - 'contrib/node/src/python/pants/contrib/node:target_types', - 'src/python/pants/engine:target', - ], - tags = {"type_checked"}, -) diff --git a/contrib/scalajs/src/python/pants/contrib/scalajs/__init__.py b/contrib/scalajs/src/python/pants/contrib/scalajs/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/scalajs/src/python/pants/contrib/scalajs/register.py b/contrib/scalajs/src/python/pants/contrib/scalajs/register.py deleted file mode 100644 index 3d4aaea7cc9..00000000000 --- a/contrib/scalajs/src/python/pants/contrib/scalajs/register.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -"""Support for Scala.js (deprecated).""" - -from pants.base.deprecated import _deprecated_contrib_plugin -from pants.build_graph.build_file_aliases import BuildFileAliases -from pants.goal.task_registrar import TaskRegistrar as task - -from pants.contrib.node.tasks.node_resolve import NodeResolve -from pants.contrib.scalajs.subsystems.scala_js_platform import ScalaJSPlatform -from pants.contrib.scalajs.target_types import ScalaJSBinary, ScalaJSLibrary -from pants.contrib.scalajs.targets.scala_js_binary import ScalaJSBinary as ScalaJSBinaryV1 -from pants.contrib.scalajs.targets.scala_js_library import ScalaJSLibrary as ScalaJSLibraryV1 -from pants.contrib.scalajs.tasks.scala_js_link import ScalaJSLink -from pants.contrib.scalajs.tasks.scala_js_zinc_compile import ScalaJSZincCompile - -_deprecated_contrib_plugin("pantsbuild.pants.contrib.scalajs") - - -def build_file_aliases(): - return BuildFileAliases( - targets={"scala_js_binary": ScalaJSBinaryV1, "scala_js_library": ScalaJSLibraryV1} - ) - - -def register_goals(): - NodeResolve.register_resolver_for_type(ScalaJSBinaryV1, ScalaJSPlatform) - # NB: These task/goal assignments are pretty nuts, but are necessary in order to - # prevent product-graph cycles between the JVM and node.js. - # see https://github.com/pantsbuild/pants/labels/engine - task(name="scala-js-compile", action=ScalaJSZincCompile).install("resolve") - task(name="scala-js-link", action=ScalaJSLink).install("resolve") - - -def global_subsystems(): - return {ScalaJSPlatform} - - -def target_types(): - return [ScalaJSBinary, ScalaJSLibrary] diff --git a/contrib/scalajs/src/python/pants/contrib/scalajs/subsystems/BUILD b/contrib/scalajs/src/python/pants/contrib/scalajs/subsystems/BUILD deleted file mode 100644 index 84bfbdcfac8..00000000000 --- a/contrib/scalajs/src/python/pants/contrib/scalajs/subsystems/BUILD +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_library( - dependencies = [ - 'contrib/node/src/python/pants/contrib/node/subsystems/resolvers:node_resolver_base', - 'src/python/pants/build_graph', - 'src/python/pants/option', - 'src/python/pants/subsystem', - 'src/python/pants/util:dirutil', - ], - tags = {"partially_type_checked"}, -) diff --git a/contrib/scalajs/src/python/pants/contrib/scalajs/subsystems/__init__.py b/contrib/scalajs/src/python/pants/contrib/scalajs/subsystems/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/scalajs/src/python/pants/contrib/scalajs/subsystems/scala_js_platform.py b/contrib/scalajs/src/python/pants/contrib/scalajs/subsystems/scala_js_platform.py deleted file mode 100644 index 89d6f0d1122..00000000000 --- a/contrib/scalajs/src/python/pants/contrib/scalajs/subsystems/scala_js_platform.py +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -import json -import os -import shutil - -from pants.build_graph.injectables_mixin import InjectablesMixin -from pants.option.custom_types import target_option -from pants.subsystem.subsystem import Subsystem -from pants.util.dirutil import safe_mkdir - -from pants.contrib.node.subsystems.resolvers.node_resolver_base import NodeResolverBase - - -class ScalaJSPlatform(InjectablesMixin, Subsystem, NodeResolverBase): - """The scala.js platform.""" - - options_scope = "scala-js" - - @classmethod - def register_options(cls, register): - super().register_options(register) - # TODO: revisit after https://rbcommons.com/s/twitter/r/3225/ - register( - "--runtime", - advanced=True, - type=list, - member_type=target_option, - default=["//:scala-js-library"], - help="Address specs pointing to the scala-js runtime libraries.", - ) - - @classmethod - def prepare(cls, options, round_manager): - super().prepare(options, round_manager) - round_manager.require_data("scala_js_binaries") - - def resolve_target(self, node_task, target, results_dir, node_paths): - # Copy any binaries to the results directory. - main = "" - scala_js_binaries = node_task.context.products.get_data("scala_js_binaries") - for dirname, rel_paths in scala_js_binaries[target].rel_paths(): - for rel_path in rel_paths: - main = rel_path - src_path = os.path.join(dirname, rel_path) - dest_path = os.path.join(results_dir, rel_path) - safe_mkdir(os.path.dirname(dest_path)) - shutil.copy2(src_path, dest_path) - - # And emit an empty package.json. - package = { - "name": target.name, - "version": "0.0.0", - "main": main, - } - with open(os.path.join(results_dir, "package.json"), "w") as fp: - json.dump(package, fp, indent=2) - - @property - def injectables_address_spec_mapping(self): - return { - "runtime": self.get_options().runtime, - } diff --git a/contrib/scalajs/src/python/pants/contrib/scalajs/target_types.py b/contrib/scalajs/src/python/pants/contrib/scalajs/target_types.py deleted file mode 100644 index 59d8eb3a2fa..00000000000 --- a/contrib/scalajs/src/python/pants/contrib/scalajs/target_types.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.engine.target import COMMON_TARGET_FIELDS, Dependencies, Sources, Target - -from pants.contrib.node.target_types import NodeModule - - -class ScalaJSBinary(Target): - """A binary JavaScript blob built from a collection of `scala_js_library` targets. - - This can be consumed by NPM and Node. - """ - - alias = "scala_js_binary" - core_fields = NodeModule.core_fields - v1_only = True - - -class ScalaJSLibrary(Target): - """A library with Scala sources which are intended to be compiled to JavaScript. - - Linking multiple libraries together into a shippable blob additionally requires a - `scala_js_binary` target. - """ - - alias = "scala_js_library" - core_fields = (*COMMON_TARGET_FIELDS, Dependencies, Sources) - v1_only = True diff --git a/contrib/scalajs/src/python/pants/contrib/scalajs/targets/BUILD b/contrib/scalajs/src/python/pants/contrib/scalajs/targets/BUILD deleted file mode 100644 index ec792997b52..00000000000 --- a/contrib/scalajs/src/python/pants/contrib/scalajs/targets/BUILD +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_library( - dependencies = [ - 'contrib/node/src/python/pants/contrib/node/targets:node_module', - 'contrib/scalajs/src/python/pants/contrib/scalajs/subsystems', - 'src/python/pants/backend/jvm/targets:jvm', - 'src/python/pants/backend/jvm/targets:scala', - 'src/python/pants/base:payload', - 'src/python/pants/base:payload_field', - 'src/python/pants/build_graph', - ], - tags = {'partially_type_checked'}, -) diff --git a/contrib/scalajs/src/python/pants/contrib/scalajs/targets/__init__.py b/contrib/scalajs/src/python/pants/contrib/scalajs/targets/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/scalajs/src/python/pants/contrib/scalajs/targets/scala_js_binary.py b/contrib/scalajs/src/python/pants/contrib/scalajs/targets/scala_js_binary.py deleted file mode 100644 index ad159281bb9..00000000000 --- a/contrib/scalajs/src/python/pants/contrib/scalajs/targets/scala_js_binary.py +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.contrib.node.targets.node_module import NodeModule -from pants.contrib.scalajs.targets.scala_js_target import ScalaJSTarget - - -class ScalaJSBinary(ScalaJSTarget, NodeModule): - """A binary javascript blob built from a collection of ScalaJSLibrary targets. - - Extends NodeModule to allow consumption by NPM and node. - """ - - pass diff --git a/contrib/scalajs/src/python/pants/contrib/scalajs/targets/scala_js_library.py b/contrib/scalajs/src/python/pants/contrib/scalajs/targets/scala_js_library.py deleted file mode 100644 index 35a4a42d70a..00000000000 --- a/contrib/scalajs/src/python/pants/contrib/scalajs/targets/scala_js_library.py +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.base.payload import Payload -from pants.build_graph.target import Target - -from pants.contrib.scalajs.targets.scala_js_target import ScalaJSTarget - - -class ScalaJSLibrary(ScalaJSTarget, Target): - """A library with scala sources, intended to be compiled to Javascript. - - Linking multiple libraries together into a shippable blob additionally requires a ScalaJSBinary - target. - """ - - def __init__(self, sources=None, address=None, payload=None, **kwargs): - """ - :param sources: Scala source that makes up this module; paths are relative to the BUILD - file's directory. - :type sources: a list of strings, with excludes prefixed by `!` - """ - payload = payload or Payload() - payload.add_fields( - { - "sources": self.create_sources_field( - sources=sources, sources_rel_path=address.spec_path, key_arg="sources" - ), - } - ) - super().__init__(address=address, payload=payload, **kwargs) diff --git a/contrib/scalajs/src/python/pants/contrib/scalajs/targets/scala_js_target.py b/contrib/scalajs/src/python/pants/contrib/scalajs/targets/scala_js_target.py deleted file mode 100644 index 696683fb7e7..00000000000 --- a/contrib/scalajs/src/python/pants/contrib/scalajs/targets/scala_js_target.py +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - - -from pants.backend.jvm.subsystems.jvm_platform import JvmPlatform -from pants.base.payload import Payload -from pants.base.payload_field import PrimitiveField, PrimitivesSetField - -from pants.contrib.scalajs.subsystems.scala_js_platform import ScalaJSPlatform - - -class ScalaJSTarget: - """A mixin for ScalaJS targets to injects scala-js deps and request ScalaJS compilation.""" - - @classmethod - def subsystems(cls): - return super().subsystems() + (JvmPlatform, ScalaJSPlatform) - - def __init__(self, address=None, payload=None, **kwargs): - self.address = address # Set in case a TargetDefinitionException is thrown early - payload = payload or Payload() - payload.add_fields( - {"platform": PrimitiveField(None), "compiler_option_sets": PrimitivesSetField(None)} - ) - super().__init__(address=address, payload=payload, **kwargs) - - @classmethod - def compute_dependency_address_specs(cls, kwargs=None, payload=None): - for address_spec in super().compute_dependency_address_specs(kwargs, payload): - yield address_spec - for address_spec in ScalaJSPlatform.global_instance().injectables_address_specs_for_key( - "runtime" - ): - yield address_spec - - @property - def strict_deps(self): - return False - - @property - def fatal_warnings(self): - return False - - @property - def compiler_option_sets(self): - """For every element in this list, enable the corresponding flags on compilation of targets. - - :return: See constructor. - :rtype: list - """ - return self.payload.compiler_option_sets - - @property - def zinc_file_manager(self): - return False - - @property - def platform(self): - return JvmPlatform.global_instance().get_platform_for_target(self) diff --git a/contrib/scalajs/src/python/pants/contrib/scalajs/tasks/BUILD b/contrib/scalajs/src/python/pants/contrib/scalajs/tasks/BUILD deleted file mode 100644 index f5e4aa22db6..00000000000 --- a/contrib/scalajs/src/python/pants/contrib/scalajs/tasks/BUILD +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_library( - dependencies = [ - 'contrib/scalajs/src/python/pants/contrib/scalajs/targets', - 'src/python/pants/backend/jvm/tasks/jvm_compile/zinc', - 'src/python/pants/backend/jvm/tasks:nailgun_task', - 'src/python/pants/goal:products', - 'src/python/pants/task', - 'src/python/pants/util:memo', - ], - tags = {'partially_type_checked'}, -) diff --git a/contrib/scalajs/src/python/pants/contrib/scalajs/tasks/__init__.py b/contrib/scalajs/src/python/pants/contrib/scalajs/tasks/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/scalajs/src/python/pants/contrib/scalajs/tasks/scala_js_link.py b/contrib/scalajs/src/python/pants/contrib/scalajs/tasks/scala_js_link.py deleted file mode 100644 index a8614a89847..00000000000 --- a/contrib/scalajs/src/python/pants/contrib/scalajs/tasks/scala_js_link.py +++ /dev/null @@ -1,115 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -import os -from collections import defaultdict - -from pants.backend.jvm.tasks.nailgun_task import NailgunTask -from pants.base.exceptions import TaskError -from pants.goal.products import MultipleRootedProducts - -from pants.contrib.scalajs.subsystems.scala_js_platform import ScalaJSPlatform -from pants.contrib.scalajs.targets.scala_js_binary import ScalaJSBinary - - -class ScalaJSLink(NailgunTask): - """Links intermediate scala.js representation outputs into a javascript binary.""" - - _SCALA_JS_CLI_MAIN = "org.scalajs.cli.Scalajsld" - - @classmethod - def register_options(cls, register): - super().register_options(register) - register( - "--full-opt", - type=bool, - fingerprint=True, - help="Perform all optimizations; this is generally only useful for deployments.", - ) - register( - "--check-ir", - type=bool, - fingerprint=True, - help="Perform (relatively costly) validity checks of IR before linking it.", - ) - # TODO: revisit after https://rbcommons.com/s/twitter/r/3225/ - cls.register_jvm_tool(register, "scala-js-cli", main=cls._SCALA_JS_CLI_MAIN) - - @classmethod - def prepare(cls, options, round_manager): - super().prepare(options, round_manager) - # Require that scala_js compilation has completed. - round_manager.require_data("scala_js_ir") - - @classmethod - def product_types(cls): - # Outputs are javascript blobs provided as a product or a resource to downstream consumers. - return ["scala_js_binaries", "runtime_classpath"] - - @classmethod - def subsystem_dependencies(cls): - return super().subsystem_dependencies() + (ScalaJSPlatform,) - - @property - def cache_target_dirs(self): - return True - - def _is_linked(self, target): - return isinstance(target, ScalaJSBinary) - - def _target_file(self, vt): - return os.path.join(vt.results_dir, f"{vt.target.name}.js") - - def execute(self): - scala_js_binaries = self.context.products.get_data( - "scala_js_binaries", lambda: defaultdict(MultipleRootedProducts) - ) - classpaths = self.context.products.get_data("runtime_classpath") - with self.invalidated( - self.context.targets(self._is_linked), invalidate_dependents=True - ) as invalidation_check: - for vt in invalidation_check.all_vts: - if not vt.valid: - self.context.log.debug(f"Linking {vt.target.address.spec}...") - self._link(vt.target, self._target_file(vt), classpaths) - else: - self.context.log.debug(f"Already linked {vt.target.address.spec}") - scala_js_binaries[vt.target].add_abs_paths(vt.results_dir, [self._target_file(vt)]) - classpaths.add_for_target(vt.target, [("default", vt.results_dir)]) - - def _link(self, target, output_file, classpaths): - args = ["--output", output_file] - if self.debug: - args.append("--debug") - if self.get_options().full_opt: - args.append("--fullOpt") - if self.get_options().check_ir: - args.append("--checkIR") - - # NB: We give the linker the entire classpath for this target, and let it check validity. - args.extend(jar for _, jar in classpaths.get_for_targets(target.closure(bfs=True))) - - result = self.runjava( - classpath=self.tool_classpath("scala-js-cli"), - main=self._SCALA_JS_CLI_MAIN, - jvm_options=self.get_options().jvm_options, - args=args, - workunit_name="scala-js-link", - ) - - # TODO: scopt doesn't exit(1) when it receives an invalid option, but in all cases here - # that should be caused by a task-implementation error rather than a user error. - if result != 0: - raise TaskError( - "java {main} ... exited non-zero ({result}) for {target}".format( - main=self._SCALA_JS_CLI_MAIN, result=result, target=target.address.spec - ), - failed_targets=[target], - ) - if not os.path.exists(output_file): - raise TaskError( - "java {main} ... failed to produce an output for {target}".format( - main=self._SCALA_JS_CLI_MAIN, target=target.address.spec - ), - failed_targets=[target], - ) diff --git a/contrib/scalajs/src/python/pants/contrib/scalajs/tasks/scala_js_zinc_compile.py b/contrib/scalajs/src/python/pants/contrib/scalajs/tasks/scala_js_zinc_compile.py deleted file mode 100644 index a937ce2d5a0..00000000000 --- a/contrib/scalajs/src/python/pants/contrib/scalajs/tasks/scala_js_zinc_compile.py +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.backend.jvm.tasks.jvm_compile.zinc.zinc_compile import BaseZincCompile -from pants.util.memo import memoized_method - -from pants.contrib.scalajs.targets.scala_js_target import ScalaJSTarget - - -class ScalaJSZincCompile(BaseZincCompile): - """Compile scala source code to an scala.js representation, ready to be linked.""" - - _name = "scala-js" - _file_suffix = ".scala" - # TODO: Although this task does not extend rsc, it's currently necessary to claim to in order - # to not be skipped by the JvmPlatform setting. When the deprecation of the concrete instance of - # `ZincCompile` completes, we can merge a few classes. - compiler_name = "rsc" - - scalac_plugins = ["scalajs"] - - @classmethod - def register_options(cls, register): - super().register_options(register) - # TODO: revisit after https://rbcommons.com/s/twitter/r/3225/ - cls.register_jvm_tool(register, "scala-js-compiler") - - @classmethod - def product_types(cls): - return ["scala_js_ir"] - - @memoized_method - def scalac_plugin_classpath_elements(self): - return self.tool_classpath("scala-js-compiler") - - def select(self, target): - if not isinstance(target, ScalaJSTarget): - return False - return target.has_sources(self._file_suffix) - - def select_source(self, source_file_path): - return source_file_path.endswith(self._file_suffix) diff --git a/contrib/scalajs/tests/python/pants_test/__init__.py b/contrib/scalajs/tests/python/pants_test/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/scalajs/tests/python/pants_test/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/scalajs/tests/python/pants_test/contrib/__init__.py b/contrib/scalajs/tests/python/pants_test/contrib/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/scalajs/tests/python/pants_test/contrib/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/scalajs/tests/python/pants_test/contrib/scalajs/__init__.py b/contrib/scalajs/tests/python/pants_test/contrib/scalajs/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/scalajs/tests/python/pants_test/contrib/scalajs/tasks/BUILD b/contrib/scalajs/tests/python/pants_test/contrib/scalajs/tasks/BUILD deleted file mode 100644 index 88c73b00a47..00000000000 --- a/contrib/scalajs/tests/python/pants_test/contrib/scalajs/tasks/BUILD +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_tests( - name='scalajs_repl_integration', - sources=['test_scalajs_repl_integration.py'], - dependencies=[ - 'src/python/pants/testutil:int-test', - 'contrib/scalajs:examples_directory', - ], - tags={'integration', 'partially_type_checked'}, - timeout=270, -) diff --git a/contrib/scalajs/tests/python/pants_test/contrib/scalajs/tasks/__init__.py b/contrib/scalajs/tests/python/pants_test/contrib/scalajs/tasks/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/scalajs/tests/python/pants_test/contrib/scalajs/tasks/test_scalajs_repl_integration.py b/contrib/scalajs/tests/python/pants_test/contrib/scalajs/tasks/test_scalajs_repl_integration.py deleted file mode 100644 index d31b2e384aa..00000000000 --- a/contrib/scalajs/tests/python/pants_test/contrib/scalajs/tasks/test_scalajs_repl_integration.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from textwrap import dedent - -from pants.testutil.pants_run_integration_test import PantsRunIntegrationTest - - -class ScalaJSReplIntegrationTest(PantsRunIntegrationTest): - def setUp(self): - self.maxDiff = None - - def test_run_repl(self): - command = [ - "-q", - "repl", - "contrib/scalajs/examples/src/scala/org/pantsbuild/scalajs/example/factfinder", - ] - program = dedent( - """ - var _ = require('factfinder'); - var tenFactorial = org.pantsbuild.scalajs.example.factfinder.Factfinder().fact(10); - console.log(tenFactorial) - """ - ).encode() - pants_run = self.run_pants(command=command, stdin_data=program) - - self.assert_success(pants_run) - self.assertEqual("3628800", pants_run.stdout_data.strip()) diff --git a/contrib/scalajs/tests/scala/org/pantsbuild/scalajs/example/factfinder/BUILD b/contrib/scalajs/tests/scala/org/pantsbuild/scalajs/example/factfinder/BUILD deleted file mode 100644 index 97bc48a5aef..00000000000 --- a/contrib/scalajs/tests/scala/org/pantsbuild/scalajs/example/factfinder/BUILD +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -junit_tests( - dependencies=[ - '3rdparty:guava', - '3rdparty:junit', - '3rdparty:scalatest', - 'contrib/scalajs/examples/src/scala/org/pantsbuild/scalajs/example/factfinder', - ], -) diff --git a/contrib/scalajs/tests/scala/org/pantsbuild/scalajs/example/factfinder/FactfinderSpec.scala b/contrib/scalajs/tests/scala/org/pantsbuild/scalajs/example/factfinder/FactfinderSpec.scala deleted file mode 100644 index ec98f628ad4..00000000000 --- a/contrib/scalajs/tests/scala/org/pantsbuild/scalajs/example/factfinder/FactfinderSpec.scala +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). -// Licensed under the Apache License, Version 2.0 (see LICENSE). - -package org.pantsbuild.scalajs.example.factfinder - -import org.junit.runner.RunWith -import org.scalatest.MustMatchers -import org.scalatest.WordSpec -import org.scalatest.junit.JUnitRunner - -import com.google.common.base.Charsets -import com.google.common.io.Resources - -@RunWith(classOf[JUnitRunner]) -class FactfinderSpec extends WordSpec with MustMatchers { - "Factfinder" should { - "be available on the classpath" in { - val factfinderURL = Resources.getResource("factfinder.js") - factfinderURL must not equal(null) - Resources.toString(factfinderURL, Charsets.UTF_8).nonEmpty must equal(true) - } - } -} diff --git a/contrib/thrifty/src/python/pants/__init__.py b/contrib/thrifty/src/python/pants/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/thrifty/src/python/pants/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/thrifty/src/python/pants/contrib/__init__.py b/contrib/thrifty/src/python/pants/contrib/__init__.py deleted file mode 100644 index 5284146ebf2..00000000000 --- a/contrib/thrifty/src/python/pants/contrib/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/contrib/thrifty/src/python/pants/contrib/thrifty/BUILD b/contrib/thrifty/src/python/pants/contrib/thrifty/BUILD deleted file mode 100644 index 80721cbfb0b..00000000000 --- a/contrib/thrifty/src/python/pants/contrib/thrifty/BUILD +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_library( - sources=['java_thrifty_gen.py', 'java_thrifty_library.py', 'target_types.py'], - dependencies=[ - "src/python/pants/backend/jvm:target_types", - "src/python/pants/engine:target", - ], - tags={"partially_type_checked"}, -) - -contrib_plugin( - name='plugin', - dependencies=[ - ':thrifty', - 'src/python/pants/goal:task_registrar', - ], - tags = {"partially_type_checked"}, - distribution_name='pantsbuild.pants.contrib.thrifty', - description='Microsoft Thrifty thrift generator pants plugins (deprecated).', - additional_classifiers=[ - 'Topic :: Software Development :: Code Generators' - ], - register_goals=True, - build_file_aliases=True, -) diff --git a/contrib/thrifty/src/python/pants/contrib/thrifty/__init__.py b/contrib/thrifty/src/python/pants/contrib/thrifty/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/contrib/thrifty/src/python/pants/contrib/thrifty/java_thrifty_gen.py b/contrib/thrifty/src/python/pants/contrib/thrifty/java_thrifty_gen.py deleted file mode 100644 index 73ef6294e5d..00000000000 --- a/contrib/thrifty/src/python/pants/contrib/thrifty/java_thrifty_gen.py +++ /dev/null @@ -1,89 +0,0 @@ -# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -import os - -from pants.backend.jvm.targets.java_library import JavaLibrary -from pants.backend.jvm.tasks.nailgun_task import NailgunTaskBase -from pants.base.build_environment import get_buildroot -from pants.base.exceptions import TaskError -from pants.base.workunit import WorkUnitLabel -from pants.java.jar.jar_dependency import JarDependency -from pants.task.simple_codegen_task import SimpleCodegenTask -from pants.util.ordered_set import OrderedSet - -from pants.contrib.thrifty.java_thrifty_library import JavaThriftyLibrary - - -class JavaThriftyGen(NailgunTaskBase, SimpleCodegenTask): - - gentarget_type = JavaThriftyLibrary - - sources_globs = ("**/*",) - - @classmethod - def register_options(cls, register): - super().register_options(register) - - def thrifty_jar(name): - return JarDependency(org="com.microsoft.thrifty", name=name, rev="0.4.3") - - cls.register_jvm_tool( - register, "thrifty-runtime", classpath=[thrifty_jar(name="thrifty-runtime")] - ) - cls.register_jvm_tool( - register, "thrifty-compiler", classpath=[thrifty_jar(name="thrifty-compiler")] - ) - - def synthetic_target_type(self, target): - return JavaLibrary - - def synthetic_target_extra_dependencies(self, target, target_workdir): - deps = OrderedSet(self.resolve_deps([self.get_options().thrifty_runtime])) - deps.update(target.dependencies) - return deps - - def synthetic_target_extra_exports(self, target, target_workdir): - return self.resolve_deps([self.get_options().thrifty_runtime]) - - def format_args_for_target(self, target, target_workdir): - sources = OrderedSet(target.sources_relative_to_buildroot()) - args = [f"--out={target_workdir}"] - for include_path in self._compute_include_paths(target): - args.append(f"--path={include_path}") - args.extend(sources) - return args - - def execute_codegen(self, target, target_workdir): - args = self.format_args_for_target(target, target_workdir) - if args: - result = self.runjava( - classpath=self.tool_classpath("thrifty-compiler"), - main="com.microsoft.thrifty.compiler.ThriftyCompiler", - args=args, - workunit_name="compile", - workunit_labels=[WorkUnitLabel.TOOL], - ) - if result != 0: - raise TaskError(f"Thrifty compiler exited non-zero ({result})") - - def _compute_include_paths(self, target): - """Computes the set of paths that thrifty uses to lookup imports. - - The IDL files under these paths are not compiled, but they are required to compile - downstream IDL files. - - :param target: the JavaThriftyLibrary target to compile. - :return: an ordered set of directories to pass along to thrifty. - """ - paths = OrderedSet() - paths.add(os.path.join(get_buildroot(), target.target_base)) - - def collect_paths(dep): - if not dep.has_sources(".thrift"): - return - paths.add(os.path.join(get_buildroot(), dep.target_base)) - - collect_paths(target) - target.walk(collect_paths) - return paths diff --git a/contrib/thrifty/src/python/pants/contrib/thrifty/java_thrifty_library.py b/contrib/thrifty/src/python/pants/contrib/thrifty/java_thrifty_library.py deleted file mode 100644 index 277aad57a94..00000000000 --- a/contrib/thrifty/src/python/pants/contrib/thrifty/java_thrifty_library.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.backend.jvm.targets.jvm_target import JvmTarget - - -class JavaThriftyLibrary(JvmTarget): - """An Android-optimized Java library generated by the Microsoft Thrifty thrift compiler. - - Says Thrifty, "Thrifty is an implementation of the Apache Thrift software stack for Android, - which uses 1/4 of the method count taken by the Apache Thrift compiler." - - For details, see https://github.com/Microsoft/thrifty - """ - - default_sources_globs = "*.thrift" diff --git a/contrib/thrifty/src/python/pants/contrib/thrifty/register.py b/contrib/thrifty/src/python/pants/contrib/thrifty/register.py deleted file mode 100644 index 68af9f7891f..00000000000 --- a/contrib/thrifty/src/python/pants/contrib/thrifty/register.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -"""Thrift code generator for Android (deprecated). - -See https://github.com/microsoft/thrifty. -""" - -from pants.base.deprecated import _deprecated_contrib_plugin -from pants.build_graph.build_file_aliases import BuildFileAliases -from pants.goal.task_registrar import TaskRegistrar as task - -from pants.contrib.thrifty.java_thrifty_gen import JavaThriftyGen -from pants.contrib.thrifty.java_thrifty_library import JavaThriftyLibrary as JavaThriftyLibraryV1 -from pants.contrib.thrifty.target_types import JavaThriftyLibrary - -_deprecated_contrib_plugin("pantsbuild.pants.contrib.thrifty") - - -def build_file_aliases(): - return BuildFileAliases(targets={"java_thrifty_library": JavaThriftyLibraryV1}) - - -def register_goals(): - task(name="thrifty", action=JavaThriftyGen).install("gen") - - -def target_types(): - return [JavaThriftyLibrary] diff --git a/contrib/thrifty/src/python/pants/contrib/thrifty/target_types.py b/contrib/thrifty/src/python/pants/contrib/thrifty/target_types.py deleted file mode 100644 index aee97607fb5..00000000000 --- a/contrib/thrifty/src/python/pants/contrib/thrifty/target_types.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.backend.jvm.target_types import COMMON_JVM_FIELDS -from pants.engine.target import Sources, Target - - -class JavaThriftySources(Sources): - default = ("*.thrift",) - - -class JavaThriftyLibrary(Target): - """An Android-optimized Java library generated by the Microsoft Thrifty thrift compiler.""" - - alias = "java_thrifty_library" - core_fields = (*COMMON_JVM_FIELDS, JavaThriftySources) - v1_only = True diff --git a/contrib/thrifty/tests/java/org/pantsbuild/contrib/thrifty/BUILD b/contrib/thrifty/tests/java/org/pantsbuild/contrib/thrifty/BUILD deleted file mode 100644 index b46a2efa34b..00000000000 --- a/contrib/thrifty/tests/java/org/pantsbuild/contrib/thrifty/BUILD +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -junit_tests( - dependencies=[ - 'contrib/thrifty/tests/thrift/org/pantsbuild/contrib/thrifty/client', - 'contrib/thrifty/tests/thrift/org/pantsbuild/contrib/thrifty/common', - ], -) diff --git a/contrib/thrifty/tests/java/org/pantsbuild/contrib/thrifty/ThriftyStructTest.java b/contrib/thrifty/tests/java/org/pantsbuild/contrib/thrifty/ThriftyStructTest.java deleted file mode 100644 index f277271f0d4..00000000000 --- a/contrib/thrifty/tests/java/org/pantsbuild/contrib/thrifty/ThriftyStructTest.java +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). -// Licensed under the Apache License, Version 2.0 (see LICENSE). - -package org.pantsbuild.contrib.thrifty; - -import org.junit.Test; -import org.pantsbuild.contrib.thrifty.common.ClientLog; -import org.pantsbuild.contrib.thrifty.common.Common; - -import static org.junit.Assert.assertEquals; - -public class ThriftyStructTest { - - @Test - public void testThriftyStruct() { - Common common = new Common.Builder() - .timestamp(1L) - .hostname("fake") - .build(); - ClientLog clientLog = new ClientLog.Builder() - .common(common) - .message("fake_message") - .build(); - assertEquals(clientLog.toString(), - "ClientLog{common=Common{timestamp=1, hostname=fake}, message=fake_message}"); - } -} diff --git a/contrib/thrifty/tests/python/pants_test/pants/contrib/thrifty/BUILD b/contrib/thrifty/tests/python/pants_test/pants/contrib/thrifty/BUILD deleted file mode 100644 index 2e123cc910c..00000000000 --- a/contrib/thrifty/tests/python/pants_test/pants/contrib/thrifty/BUILD +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -python_tests( - dependencies=[ - 'contrib/thrifty/src/python/pants/contrib/thrifty', - 'src/python/pants/testutil:task_test_base', - ], - tags = {'partially_type_checked'}, -) diff --git a/contrib/thrifty/tests/python/pants_test/pants/contrib/thrifty/test_thrifty_gen.py b/contrib/thrifty/tests/python/pants_test/pants/contrib/thrifty/test_thrifty_gen.py deleted file mode 100644 index e3c21cb8fc2..00000000000 --- a/contrib/thrifty/tests/python/pants_test/pants/contrib/thrifty/test_thrifty_gen.py +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.backend.jvm.targets.jar_library import JarLibrary -from pants.build_graph.register import build_file_aliases as register_core -from pants.java.jar.jar_dependency import JarDependency -from pants.testutil.task_test_base import TaskTestBase - -from pants.contrib.thrifty.java_thrifty_gen import JavaThriftyGen -from pants.contrib.thrifty.java_thrifty_library import JavaThriftyLibrary - - -class JavaThriftyGenTest(TaskTestBase): - TARGET_WORKDIR = ".pants.d/bogus/workdir" - - @classmethod - def task_type(cls): - return JavaThriftyGen - - @classmethod - def alias_groups(cls): - return register_core() - - def _create_fake_thrifty_tool(self): - self.make_target( - ":thrifty-compiler", - JarLibrary, - jars=[ - JarDependency(org="com.microsoft.thrifty", name="thrifty-compiler", rev="0.4.3"), - ], - ) - - def test_compiler_args(self): - self._create_fake_thrifty_tool() - target = self.make_target( - "src/thrifty:simple-thrifty-target", JavaThriftyLibrary, sources=["foo.thrift"] - ) - context = self.context(target_roots=[target]) - task = self.create_task(context) - self.assertEqual( - [ - f"--out={self.TARGET_WORKDIR}", - f"--path={self.build_root}/src/thrifty", - "src/thrifty/foo.thrift", - ], - task.format_args_for_target(target, self.TARGET_WORKDIR), - ) - - def test_compiler_args_deps(self): - self._create_fake_thrifty_tool() - upstream = self.make_target( - "src/thrifty:upstream", JavaThriftyLibrary, sources=["upstream.thrift"] - ) - downstream = self.make_target( - "src/thrifty:downstream", - JavaThriftyLibrary, - sources=["downstream.thrift"], - dependencies=[upstream], - ) - context = self.context(target_roots=[upstream, downstream]) - task = self.create_task(context) - self.assertEqual( - [ - f"--out={self.TARGET_WORKDIR}", - f"--path={self.build_root}/src/thrifty", - "src/thrifty/downstream.thrift", - ], - task.format_args_for_target(downstream, self.TARGET_WORKDIR), - ) diff --git a/contrib/thrifty/tests/thrift/org/pantsbuild/contrib/thrifty/client/BUILD b/contrib/thrifty/tests/thrift/org/pantsbuild/contrib/thrifty/client/BUILD deleted file mode 100644 index 689dd02469f..00000000000 --- a/contrib/thrifty/tests/thrift/org/pantsbuild/contrib/thrifty/client/BUILD +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -java_thrifty_library( - dependencies=[ - 'contrib/thrifty/tests/thrift/org/pantsbuild/contrib/thrifty/common', - ], -) diff --git a/contrib/thrifty/tests/thrift/org/pantsbuild/contrib/thrifty/client/clientlog.thrift b/contrib/thrifty/tests/thrift/org/pantsbuild/contrib/thrifty/client/clientlog.thrift deleted file mode 100644 index 3f88d457b05..00000000000 --- a/contrib/thrifty/tests/thrift/org/pantsbuild/contrib/thrifty/client/clientlog.thrift +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). -// Licensed under the Apache License, Version 2.0 (see LICENSE). - -namespace java org.pantsbuild.contrib.thrifty.common - -include "org/pantsbuild/contrib/thrifty/common/common.thrift" - -struct ClientLog { - 1: common.Common common; - 2: string message; -} diff --git a/contrib/thrifty/tests/thrift/org/pantsbuild/contrib/thrifty/common/BUILD b/contrib/thrifty/tests/thrift/org/pantsbuild/contrib/thrifty/common/BUILD deleted file mode 100644 index 20b78606599..00000000000 --- a/contrib/thrifty/tests/thrift/org/pantsbuild/contrib/thrifty/common/BUILD +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -java_thrifty_library() diff --git a/contrib/thrifty/tests/thrift/org/pantsbuild/contrib/thrifty/common/common.thrift b/contrib/thrifty/tests/thrift/org/pantsbuild/contrib/thrifty/common/common.thrift deleted file mode 100644 index 9d0b18ced02..00000000000 --- a/contrib/thrifty/tests/thrift/org/pantsbuild/contrib/thrifty/common/common.thrift +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). -// Licensed under the Apache License, Version 2.0 (see LICENSE). - -namespace java org.pantsbuild.contrib.thrifty.common - -struct Common { - 1: optional i64 timestamp - 2: required string hostname; -} diff --git a/examples/src/scala/org/pantsbuild/example/fact/BUILD b/examples/src/scala/org/pantsbuild/example/fact/BUILD index 09b7d14687f..447e635da6c 100644 --- a/examples/src/scala/org/pantsbuild/example/fact/BUILD +++ b/examples/src/scala/org/pantsbuild/example/fact/BUILD @@ -3,6 +3,3 @@ # A pure scala library, with no Java or 3rdparty dependencies. scala_library() -scala_js_library(name='fact-js', - sources=['*.scala'], -) diff --git a/pants.toml b/pants.toml index 5661d1be463..eb16e7188bb 100644 --- a/pants.toml +++ b/pants.toml @@ -23,40 +23,24 @@ v2 = false # Enable our own custom loose-source plugins as well as contribs. pythonpath = [ - "%(buildroot)s/contrib/avro/src/python", "%(buildroot)s/contrib/awslambda/python/src/python", "%(buildroot)s/contrib/buildrefactor/src/python", "%(buildroot)s/contrib/codeanalysis/src/python", - "%(buildroot)s/contrib/cpp/src/python", "%(buildroot)s/contrib/confluence/src/python", - "%(buildroot)s/contrib/errorprone/src/python", - "%(buildroot)s/contrib/findbugs/src/python", "%(buildroot)s/contrib/go/src/python", - "%(buildroot)s/contrib/googlejavaformat/src/python", - "%(buildroot)s/contrib/jax_ws/src/python", "%(buildroot)s/contrib/mypy/src/python", "%(buildroot)s/contrib/node/src/python", - "%(buildroot)s/contrib/scalajs/src/python", "%(buildroot)s/contrib/scrooge/src/python", - "%(buildroot)s/contrib/thrifty/src/python", "%(buildroot)s/pants-plugins/src/python", ] backend_packages.add = [ "pants.backend.docgen", - "pants.contrib.avro", "pants.contrib.buildrefactor", "pants.contrib.codeanalysis", - "pants.contrib.cpp", "pants.contrib.confluence", - "pants.contrib.errorprone", - "pants.contrib.findbugs", "pants.contrib.go", - "pants.contrib.googlejavaformat", - "pants.contrib.jax_ws", - "pants.contrib.scalajs", "pants.contrib.node", "pants.contrib.scrooge", - "pants.contrib.thrifty", "internal_backend.repositories", "internal_backend.sitegen", "internal_backend.utilities", @@ -75,9 +59,6 @@ backend_packages2.add = [ "pants.backend.python.lint.isort", "internal_backend.rules_for_testing", ] -ignore_pants_warnings = [ - "DEPRECATED: the pantsbuild.pants.contrib", -] # The invalidation globs cover the PYTHONPATH by default, but we additionally add the rust code. pantsd_invalidation_globs.add = [ @@ -192,31 +173,9 @@ deps = ["3rdparty:thrift"] [gen.thrift-py] deps = ["examples/3rdparty/python:thrift"] -[gen.thrifty] -allow_dups = true - [gen.go-protobuf] import_target = "contrib/go/examples/src/protobuf/org/pantsbuild/example:protobuf-deps" -[compile.errorprone] -command_line_options = [ - # See http://errorprone.info/bugpatterns for all patterns - '-Xep:CatchAndPrintStackTrace:OFF', - '-Xep:StringSplitter:OFF', -] -exclude_patterns = [ - 'contrib/errorprone/tests/java/org/pantsbuild/contrib/errorprone:error', - 'testprojects/src/java/org/pantsbuild/testproject/.*' -] - -[compile.findbugs] -max_rank = 4 -fail_on_error = true -exclude_patterns = [ - 'contrib/findbugs/tests/java/org/pantsbuild/contrib/findbugs:high', - 'testprojects/src/java/org/pantsbuild/testproject/.*', -] - [compile.rsc] jvm_options = ['-Xmx4g', '-XX:+UseConcMarkSweepGC', '-XX:ParallelGCThreads=4'] args = [ @@ -276,9 +235,6 @@ ignore = "%(pants_supportdir)s/eslint/.eslintignore" config = "build-support/flake8/.flake8" extra_requirements.add = ["flake8-pantsbuild>=2.0,<3"] -[google-java-format] -skip = true - [isort] config = [".isort.cfg", "contrib/.isort.cfg", "examples/.isort.cfg"] diff --git a/src/python/pants/base/deprecated.py b/src/python/pants/base/deprecated.py index 5787a4d9976..b3aaf190f90 100644 --- a/src/python/pants/base/deprecated.py +++ b/src/python/pants/base/deprecated.py @@ -328,16 +328,3 @@ def format_option(*, scope: str, option: str) -> str: if old_configured: return old_container.get(old_option) return new_container.get(new_option) - - -def _deprecated_contrib_plugin(plugin_name: str) -> None: - warn_or_error( - removal_version="1.29.0.dev0", - deprecated_entity_description=f"the {plugin_name} plugin", - hint=( - f"The {repr(plugin_name)} plugin is being removed due to low usage.\n\nTo prepare for " - f"this change, please remove {repr(plugin_name)} from 'plugins' in `pants.toml` or " - "`pants.ini`.\n\nIf you still depend on this plugin, please email pants-devel " - " or message us on Slack and we will keep this plugin." - ), - ) diff --git a/src/python/pants/releases/packages.py b/src/python/pants/releases/packages.py index dca2e4ec1a5..742b016b3c0 100644 --- a/src/python/pants/releases/packages.py +++ b/src/python/pants/releases/packages.py @@ -104,10 +104,6 @@ def contrib_packages(): "pantsbuild.pants.contrib.node", "//contrib/node/src/python/pants/contrib/node:plugin", ), - Package( - "pantsbuild.pants.contrib.scalajs", - "//contrib/scalajs/src/python/pants/contrib/scalajs:plugin", - ), Package( "pantsbuild.pants.contrib.python.checks", "//contrib/python/src/python/pants/contrib/python/checks:plugin", @@ -117,46 +113,18 @@ def contrib_packages(): "//contrib/python/src/python/pants/contrib/python/checks/checker", bdist_wheel_flags=("--universal",), ), - Package( - "pantsbuild.pants.contrib.findbugs", - "//contrib/findbugs/src/python/pants/contrib/findbugs:plugin", - ), - Package( - "pantsbuild.pants.contrib.cpp", - "//contrib/cpp/src/python/pants/contrib/cpp:plugin", - ), Package( "pantsbuild.pants.contrib.confluence", "//contrib/confluence/src/python/pants/contrib/confluence:plugin", ), - Package( - "pantsbuild.pants.contrib.errorprone", - "//contrib/errorprone/src/python/pants/contrib/errorprone:plugin", - ), Package( "pantsbuild.pants.contrib.codeanalysis", "//contrib/codeanalysis/src/python/pants/contrib/codeanalysis:plugin", ), - Package( - "pantsbuild.pants.contrib.jax_ws", - "//contrib/jax_ws/src/python/pants/contrib/jax_ws:plugin", - ), Package( "pantsbuild.pants.contrib.mypy", "//contrib/mypy/src/python/pants/contrib/mypy:plugin", ), - Package( - "pantsbuild.pants.contrib.avro", - "//contrib/avro/src/python/pants/contrib/avro:plugin", - ), - Package( - "pantsbuild.pants.contrib.thrifty", - "//contrib/thrifty/src/python/pants/contrib/thrifty:plugin", - ), - Package( - "pantsbuild.pants.contrib.googlejavaformat", - "//contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat:plugin", - ), Package( "pantsbuild.pants.contrib.awslambda_python", "//contrib/awslambda/python/src/python/pants/contrib/awslambda/python:plugin", diff --git a/src/python/pants/testutil/pants_run_integration_test.py b/src/python/pants/testutil/pants_run_integration_test.py index 19cebb586e1..7545a0af694 100644 --- a/src/python/pants/testutil/pants_run_integration_test.py +++ b/src/python/pants/testutil/pants_run_integration_test.py @@ -624,7 +624,7 @@ class Manager: "rust-toolchain", "src", ) - dirs_to_copy = ("3rdparty", "contrib") + tuple(dirs_to_copy or []) + dirs_to_copy = ("3rdparty", *(dirs_to_copy or [])) with self.temporary_workdir() as tmp_dir: for filename in files_to_copy: diff --git a/tests/python/pants_test/backend/jvm/tasks/test_checkstyle_integration.py b/tests/python/pants_test/backend/jvm/tasks/test_checkstyle_integration.py index 12c653b9461..8cdca61543d 100644 --- a/tests/python/pants_test/backend/jvm/tasks/test_checkstyle_integration.py +++ b/tests/python/pants_test/backend/jvm/tasks/test_checkstyle_integration.py @@ -100,15 +100,7 @@ def _temporary_buildroot(self, files_to_copy, current_root=None): f for f in os.listdir(current_root) if f.endswith(".toml") or f.startswith("BUILD") ) files_to_copy.update( - ( - "pants", - "3rdparty", - "build-support", - "contrib", - "src", - ".isort.cfg", - "pyproject.toml", - ) + ("pants", "3rdparty", "build-support", "src", ".isort.cfg", "pyproject.toml") ) with temporary_dir() as temp_root: temp_root = os.path.normpath(temp_root)