├── .bazelci └── presubmit.yml ├── .bazelignore ├── .bazelrc ├── .bazelversion ├── .bcr ├── README.md ├── metadata.template.json ├── presubmit.yml └── source.template.json ├── .github ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── publish-to-bcr.yml │ ├── release.yml │ └── release_prep.sh ├── .gitignore ├── .markdownlint.json ├── .scalafmt.conf ├── AUTHORS ├── BUILD ├── CODEOWNERS ├── CONTRIBUTING.md ├── CONTRIBUTORS ├── Governance.md ├── LICENSE.txt ├── MODULE.bazel ├── README.md ├── WORKSPACE ├── dangerous_test_thirdparty_version.sh ├── deps ├── latest │ └── MODULE.bazel └── test │ ├── BUILD.bazel.test │ ├── HelloLib.scala │ ├── MODULE.bazel.template │ ├── ScalaBinary.scala │ └── defs.bzl ├── docs ├── coverage.md ├── cross-compilation.md ├── customizable_phase.md ├── dependency-tracking.md ├── phase_scalafmt.md ├── publish_to_maven.md ├── scala_binary.md ├── scala_doc.md ├── scala_import.md ├── scala_library.md ├── scala_library_suite.md ├── scala_macro_library.md ├── scala_proto_library.md ├── scala_repl.md ├── scala_test.md ├── scala_test_suite.md ├── scala_toolchain.md ├── testing.md ├── thrift_library.md └── toolchain_development.md ├── dt_patches ├── BUILD ├── compiler_sources │ ├── .bazelrc │ ├── .bazelversion │ ├── BUILD │ ├── MODULE.bazel │ ├── WORKSPACE │ └── extensions.bzl ├── dt_compiler_2.11.patch ├── dt_compiler_2.12.1.patch ├── dt_compiler_2.12.8.patch ├── dt_compiler_2.12.patch ├── dt_compiler_2.13.patch ├── dt_compiler_3.patch ├── dt_patch_test.sh ├── test_dt_patches │ ├── .bazelrc │ ├── .bazelversion │ ├── BUILD │ ├── MODULE.bazel │ ├── WORKSPACE │ ├── dummy │ │ ├── BUILD │ │ └── Dummy.scala │ └── protobuf.patch └── test_dt_patches_user_srcjar │ ├── .bazelrc │ ├── .bazelversion │ ├── BUILD │ ├── MODULE.bazel │ ├── WORKSPACE │ ├── dummy │ ├── BUILD │ └── Dummy.scala │ ├── extensions.bzl │ └── protobuf.patch ├── examples ├── crossbuild │ ├── .bazelrc │ ├── .bazelversion │ ├── 1_single │ │ ├── BUILD │ │ ├── bin.scala │ │ ├── lib.scala │ │ └── test.scala │ ├── 2_deps │ │ ├── BUILD │ │ ├── bin.scala │ │ ├── lib.scala │ │ └── lib_default.scala │ ├── 3_select │ │ ├── BUILD │ │ ├── bin.scala │ │ ├── lib2.scala │ │ └── lib3.scala │ ├── BUILD │ ├── MODULE.bazel │ ├── WORKSPACE │ └── protobuf.patch ├── overridden_artifacts │ ├── .bazelrc │ ├── .bazelversion │ ├── BUILD │ ├── Hello.scala │ ├── HelloTest.scala │ ├── MODULE.bazel │ ├── WORKSPACE │ └── protobuf.patch ├── scala3 │ ├── .bazelrc │ ├── .bazelversion │ ├── BUILD │ ├── Hello.scala │ ├── MODULE.bazel │ ├── Main.scala │ ├── WORKSPACE │ └── protobuf.patch ├── semanticdb │ ├── .bazelrc │ ├── .bazelversion │ ├── BUILD │ ├── Foo.scala │ ├── MODULE.bazel │ ├── Main.scala │ ├── README.md │ ├── WORKSPACE │ ├── aspect.bzl │ └── protobuf.patch └── testing │ ├── multi_frameworks_toolchain │ ├── .bazelrc │ ├── .bazelversion │ ├── BUILD │ ├── MODULE.bazel │ ├── WORKSPACE │ ├── example │ │ ├── BUILD │ │ ├── ScalaTestExampleTest.scala │ │ └── Specs2ExampleTest.scala │ └── protobuf.patch │ ├── scalatest_repositories │ ├── .bazelrc │ ├── .bazelversion │ ├── BUILD │ ├── MODULE.bazel │ ├── WORKSPACE │ ├── example │ │ ├── BUILD │ │ └── ExampleTest.scala │ └── protobuf.patch │ └── specs2_junit_repositories │ ├── .bazelrc │ ├── .bazelversion │ ├── BUILD │ ├── MODULE.bazel │ ├── WORKSPACE │ ├── example │ ├── BUILD │ └── Specs2ExampleTest.scala │ └── protobuf.patch ├── java_stub_template └── file │ ├── BUILD.bazel │ └── file.txt ├── jmh ├── BUILD ├── jmh.bzl └── toolchain │ ├── BUILD │ └── toolchain.bzl ├── junit ├── BUILD └── junit.bzl ├── lint.sh ├── manual_test ├── README.md ├── coverage_local_jacocorunner │ ├── BUILD │ ├── expected-coverage.dat │ └── test.sh ├── scala_test_jacocorunner │ ├── BUILD │ └── EmptyTest.scala ├── scala_test_jvm_flags │ ├── BUILD │ └── EmptyTest.scala └── scalac_jvm_opts │ ├── BUILD │ ├── Empty.scala │ └── test.proto ├── protoc ├── 0001-protobuf-19679-rm-protoc-dep.patch ├── BUILD ├── private │ ├── protoc_integrity.bzl │ ├── protoc_toolchains.bzl │ └── toolchain_impl.bzl └── toolchains.bzl ├── scala ├── BUILD ├── PlaceHolderClassToCreateEmptyJarForScalaImport.java ├── advanced_usage │ ├── providers.bzl │ └── scala.bzl ├── deps.bzl ├── extensions │ ├── BUILD │ ├── config.bzl │ ├── deps.bzl │ └── protoc.bzl ├── jars_to_labels.bzl ├── latest_deps.bzl ├── plusone.bzl ├── private │ ├── BUILD │ ├── common.bzl │ ├── common_attributes.bzl │ ├── common_outputs.bzl │ ├── coverage_replacements_provider.bzl │ ├── dependency.bzl │ ├── extensions │ │ ├── BUILD │ │ └── dev_deps.bzl │ ├── macros │ │ ├── bzlmod.bzl │ │ ├── scala_repositories.bzl │ │ ├── setup_scala_toolchain.bzl │ │ └── test │ │ │ ├── BUILD.bzlmod_test │ │ │ ├── MODULE.bzlmod_test │ │ │ ├── MODULE.bzlmod_test_root_module │ │ │ └── bzlmod_test_ext.bzl │ ├── paths.bzl │ ├── phases │ │ ├── api.bzl │ │ ├── phase_collect_exports_jars.bzl │ │ ├── phase_collect_jars.bzl │ │ ├── phase_collect_srcjars.bzl │ │ ├── phase_compile.bzl │ │ ├── phase_coverage.bzl │ │ ├── phase_coverage_runfiles.bzl │ │ ├── phase_declare_executable.bzl │ │ ├── phase_default_info.bzl │ │ ├── phase_dependency.bzl │ │ ├── phase_java_wrapper.bzl │ │ ├── phase_jvm_flags.bzl │ │ ├── phase_merge_jars.bzl │ │ ├── phase_runfiles.bzl │ │ ├── phase_scalac_provider.bzl │ │ ├── phase_scalacopts.bzl │ │ ├── phase_scalafmt.bzl │ │ ├── phase_scalainfo_provider.bzl │ │ ├── phase_semanticdb.bzl │ │ ├── phase_test_environment.bzl │ │ ├── phase_write_executable.bzl │ │ ├── phase_write_manifest.bzl │ │ └── phases.bzl │ ├── resources.bzl │ ├── rule_impls.bzl │ ├── rules │ │ ├── scala_binary.bzl │ │ ├── scala_doc.bzl │ │ ├── scala_junit_test.bzl │ │ ├── scala_library.bzl │ │ ├── scala_repl.bzl │ │ └── scala_test.bzl │ ├── toolchain_defaults.bzl │ └── toolchain_deps │ │ ├── BUILD │ │ ├── toolchain_dep_rules.bzl │ │ └── toolchain_deps.bzl ├── providers.bzl ├── scala.bzl ├── scala_cross_version.bzl ├── scala_cross_version_select.bzl ├── scala_import.bzl ├── scala_maven_import_external.bzl ├── scala_toolchain.bzl ├── scalafmt │ ├── BUILD │ ├── phase_scalafmt_ext.bzl │ ├── private │ │ ├── format-test.template.sh │ │ └── format.template.sh │ ├── scalafmt │ │ ├── ScalafmtAdapter-2_11.scala │ │ ├── ScalafmtAdapter.scala │ │ └── ScalafmtWorker.scala │ ├── scalafmt_repositories.bzl │ └── toolchain │ │ ├── BUILD │ │ ├── setup_scalafmt_toolchain.bzl │ │ └── toolchain.bzl ├── scalatest │ └── BUILD ├── semanticdb_provider.bzl ├── settings │ ├── BUILD │ └── stamp_settings.bzl ├── support │ ├── BUILD │ └── JUnitXmlReporter.scala ├── toolchains.bzl ├── toolchains_repo.bzl └── unstable │ ├── BUILD │ └── defs.bzl ├── scala_config.bzl ├── scala_proto ├── BUILD ├── default │ ├── BUILD │ ├── default_deps.bzl │ └── repositories.bzl ├── private │ ├── BUILD │ ├── scala_proto.bzl │ ├── scala_proto_aspect.bzl │ ├── scala_proto_aspect_provider.bzl │ └── toolchain_deps.bzl ├── scala_proto.bzl ├── scala_proto_toolchain.bzl └── toolchains.bzl ├── scalatest ├── BUILD └── scalatest.bzl ├── scripts ├── README.md ├── build_jacocorunner │ ├── 0001-Build-Jacoco-for-Bazel-5.0.patch │ ├── 0001-Build-Jacoco-for-Bazel-6.0.patch │ ├── 0001-Build-Jacoco-for-Bazel-7.0.patch │ ├── 0001-Build-Jacoco-for-Bazel.patch │ ├── 0002-Build-Jacoco-behind-proxy.patch │ ├── build_jacocorunner.sh │ └── build_jacocorunner_bazel_4.0.sh ├── create_repository.py ├── ij.bazelproject ├── sync-bazelversion.sh └── update_protoc_integrity.py ├── specs2 ├── BUILD ├── specs2.bzl └── specs2_junit.bzl ├── src ├── java │ └── io │ │ └── bazel │ │ └── rulesscala │ │ ├── coverage │ │ └── instrumenter │ │ │ ├── BUILD │ │ │ └── JacocoInstrumenter.java │ │ ├── exe │ │ ├── BUILD │ │ ├── LaunchInfo.java │ │ └── LauncherFileWriter.java │ │ ├── io_utils │ │ ├── BUILD │ │ ├── DeleteRecursively.java │ │ └── StreamCopy.java │ │ ├── jar │ │ ├── BUILD │ │ ├── JarCreator.java │ │ └── JarHelper.java │ │ ├── preconditions │ │ ├── BUILD │ │ └── Preconditions.java │ │ ├── scala_test │ │ ├── BUILD │ │ └── Runner.java │ │ ├── scalac │ │ ├── BUILD │ │ ├── ScalacInvokerResults.java │ │ ├── ScalacWorker.java │ │ ├── compileoptions │ │ │ ├── BUILD │ │ │ ├── CompileOptions.java │ │ │ └── CompileOptionsTest.java │ │ ├── definitions.bzl │ │ ├── deps_tracking_reporter │ │ │ ├── BUILD │ │ │ ├── after_2_12_13_and_before_2_13_12 │ │ │ │ └── DepsTrackingReporter.java │ │ │ ├── after_2_13_12 │ │ │ │ └── DepsTrackingReporter.java │ │ │ ├── before_2_12_13 │ │ │ │ └── DepsTrackingReporter.java │ │ │ └── scala_3 │ │ │ │ └── DepsTrackingReporter.java │ │ ├── reporter │ │ │ ├── BUILD │ │ │ ├── after_2_12_13_and_before_2_13_12 │ │ │ │ └── ProtoReporter.java │ │ │ ├── after_2_13_12 │ │ │ │ └── ProtoReporter.java │ │ │ ├── before_2_12_13 │ │ │ │ └── ProtoReporter.java │ │ │ ├── scala_3 │ │ │ │ ├── BazelConsoleReporter.java │ │ │ │ └── ProtoReporter.java │ │ │ ├── scala_deps.proto │ │ │ ├── since_3_3 │ │ │ │ └── CompilerCompat.java │ │ │ └── since_3_before_3_3 │ │ │ │ └── CompilerCompat.java │ │ ├── scala_2 │ │ │ ├── ReportableMainClass.java │ │ │ └── ScalacInvoker.java │ │ └── scala_3 │ │ │ ├── ReportableDriver.java │ │ │ └── ScalacInvoker.java │ │ ├── specs2 │ │ ├── BUILD │ │ ├── Specs2RunnerBuilder.scala │ │ └── package.scala │ │ ├── test_discovery │ │ ├── ArchiveEntries.scala │ │ ├── BUILD │ │ ├── DiscoveredTestSuite.scala │ │ └── FilteredRunnerBuilder.scala │ │ └── worker │ │ ├── BUILD │ │ ├── Worker.java │ │ └── WorkerTest.java ├── protobuf │ └── io │ │ └── bazel │ │ └── rules_scala │ │ ├── BUILD │ │ └── diagnostics.proto └── scala │ ├── io │ └── bazel │ │ └── rules_scala │ │ ├── jmh_support │ │ ├── BUILD │ │ └── BenchmarkGenerator.scala │ │ ├── scaladoc_support │ │ └── BUILD │ │ └── scrooge_support │ │ ├── BUILD │ │ ├── Compiler.scala │ │ └── FocusedZipImporter.scala │ └── scripts │ ├── BUILD │ ├── ScalaPBWorker.scala │ ├── ScalaPbCodeGeneratorWrapper.scala │ ├── ScalaPbCodeGeneratorWrapper_2_11.scala │ └── ScroogeWorker.scala ├── test ├── A.scala ├── BUILD ├── CheckBytecodeMajorVersionTest.scala ├── D.scala ├── DataRoot1.scala ├── DataRoot2.scala ├── Exported.scala ├── HelloLib.scala ├── HelloLibTest.scala ├── HelloLibTest2.scala ├── JavaBinary.java ├── JavaUsesScalaStdLib.java ├── LibToBin.scala ├── LibToTest.scala ├── MacroTest.scala ├── OtherJavaLib.java ├── OtherLib.scala ├── Runtime.scala ├── ScalaBinary.scala ├── ScalaBinaryJdk11.scala ├── ScalaTestData.scala ├── ScalaTestResourcesFromLocalTargetTest.scala ├── SuiteUsage.scala ├── TestFilterTestA.scala ├── TestFilterTestB.scala ├── TestServer.scala ├── UnusedLib.scala ├── aspect │ ├── A.scala │ ├── B.scala │ ├── BUILD │ ├── FakeJunitTest.scala │ ├── aspect.bzl │ └── javainfo_from_aspect_test.bzl ├── check_statsfile.bzl ├── coverage_filename_encoding │ ├── A1.scala │ ├── BUILD.bazel │ ├── Test.scala │ └── expected-coverage.dat ├── coverage_scalatest │ ├── A1.scala │ ├── A2.scala │ ├── B1.scala │ ├── B2.java │ ├── BUILD │ ├── C2.scala │ ├── D1.scala │ ├── TestB2.java │ ├── TestWithScalaTest.scala │ └── expected-coverage.dat ├── coverage_scalatest_resources │ ├── consumer │ │ ├── BUILD.bazel │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── consumer │ │ │ │ └── Consumer.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── com │ │ │ └── example │ │ │ └── consumer │ │ │ └── ConsumerSpec.scala │ ├── expected-coverage.dat │ └── resource │ │ ├── BUILD.bazel │ │ └── src │ │ └── main │ │ ├── resources │ │ └── com │ │ │ └── example │ │ │ └── resource │ │ │ └── example.sql │ │ └── scala │ │ └── com │ │ └── example │ │ └── resource │ │ └── Util.scala ├── coverage_specs2_with_junit │ ├── A1.scala │ ├── A2.scala │ ├── B1.scala │ ├── B2.java │ ├── BUILD │ ├── C2.scala │ ├── D1.scala │ ├── E1.scala │ ├── TestWithSpecs2WithJUnit.scala │ └── expected-coverage.dat ├── data │ ├── BUILD │ ├── foo.txt │ ├── more.txt │ └── some.txt ├── diagnostics_reporter │ ├── BUILD │ ├── DiagnosticsReporterTest.java │ ├── DiagnosticsReporterTestCases2.java │ ├── DiagnosticsReporterTestCases3.java │ └── VerifyDiagnosticsOutput.java ├── example_jars │ ├── BUILD │ ├── expected_service_manifest.txt │ └── src │ │ └── main │ │ └── resources │ │ └── META-INF │ │ └── services │ │ └── org.apache.beam.sdk.io.FileSystemRegistrar ├── gen_src │ ├── BUILD │ └── SrcGenerator.scala ├── jar_lister.py ├── jmh │ ├── AddNumbers.scala │ ├── BUILD │ ├── JavaType.java │ ├── ScalaType.scala │ ├── TestBenchmark.scala │ ├── TestJmhRuntimeJdk11.scala │ ├── TestJmhRuntimeJdk8.scala │ ├── data.txt │ └── test_binary.sh ├── longnames │ └── looooooongnaaaaaaame │ │ └── anooooootherlooooooooongname │ │ └── anooooootherlooooooooongname2 │ │ └── anooooootherlooooooooongname3 │ │ └── LongNamesTest.scala ├── macros │ ├── BUILD │ ├── IdentityMacro.scala │ ├── MacroDependency.scala │ ├── MacroUser.scala │ ├── MacroWithDependencies.scala │ └── MacroWithDependenciesUser.scala ├── no_sigs.sh ├── phase │ ├── add_to_all_rules │ │ ├── BUILD │ │ ├── PhaseBinary.scala │ │ ├── PhaseJunitTest.scala │ │ ├── PhaseLibrary.scala │ │ ├── PhaseTest.scala │ │ ├── phase_add_to_all_rules.bzl │ │ └── phase_add_to_all_rules_test.bzl │ ├── adjustment │ │ ├── BUILD │ │ ├── PhaseLibrary.scala │ │ ├── phase_adjustment.bzl │ │ └── phase_adjustment_test.bzl │ └── providers │ │ ├── BUILD.bazel │ │ ├── phase_providers_expose.bzl │ │ └── phase_providers_override.bzl ├── plugins │ ├── BUILD │ ├── check_expand_location_plugin.scala │ └── trivial.scala ├── proto │ ├── BUILD │ ├── BlackListedProtoTest.scala │ ├── CustomGeneratedObjectTest.scala │ ├── PackProtosTest.scala │ ├── blacklisted_proto.proto │ ├── custom_generator │ │ ├── BUILD.bazel │ │ ├── DummyGenerator.scala │ │ ├── DummyGeneratorTest.scala │ │ └── FailingGenerator.scala │ ├── default_outputs_test.bzl │ ├── different_root.proto │ ├── different_root2.proto │ ├── some │ │ └── path │ │ │ └── nested.proto │ ├── standalone.proto │ ├── test2.proto │ ├── test3.proto │ ├── test_external_dep.proto │ └── test_service.proto ├── proto2 │ ├── BUILD │ └── test.proto ├── proto3 │ ├── BUILD │ └── test.proto ├── proto_cross_repo_boundary │ ├── BUILD │ └── repo │ │ ├── .bazelversion │ │ ├── BUILD │ │ ├── MODULE.bazel │ │ ├── WORKSPACE │ │ └── sample.proto ├── py_resource.py ├── rootpaths_binary.sh ├── scala_test │ ├── A.scala │ ├── B.scala │ ├── BUILD │ └── CustomReporter.scala ├── scalac │ └── srcjars │ │ ├── BUILD.bazel │ │ ├── DuplicatesTest.scala │ │ ├── duplicate │ │ └── BUILD.bazel │ │ └── setup.bzl ├── scalacopts │ ├── A.scala │ ├── BUILD │ └── EchoMacroSettings.scala ├── scalafmt │ ├── .scalafmt.conf │ ├── BUILD │ ├── formatted │ │ ├── formatted-custom-conf.scala │ │ ├── formatted-encoding.scala │ │ └── formatted-test.scala │ ├── phase_scalafmt_test.bzl │ └── unformatted │ │ ├── unformatted-custom-conf.scala │ │ ├── unformatted-encoding.scala │ │ └── unformatted-test.scala ├── semanticdb │ ├── A.scala │ ├── B.scala │ ├── BUILD │ ├── rules.bzl │ └── semantic_provider_vars.sh.template ├── shell │ ├── test_build_event_protocol.sh │ ├── test_bzlmod_macros.sh │ ├── test_bzlmod_tidy.sh │ ├── test_compilation.sh │ ├── test_compiler_dependency_tracking.sh │ ├── test_coverage_equals_in_target.sh │ ├── test_coverage_scalatest.sh │ ├── test_coverage_scalatest_resources.sh │ ├── test_coverage_specs2_with_junit.sh │ ├── test_cross_build.sh │ ├── test_custom_reporter_class.sh │ ├── test_deps.sh │ ├── test_diagnostics_reporter.sh │ ├── test_examples.sh │ ├── test_helper.sh │ ├── test_inherited_environment.sh │ ├── test_invalid_scalacopts.sh │ ├── test_javac_jvm_flags.sh │ ├── test_junit.sh │ ├── test_macros.sh │ ├── test_misc.sh │ ├── test_persistent_worker.sh │ ├── test_phase.sh │ ├── test_runner.sh │ ├── test_scala_binary.sh │ ├── test_scala_classpath.sh │ ├── test_scala_config.sh │ ├── test_scala_import_source_jar.sh │ ├── test_scala_jacocorunner.sh │ ├── test_scala_jvm_flags.sh │ ├── test_scala_library.sh │ ├── test_scala_library_jar.sh │ ├── test_scala_proto_library.sh │ ├── test_scala_specs2.sh │ ├── test_scala_test_testfilter.sh │ ├── test_scalac_jvm_flags.sh │ ├── test_scaladoc.sh │ ├── test_scalafmt.sh │ ├── test_scalafmt_helper.sh │ ├── test_semanticdb.sh │ ├── test_strict_dependency.sh │ ├── test_toolchain.sh │ ├── test_twitter_scrooge.sh │ └── test_unused_dependency.sh ├── src │ └── main │ │ ├── resources │ │ ├── META-INF │ │ │ ├── BUILD │ │ │ ├── FAKE.DSA │ │ │ ├── FAKE.RSA │ │ │ └── services │ │ │ │ ├── BUILD │ │ │ │ └── org.apache.beam.sdk.io.FileSystemRegistrar │ │ ├── java_sources │ │ │ ├── BUILD │ │ │ ├── SimpleJavaSourceFileA.java │ │ │ └── SimpleJavaSourceFileB.java │ │ └── scalarules │ │ │ └── test │ │ │ ├── BUILD │ │ │ ├── Bar.thrift │ │ │ ├── Baz.thrift │ │ │ ├── Foo.thrift │ │ │ ├── byes │ │ │ ├── classpath_resource1 │ │ │ ├── BUILD │ │ │ └── classpath-resource │ │ │ ├── classpath_resource2 │ │ │ ├── BUILD │ │ │ └── classpath-resource │ │ │ ├── hellos │ │ │ ├── more-byes │ │ │ └── more-hellos │ │ └── scala │ │ └── scalarules │ │ └── test │ │ ├── BinaryDependentOnJava.scala │ │ ├── MixJavaScalaLibBinary.scala │ │ ├── ResourcesStripScalaBinary.scala │ │ ├── ResourcesStripScalaLib.scala │ │ ├── ScalaLibBinary.scala │ │ ├── ScalaLibResources.scala │ │ ├── classpath_resources │ │ ├── BUILD │ │ ├── ObjectWithClasspathResources.scala │ │ └── ObjectWithDuplicateClasspathResources.scala │ │ ├── compiler_plugin │ │ ├── BUILD.bazel │ │ └── KindProjected.scala │ │ ├── disappearing_class │ │ └── ClassProvider.scala │ │ ├── duplicated_resources │ │ ├── child │ │ │ ├── BUILD │ │ │ ├── ScalaLibResourcesDuplicatedTest.scala │ │ │ └── resource.txt │ │ └── parent │ │ │ ├── BUILD │ │ │ └── resource.txt │ │ ├── extra_protobuf_generator │ │ ├── BUILD │ │ ├── ExtraProtobufGenerator.scala │ │ ├── ProtobufAdapter.scala │ │ └── ProtobufAdapter_2_11.scala │ │ ├── fetch_sources │ │ ├── BUILD │ │ └── FetchSources.scala │ │ ├── ijar │ │ ├── A.scala │ │ ├── B.scala │ │ ├── BUILD │ │ └── C.java │ │ ├── io_utils │ │ ├── BUILD │ │ └── DeleteDirectoryTest.scala │ │ ├── junit │ │ ├── FilterTest.scala │ │ ├── HelloWorldJunitTest.scala │ │ ├── JunitAbstractClassAndInterface.scala │ │ ├── JunitCustomRunner.java │ │ ├── JunitCustomRunnerTest.scala │ │ ├── JunitIncludesRunWith.scala │ │ ├── JunitIncludesTestHierarchies.scala │ │ ├── JunitInnerClass.scala │ │ ├── JunitJavaTest.java │ │ ├── JunitMultiplePrefixes.scala │ │ ├── JunitMultipleSuffixes.scala │ │ ├── JunitNoTestEnvironmentTest.scala │ │ ├── JunitNoTests.scala │ │ ├── JunitSetTestEnvironmentTest.scala │ │ ├── JunitTests.scala │ │ ├── runtime_platform │ │ │ └── JunitRuntimePlatformTest.java │ │ ├── scala.scala │ │ ├── separate_target │ │ │ ├── FailingTest.scala │ │ │ ├── JunitJavaSeparateTargetTest.java │ │ │ ├── JunitSeparateTargetTest.scala │ │ │ └── SomeScalaClass.scala │ │ ├── specs2 │ │ │ └── Specs2Tests.scala │ │ ├── support │ │ │ ├── JUnitCompileTimeDep.scala │ │ │ └── JUnitRuntimeDep.scala │ │ └── test_discovery │ │ │ ├── ArchiveEntriesTest.scala │ │ │ └── BUILD │ │ ├── large_classpath │ │ ├── BUILD │ │ ├── ObjectWithLargeClasspath.scala │ │ └── helper.bzl │ │ ├── location_expansion │ │ └── LocationExpansionTest.scala │ │ ├── mix_java_scala │ │ ├── Bar.scala │ │ ├── Baz.java │ │ ├── Baz.srcjar │ │ └── FooBar.java │ │ ├── neverlink │ │ ├── A.scala │ │ ├── B.scala │ │ ├── BUILD │ │ └── NeverlinkTest.scala │ │ ├── only_java │ │ └── Alpha.java │ │ ├── resource_jars │ │ ├── BUILD │ │ └── TestResourceJars.scala │ │ ├── resources │ │ ├── BUILD │ │ ├── ScalaLibOnlyResourcesFilegroupTest.scala │ │ ├── ScalaLibOnlyResourcesTest.scala │ │ ├── ScalaLibResourcesFromExternalDepTest.scala │ │ ├── ScalaLibResourcesFromExternalScalaTest.scala │ │ ├── resource.txt │ │ ├── strip │ │ │ ├── BUILD │ │ │ ├── ResourceStripPrefixTest.scala │ │ │ └── nosrc_jar_resource.txt │ │ └── subdir │ │ │ └── resource.txt │ │ ├── scala_import │ │ ├── BUILD │ │ ├── ReferCatsImplicits.scala │ │ ├── ScalaImportExposesFileJarsTest.scala │ │ ├── ScalaImportExposesJarsTest.scala │ │ ├── ScalaImportPropagatesRuntimeDepsTest.scala │ │ ├── generic │ │ │ └── Generic.scala │ │ ├── nl │ │ │ ├── BUILD.bazel │ │ │ ├── ScalaImportNeverLink.java │ │ │ └── ScalaImportNeverLinkTest.scala │ │ ├── scala_import_stamp_test.bzl │ │ └── srcjar │ │ │ ├── BUILD.bazel │ │ │ └── exposes_srcjar_test.bzl │ │ ├── sources_jars_in_deps │ │ ├── BUILD │ │ └── ReferCatsImplicits.scala │ │ ├── srcjars │ │ ├── BUILD │ │ ├── SourceJar1.scala │ │ ├── SourceJar1.srcjar │ │ ├── SourceJar2.scala │ │ ├── SourceJar2.srcjar │ │ └── pack_sources_test.bzl │ │ ├── srcjars_with_java │ │ ├── BUILD │ │ ├── JavaDependent.scala │ │ ├── JavaSource.java │ │ ├── JavaSourceJar.srcjar │ │ ├── MixedLanguageDependent.scala │ │ ├── MixedLanguageSourceJar.srcjar │ │ └── ScalaSource.scala │ │ ├── stamping │ │ ├── BUILD │ │ ├── ClassFromLibrary.scala │ │ ├── ClassFromMacroLibrary.scala │ │ └── JarStampingTest.scala │ │ ├── strict_deps │ │ └── no_recompilation │ │ │ ├── A.scala │ │ │ ├── B.scala │ │ │ ├── BUILD │ │ │ └── C.scala │ │ ├── twitter_scrooge │ │ ├── BUILD │ │ ├── BareThrifts.scala │ │ ├── JustScrooge1.java │ │ ├── JustScrooge1.scala │ │ ├── JustScrooge2a.scala │ │ ├── JustScrooge2b.scala │ │ ├── JustScrooge3.scala │ │ ├── Mixed.scala │ │ ├── Scrooge2.scala │ │ ├── Twodeep.scala │ │ ├── prefix_test │ │ │ ├── a │ │ │ │ └── b │ │ │ │ │ └── c │ │ │ │ │ └── d │ │ │ │ │ ├── A.thrift │ │ │ │ │ └── BUILD │ │ │ └── e │ │ │ │ └── f │ │ │ │ └── b │ │ │ │ └── c │ │ │ │ └── d │ │ │ │ ├── B.thrift │ │ │ │ └── BUILD │ │ ├── string_in_file.sh │ │ ├── string_in_filename_in_jar.sh │ │ ├── thrift │ │ │ ├── BUILD │ │ │ ├── Thrift1.thrift │ │ │ ├── ThriftMany1.thrift │ │ │ ├── ThriftMany2.thrift │ │ │ ├── bare_jar_thrifts │ │ │ │ ├── BUILD │ │ │ │ ├── BareJar.thrift │ │ │ │ ├── bare_jar_1 │ │ │ │ │ └── BUILD │ │ │ │ └── bare_jar_2 │ │ │ │ │ └── BUILD │ │ │ ├── thrift2 │ │ │ │ ├── BUILD │ │ │ │ ├── Thrift2_A.thrift │ │ │ │ ├── Thrift2_B.thrift │ │ │ │ ├── thrift3 │ │ │ │ │ ├── BUILD.bazel │ │ │ │ │ └── Thrift3.thrift │ │ │ │ └── thrift4 │ │ │ │ │ ├── BUILD │ │ │ │ │ ├── Thrift4.thrift │ │ │ │ │ └── Thrift4a.thrift │ │ │ └── thrift_with_compiler_args │ │ │ │ ├── BUILD │ │ │ │ └── Thrift5.thrift │ │ └── twitter_scrooge_test.bzl │ │ └── utf8 │ │ ├── JavaClassWithUtf8.java │ │ └── ScalaClassWithUtf8.scala ├── test_binary.sh ├── test_binary_run_with_large_classpath.sh ├── test_scala_library_outputs_mixed_java_scala_jars.sh ├── toolchains │ ├── BUILD.bazel │ └── jdk.bzl └── unstable │ ├── BUILD │ ├── binary.scala │ ├── library.scala │ └── test.scala ├── test_all.sh ├── test_cleanup.sh ├── test_coverage.sh ├── test_cross_build.sh ├── test_cross_build ├── .bazelrc ├── .bazelversion ├── BUILD ├── MODULE.bazel ├── WORKSPACE ├── protobuf.patch ├── scalafmt │ ├── .scalafmt2.conf │ ├── .scalafmt3.conf │ ├── BUILD │ ├── formatted │ │ ├── formatted-binary2.scala │ │ ├── formatted-binary3.scala │ │ ├── formatted-library2.scala │ │ ├── formatted-library3.scala │ │ ├── formatted-test2.scala │ │ └── formatted-test3.scala │ ├── scalafmt_rules.bzl │ └── unformatted │ │ ├── unformatted-binary2.scala │ │ ├── unformatted-binary3.scala │ │ ├── unformatted-library2.scala │ │ ├── unformatted-library3.scala │ │ ├── unformatted-test2.scala │ │ └── unformatted-test3.scala └── version_specific │ ├── BUILD │ ├── before_3_2.scala │ ├── before_3_3.scala │ ├── since_3_1.scala │ ├── since_3_2.scala │ └── since_3_3.scala ├── test_dependency_versions.sh ├── test_examples.sh ├── test_expect_failure ├── compiler_dependency_tracker │ ├── A.scala │ ├── B.scala │ ├── BUILD │ ├── C.scala │ ├── D.scala │ ├── E.scala │ ├── F.scala │ └── sdeps │ │ ├── AnotherScalaDep.scala │ │ ├── BUILD │ │ ├── IgnoredScalaDep.scala │ │ ├── ScalaDep.scala │ │ ├── SdepsTest.scala │ │ ├── SomeJava.java │ │ └── SomeScalaWithDeps.scala ├── compilers_javac_opts │ ├── BUILD │ └── WillNotCompileSinceJavaToolchainAddsAnInvalidJvmFlag.java ├── compilers_jvm_flags │ ├── BUILD │ ├── WillNotCompileJavaSinceXmxTooLow.java │ ├── WillNotCompileScalaSinceXmxTooLow.scala │ └── args.txt ├── diagnostics_reporter │ ├── BUILD │ ├── ErrorAndWarningFile.scala │ ├── ErrorFile.scala │ ├── InfoFile.scala │ ├── TwoErrorsFile.scala │ └── WarningFile.scala ├── disappearing_class │ ├── BUILD │ ├── ClassProvider.scala │ └── UsesClass.scala ├── java_in_src_jar_when_disabled │ ├── BUILD │ └── JavaSourceJar.srcjar ├── jmh │ ├── BUILD │ └── InvalidBenchmark.scala ├── mismatching_resource_strip_prefix │ ├── BUILD │ └── resource.txt ├── missing_direct_deps │ ├── external_deps │ │ ├── A.scala │ │ ├── B.scala │ │ ├── BUILD │ │ ├── Empty.java │ │ └── UsesExternalDep.java │ ├── filtering │ │ ├── BUILD │ │ └── UsesGuava.scala │ ├── internal_deps │ │ ├── A.scala │ │ ├── B.scala │ │ ├── BUILD │ │ ├── C.scala │ │ ├── D.scala │ │ ├── HasCustomJavaProviderDependency.scala │ │ ├── JavaLibraryHasCustomJavaProviderDependency.java │ │ ├── Placeholder.java │ │ ├── User.java │ │ └── custom-jvm-rule.bzl │ └── scala_proto_deps │ │ ├── BUILD │ │ ├── UseScalaProtoIndirectly.scala │ │ ├── UseTestMessage.java │ │ ├── customized_scala_proto.bzl │ │ └── some.proto ├── plus_one_deps │ ├── BUILD.bazel │ ├── deps_of_exports │ │ ├── A.scala │ │ ├── B.scala │ │ ├── BUILD.bazel │ │ ├── C.scala │ │ └── D.scala │ ├── exports_of_deps │ │ ├── A.scala │ │ ├── B.scala │ │ ├── BUILD.bazel │ │ ├── C.scala │ │ └── D.scala │ ├── external_deps │ │ ├── A.scala │ │ └── BUILD.bazel │ ├── internal_deps │ │ ├── A.scala │ │ ├── B.scala │ │ ├── BUILD.bazel │ │ └── C.scala │ └── with_unused_deps │ │ ├── A.scala │ │ ├── B.scala │ │ ├── BUILD.bazel │ │ └── C.scala ├── proto_source_root │ ├── dependency │ │ ├── BUILD │ │ └── zip_code.proto │ └── user │ │ ├── BUILD │ │ ├── address.proto │ │ └── person.proto ├── scala_import │ ├── BUILD │ ├── LeafScalaImportPassesLabelsDirectDeps.scala │ ├── RootScalaImportPassesLabelsDirectDeps.scala │ └── ScalaImportPropagatesCompileDepsTest.scala ├── scala_junit_test │ ├── BUILD │ ├── JunitFailureTest.scala │ ├── JunitTest.scala │ └── specs2 │ │ ├── FailingTest.scala │ │ └── SuiteWithOneFailingTest.scala ├── scala_library_suite │ ├── BUILD │ └── DataA.scala ├── scala_test_env_inherit │ ├── BUILD │ └── InheritedEnvTest.scala ├── scala_test_jacocorunner │ ├── BUILD │ └── EmptyTest.scala ├── scala_test_jvm_flags │ ├── BUILD │ └── EmptyTest.scala ├── scala_test_testfilter │ ├── A.scala │ ├── B.scala │ └── BUILD ├── scalac_exceptions │ ├── BUILD │ ├── BadMacro.scala │ ├── BadMacroInvocation.scala │ └── StackOverflowMacroInvocation.scala ├── scalac_jvm_opts │ ├── BUILD │ └── Empty.scala ├── scalacopts_from_toolchain │ ├── BUILD │ └── ClassWithUnused.scala ├── scalacopts_invalid │ ├── BUILD │ └── Empty.scala ├── scaladoc │ ├── A.scala │ ├── B.scala │ ├── BUILD │ ├── C.scala │ └── scaladoc.bzl ├── transitive │ ├── java_to_scala │ │ ├── A.scala │ │ ├── BUILD │ │ ├── C.java │ │ └── D.java │ ├── scala_to_java │ │ ├── A.java │ │ ├── BUILD │ │ └── D.scala │ └── scala_to_scala │ │ ├── A.scala │ │ ├── BUILD │ │ └── D.scala └── unused_dependency_checker │ ├── A.scala │ ├── B.scala │ ├── BUILD │ └── filtering │ ├── BUILD │ └── Empty.scala ├── test_intellij_aspect.sh ├── test_lint.sh ├── test_reproducibility.sh ├── test_rules_scala.sh ├── test_statsfile ├── BUILD └── Simple.scala ├── test_thirdparty_version.sh ├── test_version.sh ├── test_version ├── MODULE.bazel.template ├── WORKSPACE.template ├── protobuf.patch ├── scrooge_repositories.bzl ├── test_reporter │ ├── BUILD │ └── ErrorFile.scala └── version_specific_tests_dir │ ├── BUILD │ ├── Exported.scala │ ├── HelloLib.scala │ ├── HelloLibTest.scala │ ├── JavaBinary.java │ ├── MacroTest.scala │ ├── OtherJavaLib.java │ ├── OtherLib.scala │ ├── Runtime.scala │ ├── ScalaBinary.scala │ ├── TestServer.scala │ ├── proto │ ├── BUILD │ ├── test2.proto │ ├── test3.proto │ └── test_service.proto │ ├── proto2 │ ├── BUILD │ └── test.proto │ ├── src │ └── main │ │ ├── resources │ │ └── scalarules │ │ │ └── test │ │ │ ├── BUILD │ │ │ ├── Bar.thrift │ │ │ ├── Baz.thrift │ │ │ └── Foo.thrift │ │ └── scala │ │ └── scalarules │ │ └── test │ │ ├── MixJavaScalaLibBinary.scala │ │ ├── ScalaLibBinary.scala │ │ ├── junit │ │ ├── JunitTests.scala │ │ ├── specs2 │ │ │ └── Specs2Tests.scala │ │ └── support │ │ │ ├── JUnitCompileTimeDep.scala │ │ │ └── JUnitRuntimeDep.scala │ │ ├── mix_java_scala │ │ ├── Bar.scala │ │ ├── Baz.java │ │ └── FooBar.java │ │ └── twitter_scrooge │ │ ├── BUILD │ │ ├── BareThrifts.scala │ │ ├── JustScrooge1.scala │ │ ├── JustScrooge2a.scala │ │ ├── JustScrooge2b.scala │ │ ├── JustScrooge3.scala │ │ ├── Mixed.scala │ │ ├── Scrooge2.scala │ │ ├── Twodeep.scala │ │ ├── grep.sh │ │ ├── prefix_test │ │ ├── a │ │ │ └── b │ │ │ │ └── c │ │ │ │ └── d │ │ │ │ ├── A.thrift │ │ │ │ └── BUILD │ │ └── e │ │ │ └── f │ │ │ └── b │ │ │ └── c │ │ │ └── d │ │ │ ├── B.thrift │ │ │ └── BUILD │ │ └── thrift │ │ ├── BUILD │ │ ├── Thrift1.thrift │ │ ├── ThriftMany1.thrift │ │ ├── ThriftMany2.thrift │ │ ├── bare_jar_thrifts │ │ ├── BUILD │ │ ├── BareJar.thrift │ │ ├── bare_jar_1 │ │ │ └── BUILD │ │ └── bare_jar_2 │ │ │ └── BUILD │ │ └── thrift2 │ │ ├── BUILD │ │ ├── Thrift2_A.thrift │ │ ├── Thrift2_B.thrift │ │ ├── thrift3 │ │ ├── BUILD │ │ └── Thrift3.thrift │ │ └── thrift4 │ │ ├── BUILD │ │ ├── Thrift4.thrift │ │ └── Thrift4a.thrift │ ├── test_binary.sh │ └── twitter_scrooge │ ├── BUILD │ └── dependency_version_in_filename.sh ├── testing ├── BUILD ├── testing.bzl └── toolchain │ ├── BUILD │ ├── toolchain.bzl │ └── toolchain_deps.bzl ├── third_party ├── README.md ├── dependency_analyzer │ ├── LICENSE │ └── src │ │ ├── main │ │ ├── BUILD │ │ ├── io │ │ │ └── bazel │ │ │ │ └── rulesscala │ │ │ │ ├── dependencyanalyzer │ │ │ │ ├── AstUsedJarFinder.scala │ │ │ │ ├── DependencyAnalyzer.scala │ │ │ │ ├── DependencyAnalyzerSettings.scala │ │ │ │ ├── HighLevelCrawlUsedJarFinder.scala │ │ │ │ ├── OptionsParser.scala │ │ │ │ ├── Reporter.scala │ │ │ │ ├── Reporter213.scala │ │ │ │ ├── ScalaVersion.scala │ │ │ │ └── compiler │ │ │ │ │ └── BUILD │ │ │ │ └── dependencyanalyzer3 │ │ │ │ ├── AstUsedJarFinder.scala │ │ │ │ ├── DependencyAnalyzer.scala │ │ │ │ ├── HighLevelCrawlUsedJarFinder.scala │ │ │ │ └── ScalaVersion.scala │ │ └── resources │ │ │ ├── plugin.properties │ │ │ └── scalac-plugin.xml │ │ └── test │ │ ├── BUILD │ │ ├── analyzer_test.bzl │ │ ├── io │ │ └── bazel │ │ │ └── rulesscala │ │ │ └── dependencyanalyzer │ │ │ ├── AstUsedJarFinderTest.scala │ │ │ ├── CompileTest.scala │ │ │ ├── ScalaVersionMacrosTest.scala │ │ │ ├── ScalaVersionTest.scala │ │ │ ├── ScalacDependencyTest.scala │ │ │ ├── StrictDepsTest.scala │ │ │ └── UnusedDependencyCheckerTest.scala │ │ └── test_optionsparser.scala ├── repositories │ ├── BUILD │ ├── repositories.bzl │ ├── scala_2_11.bzl │ ├── scala_2_12.bzl │ ├── scala_2_13.bzl │ ├── scala_3_1.bzl │ ├── scala_3_2.bzl │ ├── scala_3_3.bzl │ ├── scala_3_4.bzl │ ├── scala_3_5.bzl │ ├── scala_3_6.bzl │ └── scala_3_7.bzl ├── test │ ├── example_external_workspace │ │ ├── .bazelrc │ │ ├── .bazelversion │ │ ├── BUILD │ │ ├── MODULE.bazel │ │ ├── WORKSPACE │ │ ├── protobuf.patch │ │ ├── strip │ │ │ ├── BUILD.bazel │ │ │ └── nosrc_jar_resource.txt │ │ └── test │ │ │ ├── BUILD │ │ │ └── EmptyTest.scala │ ├── new_local_repo │ │ ├── .bazelversion │ │ ├── BUILD │ │ ├── MODULE.bazel │ │ ├── WORKSPACE │ │ └── resource.txt │ └── proto │ │ ├── .bazelrc │ │ ├── .bazelversion │ │ ├── BUILD.bazel │ │ ├── MODULE.bazel │ │ ├── WORKSPACE │ │ ├── protobuf.patch │ │ └── test.proto └── utils │ ├── LICENSE │ └── src │ └── test │ ├── BUILD │ └── io │ └── bazel │ └── rulesscala │ └── utils │ ├── CommandLineParserAdapter_before_2_13_9.scala │ ├── CommandLineParserAdapter_since_2_13_9.scala │ ├── JavaCompileUtil.scala │ ├── TestUtil.scala │ ├── TestUtil3.scala │ └── TestUtilCommon.scala ├── thrift ├── BUILD ├── thrift.bzl └── thrift_info.bzl ├── tools ├── BUILD └── bazel.rc.buildkite └── twitter_scrooge ├── BUILD ├── toolchain ├── BUILD └── toolchain.bzl └── twitter_scrooge.bzl /.bazelversion: -------------------------------------------------------------------------------- 1 | 7.6.1 2 | -------------------------------------------------------------------------------- /.bcr/metadata.template.json: -------------------------------------------------------------------------------- 1 | { 2 | "homepage": "https://github.com/bazel-contrib/rules_scala", 3 | "maintainers": [ 4 | { 5 | "name": "Simonas Pinevičius", 6 | "email": "simonas.pinevicius@gmail.com", 7 | "github": "simuons" 8 | }, 9 | { 10 | "name": "Vaidas Pilkauskas", 11 | "email": "vaidas.pilkauskas@gmail.com", 12 | "github": "liucijus" 13 | } 14 | ], 15 | "repository": [ 16 | "github:bazel-contrib/rules_scala" 17 | ], 18 | "versions": [], 19 | "yanked_versions": {} 20 | } 21 | -------------------------------------------------------------------------------- /.bcr/presubmit.yml: -------------------------------------------------------------------------------- 1 | bcr_test_module: 2 | module_path: "examples/crossbuild" 3 | matrix: 4 | platform: ["debian10", "macos", "ubuntu2004", "windows"] 5 | bazel: [7.x, 8.x, rolling, last_green] 6 | tasks: 7 | run_tests: 8 | name: "Build and test the example module" 9 | platform: ${{ platform }} 10 | bazel: ${{ bazel }} 11 | build_targets: 12 | - "//..." 13 | test_targets: 14 | - "//..." 15 | -------------------------------------------------------------------------------- /.bcr/source.template.json: -------------------------------------------------------------------------------- 1 | { 2 | "integrity": "", 3 | "strip_prefix": "{REPO}-{VERSION}", 4 | "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{TAG}.tar.gz" 5 | } 6 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Description 2 | 3 | 4 | 5 | 9 | 10 | ### Motivation 11 | 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bazel-* 2 | *.swp 3 | *.idea 4 | hash1 5 | hash2 6 | .DS_store 7 | .bazel_cache 8 | .ijwb 9 | .bazelbsp 10 | .bsp 11 | .metals 12 | .vscode 13 | unformatted-*.backup.scala 14 | .scala-build 15 | test/semanticdb/tempsrc 16 | 17 | # From scripts/create_repository.py 18 | repository-artifacts.json 19 | 20 | # Until it settles down 21 | **/MODULE.bazel.lock 22 | 23 | # Used by some tests, but can also be used for local experimentation. 24 | tmp/ 25 | 26 | # Not required by tests. 27 | deps/latest/.bazelversion 28 | -------------------------------------------------------------------------------- /.markdownlint.json: -------------------------------------------------------------------------------- 1 | { 2 | "default": true, 3 | "MD013": false, 4 | "MD033": false 5 | } 6 | -------------------------------------------------------------------------------- /.scalafmt.conf: -------------------------------------------------------------------------------- 1 | version = "3.9.6" 2 | runner.dialect = scala213 3 | align.openParenCallSite = false 4 | align.openParenDefnSite = false 5 | continuationIndent.defnSite = 2 6 | danglingParentheses.preset = true 7 | docstrings.style = Asterisk 8 | importSelectors = singleLine 9 | maxColumn = 120 10 | rewrite.redundantBraces.stringInterpolation = true 11 | rewrite.rules = [ 12 | RedundantParens, 13 | PreferCurlyFors, 14 | SortImports 15 | ] 16 | indentOperator.topLevelOnly = true 17 | lineEndings = preserve 18 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # This the official list of Bazel authors for copyright purposes. 2 | # This file is distinct from the CONTRIBUTORS files. 3 | # See the latter for an explanation. 4 | 5 | # Names should be added to this file as: 6 | # Name or Organization 7 | # The email address is not required for organizations. 8 | 9 | Google Inc. 10 | Dino Wernli 11 | Oscar Boykin 12 | John T. Sullivan 13 | Andy Scott 14 | Ittai Zeidman 15 | -------------------------------------------------------------------------------- /BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/BUILD -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @liucijus @simuons 2 | -------------------------------------------------------------------------------- /docs/scala_library_suite.md: -------------------------------------------------------------------------------- 1 | # scala_library_suite 2 | 3 | `scala_library_suite` allows you to define a glob or series of targets for which to generate sub 4 | scala libraries. The outer target will export all of the inner targets. 5 | 6 | This rule is useful for splitting up a larger target into smaller targets (typically a series of independent files), 7 | thereby enabling better cache outputs and parallelization of building individual targets. 8 | Generally speaking, downstream targets should not be aware of a suite's presence - it should be strictly 9 | a parent-children relationship. 10 | -------------------------------------------------------------------------------- /docs/scala_test_suite.md: -------------------------------------------------------------------------------- 1 | # scala_test_suite 2 | 3 | `scala_test_suite` allows you to define a glob or series of targets for which to generate sub scala tests. 4 | 5 | The outer target defines a native test suite to run all the inner tests. This allows splitting up 6 | of a series of independent tests from one target into several finer grained targets, enabling better caching 7 | and parallelization of building & testing individual targets. 8 | -------------------------------------------------------------------------------- /dt_patches/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/dt_patches/BUILD -------------------------------------------------------------------------------- /dt_patches/compiler_sources/.bazelrc: -------------------------------------------------------------------------------- 1 | import ../../.bazelrc 2 | -------------------------------------------------------------------------------- /dt_patches/compiler_sources/.bazelversion: -------------------------------------------------------------------------------- 1 | 7.6.1 2 | -------------------------------------------------------------------------------- /dt_patches/compiler_sources/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/dt_patches/compiler_sources/BUILD -------------------------------------------------------------------------------- /dt_patches/compiler_sources/MODULE.bazel: -------------------------------------------------------------------------------- 1 | """Bazel module ./test/shell/test_examples.sh tests""" 2 | 3 | module(name = "compiler_sources") 4 | 5 | bazel_dep(name = "rules_scala") 6 | local_path_override( 7 | module_name = "rules_scala", 8 | path = "../..", 9 | ) 10 | 11 | scala_config = use_extension( 12 | "@rules_scala//scala/extensions:config.bzl", 13 | "scala_config", 14 | ) 15 | use_repo(scala_config, "rules_scala_config") 16 | -------------------------------------------------------------------------------- /dt_patches/compiler_sources/WORKSPACE: -------------------------------------------------------------------------------- 1 | workspace(name = "compiler_sources") 2 | -------------------------------------------------------------------------------- /dt_patches/test_dt_patches/.bazelrc: -------------------------------------------------------------------------------- 1 | import ../../.bazelrc 2 | -------------------------------------------------------------------------------- /dt_patches/test_dt_patches/.bazelversion: -------------------------------------------------------------------------------- 1 | 7.6.1 2 | -------------------------------------------------------------------------------- /dt_patches/test_dt_patches/dummy/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_scala//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "dummy", 5 | srcs = ["Dummy.scala"], 6 | visibility = ["//visibility:public"], 7 | ) 8 | -------------------------------------------------------------------------------- /dt_patches/test_dt_patches/dummy/Dummy.scala: -------------------------------------------------------------------------------- 1 | package dummy 2 | 3 | class Dummy -------------------------------------------------------------------------------- /dt_patches/test_dt_patches/protobuf.patch: -------------------------------------------------------------------------------- 1 | ../../protoc/0001-protobuf-19679-rm-protoc-dep.patch -------------------------------------------------------------------------------- /dt_patches/test_dt_patches_user_srcjar/.bazelrc: -------------------------------------------------------------------------------- 1 | import ../../.bazelrc 2 | -------------------------------------------------------------------------------- /dt_patches/test_dt_patches_user_srcjar/.bazelversion: -------------------------------------------------------------------------------- 1 | 7.6.1 2 | -------------------------------------------------------------------------------- /dt_patches/test_dt_patches_user_srcjar/dummy/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_scala//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "dummy", 5 | srcs = ["Dummy.scala"], 6 | visibility = ["//visibility:public"], 7 | ) 8 | -------------------------------------------------------------------------------- /dt_patches/test_dt_patches_user_srcjar/dummy/Dummy.scala: -------------------------------------------------------------------------------- 1 | package dummy 2 | 3 | class Dummy -------------------------------------------------------------------------------- /dt_patches/test_dt_patches_user_srcjar/protobuf.patch: -------------------------------------------------------------------------------- 1 | ../../protoc/0001-protobuf-19679-rm-protoc-dep.patch -------------------------------------------------------------------------------- /examples/crossbuild/.bazelrc: -------------------------------------------------------------------------------- 1 | import ../../.bazelrc 2 | -------------------------------------------------------------------------------- /examples/crossbuild/.bazelversion: -------------------------------------------------------------------------------- 1 | 7.6.1 2 | -------------------------------------------------------------------------------- /examples/crossbuild/1_single/bin.scala: -------------------------------------------------------------------------------- 1 | object C extends App { 2 | println("Hello") 3 | } 4 | -------------------------------------------------------------------------------- /examples/crossbuild/1_single/lib.scala: -------------------------------------------------------------------------------- 1 | class A 2 | -------------------------------------------------------------------------------- /examples/crossbuild/1_single/test.scala: -------------------------------------------------------------------------------- 1 | import org.scalatest.flatspec.AnyFlatSpec 2 | 3 | class Zero extends AnyFlatSpec { 4 | "Equality" should "be tested" in { 5 | assert (0 == -0) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /examples/crossbuild/2_deps/bin.scala: -------------------------------------------------------------------------------- 1 | object C extends App { 2 | println("Hello, world") 3 | } 4 | -------------------------------------------------------------------------------- /examples/crossbuild/2_deps/lib.scala: -------------------------------------------------------------------------------- 1 | class A 2 | -------------------------------------------------------------------------------- /examples/crossbuild/2_deps/lib_default.scala: -------------------------------------------------------------------------------- 1 | class B 2 | -------------------------------------------------------------------------------- /examples/crossbuild/3_select/bin.scala: -------------------------------------------------------------------------------- 1 | object B extends App { 2 | (new A).say 3 | } 4 | -------------------------------------------------------------------------------- /examples/crossbuild/3_select/lib2.scala: -------------------------------------------------------------------------------- 1 | class A { 2 | def say = println("Hello 2") 3 | } 4 | -------------------------------------------------------------------------------- /examples/crossbuild/3_select/lib3.scala: -------------------------------------------------------------------------------- 1 | class A: 2 | def say = 3 | println("Hello 3") 4 | -------------------------------------------------------------------------------- /examples/crossbuild/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/examples/crossbuild/BUILD -------------------------------------------------------------------------------- /examples/crossbuild/protobuf.patch: -------------------------------------------------------------------------------- 1 | ../../protoc/0001-protobuf-19679-rm-protoc-dep.patch -------------------------------------------------------------------------------- /examples/overridden_artifacts/.bazelrc: -------------------------------------------------------------------------------- 1 | import ../../.bazelrc 2 | -------------------------------------------------------------------------------- /examples/overridden_artifacts/.bazelversion: -------------------------------------------------------------------------------- 1 | 7.6.1 2 | -------------------------------------------------------------------------------- /examples/overridden_artifacts/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_scala//scala:scala.bzl", "scala_library", "scala_test") 2 | 3 | scala_library( 4 | name = "hello", 5 | srcs = ["Hello.scala"], 6 | ) 7 | 8 | scala_test( 9 | name = "hello-test", 10 | srcs = ["HelloTest.scala"], 11 | deps = [":hello"], 12 | ) 13 | -------------------------------------------------------------------------------- /examples/overridden_artifacts/Hello.scala: -------------------------------------------------------------------------------- 1 | package overriddenartifactstest 2 | 3 | class Hello(version: String): 4 | def greetings(): String = "Hello, World! This is Scala " + version + "." 5 | -------------------------------------------------------------------------------- /examples/overridden_artifacts/HelloTest.scala: -------------------------------------------------------------------------------- 1 | package overriddenartifactstest 2 | 3 | import org.scalatest.funsuite.AnyFunSuite 4 | 5 | class HelloTest extends AnyFunSuite: 6 | test("greetings includes the correct Scala version number") { 7 | val hello = new Hello(util.Properties.versionNumberString) 8 | 9 | // Apparently Scala 3 code will still return a Scala 2 version number: 10 | // - https://users.scala-lang.org/t/what-scala-library-version-is-used-by-which-scala-3-version/9999 11 | assert(hello.greetings().endsWith("2.13.14.")) 12 | } 13 | -------------------------------------------------------------------------------- /examples/overridden_artifacts/protobuf.patch: -------------------------------------------------------------------------------- 1 | ../../protoc/0001-protobuf-19679-rm-protoc-dep.patch -------------------------------------------------------------------------------- /examples/scala3/.bazelrc: -------------------------------------------------------------------------------- 1 | import ../../.bazelrc 2 | -------------------------------------------------------------------------------- /examples/scala3/.bazelversion: -------------------------------------------------------------------------------- 1 | 7.6.1 2 | -------------------------------------------------------------------------------- /examples/scala3/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_scala//scala:scala.bzl", "scala_binary", "scala_library") 2 | 3 | scala_library( 4 | name = "lib", 5 | srcs = ["Hello.scala"], 6 | deps = [], 7 | ) 8 | 9 | scala_binary( 10 | name = "main", 11 | srcs = ["Main.scala"], 12 | main_class = "hello", 13 | deps = [":lib"], 14 | ) 15 | -------------------------------------------------------------------------------- /examples/scala3/Hello.scala: -------------------------------------------------------------------------------- 1 | package examples.scala3 2 | 3 | class Hello: 4 | def hello: String = "Hello" 5 | -------------------------------------------------------------------------------- /examples/scala3/Main.scala: -------------------------------------------------------------------------------- 1 | import examples.scala3.Hello 2 | 3 | @main def hello = println((new Hello).hello) 4 | -------------------------------------------------------------------------------- /examples/scala3/protobuf.patch: -------------------------------------------------------------------------------- 1 | ../../protoc/0001-protobuf-19679-rm-protoc-dep.patch -------------------------------------------------------------------------------- /examples/semanticdb/.bazelrc: -------------------------------------------------------------------------------- 1 | import ../../.bazelrc 2 | -------------------------------------------------------------------------------- /examples/semanticdb/.bazelversion: -------------------------------------------------------------------------------- 1 | 7.6.1 2 | -------------------------------------------------------------------------------- /examples/semanticdb/Foo.scala: -------------------------------------------------------------------------------- 1 | class Foo(){ 2 | def sayHello: String = "Hello!!" 3 | } 4 | -------------------------------------------------------------------------------- /examples/semanticdb/Main.scala: -------------------------------------------------------------------------------- 1 | 2 | object main{ 3 | def main(args: Array[String]): Unit = { 4 | val foo = new Foo() 5 | println(foo.sayHello) 6 | } 7 | } -------------------------------------------------------------------------------- /examples/semanticdb/protobuf.patch: -------------------------------------------------------------------------------- 1 | ../../protoc/0001-protobuf-19679-rm-protoc-dep.patch -------------------------------------------------------------------------------- /examples/testing/multi_frameworks_toolchain/.bazelrc: -------------------------------------------------------------------------------- 1 | import ../../../.bazelrc 2 | -------------------------------------------------------------------------------- /examples/testing/multi_frameworks_toolchain/.bazelversion: -------------------------------------------------------------------------------- 1 | 7.6.1 2 | -------------------------------------------------------------------------------- /examples/testing/multi_frameworks_toolchain/example/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_scala//scala:scala.bzl", "scala_specs2_junit_test", "scala_test") 2 | 3 | scala_test( 4 | name = "scalatest_example", 5 | srcs = ["ScalaTestExampleTest.scala"], 6 | ) 7 | 8 | scala_specs2_junit_test( 9 | name = "specs2_example", 10 | srcs = ["Specs2ExampleTest.scala"], 11 | suffixes = ["Test"], 12 | ) 13 | -------------------------------------------------------------------------------- /examples/testing/multi_frameworks_toolchain/example/ScalaTestExampleTest.scala: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | import org.scalatest.flatspec.AnyFlatSpec 4 | import org.scalatest.matchers.must.Matchers 5 | 6 | class ScalaTestExampleTest extends AnyFlatSpec with Matchers { 7 | "Example" should "pass" in { 8 | 1 must be(1) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /examples/testing/multi_frameworks_toolchain/example/Specs2ExampleTest.scala: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | import org.specs2.mutable.SpecWithJUnit 4 | 5 | class Specs2ExampleTest extends SpecWithJUnit { 6 | 7 | "Example" in { 8 | 1 mustEqual 1 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /examples/testing/multi_frameworks_toolchain/protobuf.patch: -------------------------------------------------------------------------------- 1 | ../../../protoc/0001-protobuf-19679-rm-protoc-dep.patch -------------------------------------------------------------------------------- /examples/testing/scalatest_repositories/.bazelrc: -------------------------------------------------------------------------------- 1 | import ../../../.bazelrc 2 | -------------------------------------------------------------------------------- /examples/testing/scalatest_repositories/.bazelversion: -------------------------------------------------------------------------------- 1 | 7.6.1 2 | -------------------------------------------------------------------------------- /examples/testing/scalatest_repositories/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/examples/testing/scalatest_repositories/BUILD -------------------------------------------------------------------------------- /examples/testing/scalatest_repositories/example/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_scala//scala:scala.bzl", "scala_test") 2 | 3 | scala_test( 4 | name = "example", 5 | srcs = ["ExampleTest.scala"], 6 | ) 7 | -------------------------------------------------------------------------------- /examples/testing/scalatest_repositories/example/ExampleTest.scala: -------------------------------------------------------------------------------- 1 | package examples.testing.scalatest_repositories.example 2 | 3 | import org.scalatest.flatspec.AnyFlatSpec 4 | import org.scalatest.matchers.must.Matchers 5 | 6 | class ExampleTest extends AnyFlatSpec with Matchers { 7 | "Example" should "pass" in { 8 | 1 must be(1) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /examples/testing/scalatest_repositories/protobuf.patch: -------------------------------------------------------------------------------- 1 | ../../../protoc/0001-protobuf-19679-rm-protoc-dep.patch -------------------------------------------------------------------------------- /examples/testing/specs2_junit_repositories/.bazelrc: -------------------------------------------------------------------------------- 1 | import ../../../.bazelrc 2 | -------------------------------------------------------------------------------- /examples/testing/specs2_junit_repositories/.bazelversion: -------------------------------------------------------------------------------- 1 | 7.6.1 2 | -------------------------------------------------------------------------------- /examples/testing/specs2_junit_repositories/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/examples/testing/specs2_junit_repositories/BUILD -------------------------------------------------------------------------------- /examples/testing/specs2_junit_repositories/example/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_scala//scala:scala.bzl", "scala_specs2_junit_test") 2 | 3 | scala_specs2_junit_test( 4 | name = "example", 5 | srcs = ["Specs2ExampleTest.scala"], 6 | suffixes = ["Test"], 7 | ) 8 | -------------------------------------------------------------------------------- /examples/testing/specs2_junit_repositories/example/Specs2ExampleTest.scala: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | import org.specs2.mutable.SpecWithJUnit 4 | 5 | class Specs2ExampleTest extends SpecWithJUnit { 6 | "works" in { 7 | 1 mustEqual 1 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/testing/specs2_junit_repositories/protobuf.patch: -------------------------------------------------------------------------------- 1 | ../../../protoc/0001-protobuf-19679-rm-protoc-dep.patch -------------------------------------------------------------------------------- /java_stub_template/file/BUILD.bazel: -------------------------------------------------------------------------------- 1 | filegroup( 2 | name = "file", 3 | srcs = ["file.txt"], 4 | visibility = ["//visibility:public"], 5 | ) 6 | -------------------------------------------------------------------------------- /jmh/BUILD: -------------------------------------------------------------------------------- 1 | load("//jmh/toolchain:toolchain.bzl", "DEP_PROVIDERS", "export_toolchain_deps") 2 | 3 | [ 4 | export_toolchain_deps( 5 | name = provider, 6 | deps_id = provider, 7 | visibility = ["//visibility:public"], 8 | ) 9 | for provider in DEP_PROVIDERS 10 | ] 11 | -------------------------------------------------------------------------------- /jmh/toolchain/BUILD: -------------------------------------------------------------------------------- 1 | toolchain_type( 2 | name = "jmh_toolchain_type", 3 | visibility = ["//visibility:public"], 4 | ) 5 | -------------------------------------------------------------------------------- /junit/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/junit/BUILD -------------------------------------------------------------------------------- /junit/junit.bzl: -------------------------------------------------------------------------------- 1 | def junit_artifact_ids(): 2 | return [ 3 | "io_bazel_rules_scala_junit_junit", 4 | "io_bazel_rules_scala_org_hamcrest_hamcrest_core", 5 | ] 6 | -------------------------------------------------------------------------------- /lint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eou pipefail 4 | 5 | bazel run //tools:lint_fix 6 | -------------------------------------------------------------------------------- /manual_test/README.md: -------------------------------------------------------------------------------- 1 | # Manual test collection 2 | 3 | This directory contains tests that require extra setup such as extra bazel flags. 4 | -------------------------------------------------------------------------------- /manual_test/scala_test_jacocorunner/EmptyTest.scala: -------------------------------------------------------------------------------- 1 | package test_expect_failure.scala_test_jacocorunner 2 | 3 | import org.scalatest.funsuite._ 4 | 5 | class EmptyTest extends AnyFunSuite { 6 | test("empty test") { 7 | assert(true) 8 | } 9 | } -------------------------------------------------------------------------------- /manual_test/scala_test_jvm_flags/EmptyTest.scala: -------------------------------------------------------------------------------- 1 | package test_expect_failure.scala_test_jvm_flags 2 | 3 | import org.scalatest.funsuite._ 4 | 5 | class EmptyTest extends AnyFunSuite { 6 | test("empty test") { 7 | assert(true) 8 | } 9 | } -------------------------------------------------------------------------------- /manual_test/scalac_jvm_opts/Empty.scala: -------------------------------------------------------------------------------- 1 | package test_expect_failure.scalac_jvm_opts 2 | 3 | class Empty -------------------------------------------------------------------------------- /manual_test/scalac_jvm_opts/test.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | option java_package = "test.proto"; 4 | 5 | message TestResponse1 { 6 | optional uint32 c = 1; 7 | optional bool d = 2; 8 | } 9 | -------------------------------------------------------------------------------- /protoc/BUILD: -------------------------------------------------------------------------------- 1 | exports_files( 2 | ["toolchains.bzl"], 3 | visibility = ["//visibility:public"], 4 | ) 5 | 6 | toolchain_type( 7 | name = "toolchain_type", 8 | visibility = ["//visibility:public"], 9 | ) 10 | -------------------------------------------------------------------------------- /scala/PlaceHolderClassToCreateEmptyJarForScalaImport.java: -------------------------------------------------------------------------------- 1 | public class PlaceHolderClassToCreateEmptyJarForScalaImport {} 2 | -------------------------------------------------------------------------------- /scala/advanced_usage/providers.bzl: -------------------------------------------------------------------------------- 1 | """ 2 | A phase provider for customizable rules 3 | It is used only when you intend to add functionalities to existing default rules 4 | """ 5 | 6 | ScalaRulePhase = provider( 7 | doc = "A custom phase plugin", 8 | fields = { 9 | "custom_phases": "The phases to add. It takes an array of (relation, peer_name, phase_name, phase_function). Please refer to docs/customizable_phase.md for more details.", 10 | }, 11 | ) 12 | -------------------------------------------------------------------------------- /scala/extensions/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/scala/extensions/BUILD -------------------------------------------------------------------------------- /scala/jars_to_labels.bzl: -------------------------------------------------------------------------------- 1 | JarsToLabelsInfo = provider(fields = [ 2 | "jars_to_labels", # dict of path of a jar to a label 3 | ]) 4 | -------------------------------------------------------------------------------- /scala/private/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/scala/private/BUILD -------------------------------------------------------------------------------- /scala/private/common_outputs.bzl: -------------------------------------------------------------------------------- 1 | """Common outputs used in rule outputs""" 2 | 3 | common_outputs = { 4 | "jar": "%{name}.jar", 5 | "deploy_jar": "%{name}_deploy.jar", 6 | "manifest": "%{name}_MANIFEST.MF", 7 | "statsfile": "%{name}.statsfile", 8 | "diagnosticsfile": "%{name}.diagnosticsproto", 9 | "scaladepsfile": "%{name}.sdeps", 10 | } 11 | -------------------------------------------------------------------------------- /scala/private/extensions/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/scala/private/extensions/BUILD -------------------------------------------------------------------------------- /scala/private/paths.bzl: -------------------------------------------------------------------------------- 1 | java_extension = ".java" 2 | 3 | scala_extension = ".scala" 4 | 5 | srcjar_extension = ".srcjar" 6 | 7 | def get_files_with_extension(ctx, extension): 8 | return [ 9 | f 10 | for f in ctx.files.srcs 11 | if f.basename.endswith(extension) 12 | ] 13 | -------------------------------------------------------------------------------- /scala/private/phases/phase_collect_srcjars.bzl: -------------------------------------------------------------------------------- 1 | # 2 | # PHASE: collect srcjars 3 | # 4 | # DOCUMENT THIS 5 | # 6 | 7 | def phase_collect_srcjars(ctx, p): 8 | # This will be used to pick up srcjars from non-scala library 9 | # targets (like thrift code generation) 10 | srcjars = [] 11 | for target in ctx.attr.deps: 12 | if hasattr(target, "srcjars"): 13 | srcjars.append(target.srcjars.srcjar) 14 | return depset(srcjars) 15 | -------------------------------------------------------------------------------- /scala/private/phases/phase_declare_executable.bzl: -------------------------------------------------------------------------------- 1 | # 2 | # PHASE: declare executable 3 | # 4 | # DOCUMENT THIS 5 | # 6 | load("//scala/private:rule_impls.bzl", "is_windows") 7 | 8 | def phase_declare_executable(ctx, p): 9 | if (is_windows(ctx)): 10 | return struct( 11 | executable = ctx.actions.declare_file("%s.exe" % ctx.label.name), 12 | ) 13 | else: 14 | return struct( 15 | executable = ctx.actions.declare_file(ctx.label.name), 16 | ) 17 | -------------------------------------------------------------------------------- /scala/private/phases/phase_scalacopts.bzl: -------------------------------------------------------------------------------- 1 | def phase_scalacopts(ctx, p): 2 | toolchain = ctx.toolchains["//scala:toolchain_type"] 3 | return toolchain.scalacopts + ctx.attr.scalacopts 4 | -------------------------------------------------------------------------------- /scala/private/phases/phase_scalainfo_provider.bzl: -------------------------------------------------------------------------------- 1 | load("//scala:providers.bzl", "ScalaInfo") 2 | 3 | def _phase_scalainfo_provider_implementation(contains_macros): 4 | return struct( 5 | external_providers = { 6 | "ScalaInfo": ScalaInfo(contains_macros = contains_macros), 7 | }, 8 | ) 9 | 10 | def phase_scalainfo_provider_macro(ctx, p): 11 | return _phase_scalainfo_provider_implementation(contains_macros = True) 12 | 13 | def phase_scalainfo_provider_non_macro(ctx, p): 14 | return _phase_scalainfo_provider_implementation(contains_macros = False) 15 | -------------------------------------------------------------------------------- /scala/private/phases/phase_write_manifest.bzl: -------------------------------------------------------------------------------- 1 | # 2 | # PHASE: write manifest 3 | # 4 | # DOCUMENT THIS 5 | # 6 | load( 7 | "//scala/private:common.bzl", 8 | _write_manifest_file = "write_manifest_file", 9 | ) 10 | 11 | def phase_write_manifest(ctx, p): 12 | main_class = getattr(ctx.attr, "main_class", None) 13 | _write_manifest_file(ctx.actions, ctx.outputs.manifest, main_class) 14 | -------------------------------------------------------------------------------- /scala/private/toolchain_deps/toolchain_dep_rules.bzl: -------------------------------------------------------------------------------- 1 | load( 2 | "//scala/private/toolchain_deps:toolchain_deps.bzl", 3 | "expose_toolchain_deps", 4 | ) 5 | 6 | _TOOLCHAIN_TYPE = "//scala:toolchain_type" 7 | 8 | def _common_toolchain_deps(ctx): 9 | return expose_toolchain_deps(ctx, _TOOLCHAIN_TYPE) 10 | 11 | common_toolchain_deps = rule( 12 | implementation = _common_toolchain_deps, 13 | attrs = { 14 | "deps_id": attr.string(mandatory = True), 15 | }, 16 | toolchains = [_TOOLCHAIN_TYPE], 17 | ) 18 | -------------------------------------------------------------------------------- /scala/scalafmt/private/format.template.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | WORKSPACE_ROOT="${1:-$BUILD_WORKSPACE_DIRECTORY}" 3 | RUNPATH="${TEST_SRCDIR-$0.runfiles}"/%workspace% 4 | RUNPATH=(${RUNPATH//bin/ }) 5 | RUNPATH="${RUNPATH[0]}"bin 6 | 7 | while read original formatted; do 8 | if [[ ! -z "$original" ]] && [[ ! -z "$formatted" ]]; then 9 | if ! cmp -s "$WORKSPACE_ROOT/$original" "$RUNPATH/$formatted"; then 10 | echo "Formatting $original" 11 | cp "$RUNPATH/$formatted" "$WORKSPACE_ROOT/$original" 12 | fi 13 | fi 14 | done < "$RUNPATH"/%manifest% 15 | -------------------------------------------------------------------------------- /scala/scalafmt/scalafmt/ScalafmtAdapter-2_11.scala: -------------------------------------------------------------------------------- 1 | package io.bazel.rules_scala.scalafmt 2 | 3 | import java.io.File 4 | import org.scalafmt.config.Config 5 | import org.scalafmt.config.ScalafmtConfig 6 | import org.scalafmt.util.FileOps 7 | 8 | object ScalafmtAdapter { 9 | def readFile(file: File)(implicit codec: scala.io.Codec): String = 10 | FileOps.readFile(file)(codec) 11 | 12 | def parseConfigFile(configFile: File): ScalafmtConfig = 13 | Config.fromHoconFile(configFile).get 14 | } 15 | -------------------------------------------------------------------------------- /scala/scalafmt/scalafmt/ScalafmtAdapter.scala: -------------------------------------------------------------------------------- 1 | package io.bazel.rules_scala.scalafmt 2 | 3 | import java.io.File 4 | import org.scalafmt.config.ScalafmtConfig 5 | import org.scalafmt.sysops.PlatformFileOps 6 | 7 | object ScalafmtAdapter { 8 | def readFile(file: File)(implicit codec: scala.io.Codec): String = 9 | PlatformFileOps.readFile(file.toPath())(codec) 10 | 11 | def parseConfigFile(configFile: File): ScalafmtConfig = 12 | ScalafmtConfig.fromHoconFile(configFile.toPath()).get 13 | } 14 | -------------------------------------------------------------------------------- /scala/scalafmt/toolchain/BUILD: -------------------------------------------------------------------------------- 1 | toolchain_type( 2 | name = "scalafmt_toolchain_type", 3 | visibility = ["//visibility:public"], 4 | ) 5 | -------------------------------------------------------------------------------- /scala/scalatest/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | alias( 4 | name = "scalatest", 5 | actual = "//testing/toolchain:scalatest_classpath", 6 | deprecation = "Use //testing/toolchain:scalatest_classpath directly", 7 | ) 8 | -------------------------------------------------------------------------------- /scala/semanticdb_provider.bzl: -------------------------------------------------------------------------------- 1 | SemanticdbInfo = provider( 2 | fields = { 3 | "semanticdb_enabled": "boolean", 4 | "target_root": "directory containing the semanticdb files (relative to execroot).", 5 | "is_bundled_in_jar": "boolean: whether the semanticdb files are bundled inside the jar", 6 | "plugin_jar": "semanticdb plugin jar file", 7 | }, 8 | ) 9 | -------------------------------------------------------------------------------- /scala/settings/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala/settings:stamp_settings.bzl", "stamp_scala_import") 2 | 3 | stamp_scala_import( 4 | name = "stamp_scala_import", 5 | build_setting_default = True, 6 | visibility = ["//visibility:public"], 7 | ) 8 | -------------------------------------------------------------------------------- /scala/settings/stamp_settings.bzl: -------------------------------------------------------------------------------- 1 | StampScalaImport = provider(fields = ["enabled"]) 2 | 3 | def _impl(ctx): 4 | return StampScalaImport(enabled = ctx.build_setting_value) 5 | 6 | stamp_scala_import = rule( 7 | implementation = _impl, 8 | build_setting = config.bool(flag = True), 9 | ) 10 | -------------------------------------------------------------------------------- /scala/unstable/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/scala/unstable/BUILD -------------------------------------------------------------------------------- /scala_proto/BUILD: -------------------------------------------------------------------------------- 1 | load( 2 | "//scala_proto/private:toolchain_deps.bzl", 3 | "export_scalapb_toolchain_deps", 4 | ) 5 | 6 | toolchain_type( 7 | name = "toolchain_type", 8 | visibility = ["//visibility:public"], 9 | ) 10 | 11 | toolchain_type( 12 | name = "deps_toolchain_type", 13 | visibility = ["//visibility:public"], 14 | ) 15 | 16 | export_scalapb_toolchain_deps( 17 | name = "scalapb_worker_deps", 18 | deps_id = "scalapb_worker_deps", 19 | visibility = ["//visibility:public"], 20 | ) 21 | -------------------------------------------------------------------------------- /scala_proto/default/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/scala_proto/default/BUILD -------------------------------------------------------------------------------- /scala_proto/private/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/scala_proto/private/BUILD -------------------------------------------------------------------------------- /scala_proto/private/scala_proto_aspect_provider.bzl: -------------------------------------------------------------------------------- 1 | ScalaProtoAspectInfo = provider(fields = [ 2 | "java_info", 3 | ]) 4 | -------------------------------------------------------------------------------- /scala_proto/private/toolchain_deps.bzl: -------------------------------------------------------------------------------- 1 | load( 2 | "//scala/private/toolchain_deps:toolchain_deps.bzl", 3 | "expose_toolchain_deps", 4 | ) 5 | 6 | _DEPS_TOOLCHAIN_TYPE = "//scala_proto:deps_toolchain_type" 7 | 8 | def _export_scalapb_toolchain_deps(ctx): 9 | return expose_toolchain_deps(ctx, _DEPS_TOOLCHAIN_TYPE) 10 | 11 | export_scalapb_toolchain_deps = rule( 12 | _export_scalapb_toolchain_deps, 13 | attrs = { 14 | "deps_id": attr.string( 15 | mandatory = True, 16 | ), 17 | }, 18 | toolchains = [_DEPS_TOOLCHAIN_TYPE], 19 | ) 20 | -------------------------------------------------------------------------------- /scalatest/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/scalatest/BUILD -------------------------------------------------------------------------------- /specs2/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_import") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | java_import( 6 | name = "specs2", 7 | jars = [], 8 | exports = [ 9 | "//testing/toolchain:specs2_classpath", 10 | ], 11 | deps = [ 12 | "//scala/private/toolchain_deps:scala_xml", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /specs2/specs2.bzl: -------------------------------------------------------------------------------- 1 | def specs2_artifact_ids(): 2 | return [ 3 | "io_bazel_rules_scala_org_specs2_specs2_common", 4 | "io_bazel_rules_scala_org_specs2_specs2_core", 5 | "io_bazel_rules_scala_org_specs2_specs2_fp", 6 | "io_bazel_rules_scala_org_specs2_specs2_matcher", 7 | ] 8 | 9 | def specs2_dependencies(): 10 | return [Label("//specs2:specs2")] 11 | -------------------------------------------------------------------------------- /specs2/specs2_junit.bzl: -------------------------------------------------------------------------------- 1 | load("//specs2:specs2.bzl", "specs2_dependencies") 2 | 3 | def specs2_junit_artifact_ids(): 4 | return [ 5 | "io_bazel_rules_scala_org_specs2_specs2_junit", 6 | ] 7 | 8 | def specs2_junit_dependencies(): 9 | return specs2_dependencies() + [ 10 | Label("//testing/toolchain:specs2_junit_classpath"), 11 | ] 12 | -------------------------------------------------------------------------------- /src/java/io/bazel/rulesscala/io_utils/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_library") 2 | 3 | java_library( 4 | name = "io_utils", 5 | srcs = glob(["*.java"]), 6 | visibility = ["//visibility:public"], 7 | ) 8 | -------------------------------------------------------------------------------- /src/java/io/bazel/rulesscala/jar/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_binary", "java_library") 2 | 3 | java_library( 4 | name = "jar", 5 | srcs = [ 6 | "JarCreator.java", 7 | "JarHelper.java", 8 | ], 9 | visibility = ["//visibility:public"], 10 | ) 11 | 12 | java_binary( 13 | name = "binary", 14 | main_class = "io.bazel.rulesscala.jar.JarCreator", 15 | visibility = ["//visibility:public"], 16 | runtime_deps = [ 17 | ":jar", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /src/java/io/bazel/rulesscala/preconditions/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_library") 2 | 3 | java_library( 4 | name = "preconditions", 5 | srcs = glob(["*.java"]), 6 | visibility = ["//visibility:public"], 7 | ) 8 | -------------------------------------------------------------------------------- /src/java/io/bazel/rulesscala/preconditions/Preconditions.java: -------------------------------------------------------------------------------- 1 | package io.bazel.rulesscala.preconditions; 2 | 3 | public class Preconditions { 4 | public static void require(boolean value) { 5 | if (!value) { 6 | throw new IllegalArgumentException(); 7 | } 8 | } 9 | 10 | public static T requireNotNull(T value) { 11 | if (value == null) { 12 | throw new NullPointerException(); 13 | } 14 | 15 | return value; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/java/io/bazel/rulesscala/scala_test/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_library") 2 | 3 | java_library( 4 | name = "runner", 5 | srcs = ["Runner.java"], 6 | visibility = ["//visibility:public"], 7 | deps = [ 8 | "//testing/toolchain:scalatest_classpath", 9 | "@bazel_tools//tools/java/runfiles", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /src/java/io/bazel/rulesscala/scalac/ScalacInvokerResults.java: -------------------------------------------------------------------------------- 1 | package io.bazel.rulesscala.scalac; 2 | 3 | public class ScalacInvokerResults{ 4 | public long startTime; //unixTime ms 5 | public long stopTime; //unixTime ms 6 | } 7 | -------------------------------------------------------------------------------- /src/java/io/bazel/rulesscala/scalac/compileoptions/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_library", "java_test") 2 | 3 | java_library( 4 | name = "compileoptions", 5 | srcs = ["CompileOptions.java"], 6 | visibility = ["//visibility:public"], 7 | deps = ["//scala/private/toolchain_deps:scala_compile_classpath"], 8 | ) 9 | 10 | java_test( 11 | name = "CompileOptionsTest", 12 | srcs = ["CompileOptionsTest.java"], 13 | test_class = "io.bazel.rulesscala.scalac.compileoptions.CompileOptionsTest", 14 | deps = [":compileoptions"], 15 | ) 16 | -------------------------------------------------------------------------------- /src/java/io/bazel/rulesscala/scalac/reporter/since_3_3/CompilerCompat.java: -------------------------------------------------------------------------------- 1 | package io.bazel.rulesscala.scalac.reporter; 2 | 3 | import dotty.tools.dotc.core.Contexts; 4 | import dotty.tools.dotc.reporting.Message; 5 | import dotty.tools.dotc.reporting.NoExplanation; 6 | 7 | public class CompilerCompat { 8 | static Message toMessage(String msg) { 9 | return new NoExplanation((ctx) -> msg, Contexts.NoContext()); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/java/io/bazel/rulesscala/scalac/reporter/since_3_before_3_3/CompilerCompat.java: -------------------------------------------------------------------------------- 1 | package io.bazel.rulesscala.scalac.reporter; 2 | 3 | import dotty.tools.dotc.reporting.Message; 4 | import dotty.tools.dotc.reporting.NoExplanation; 5 | 6 | public class CompilerCompat { 7 | static Message toMessage(String msg) { 8 | return new NoExplanation(() -> msg); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/java/io/bazel/rulesscala/test_discovery/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "test_discovery", 5 | srcs = [ 6 | "ArchiveEntries.scala", 7 | "DiscoveredTestSuite.scala", 8 | "FilteredRunnerBuilder.scala", 9 | ], 10 | visibility = ["//visibility:public"], 11 | deps = ["//testing/toolchain:junit_classpath"], 12 | ) 13 | -------------------------------------------------------------------------------- /src/protobuf/io/bazel/rules_scala/BUILD: -------------------------------------------------------------------------------- 1 | load( 2 | "@com_google_protobuf//bazel:java_proto_library.bzl", 3 | "java_proto_library", 4 | ) 5 | load("@rules_proto//proto:defs.bzl", "proto_library") 6 | 7 | proto_library( 8 | name = "diagnostics_proto", 9 | srcs = ["diagnostics.proto"], 10 | ) 11 | 12 | java_proto_library( 13 | name = "diagnostics_java_proto", 14 | visibility = ["//visibility:public"], 15 | deps = [":diagnostics_proto"], 16 | ) 17 | -------------------------------------------------------------------------------- /src/scala/io/bazel/rules_scala/scrooge_support/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "compiler", 5 | srcs = [ 6 | "Compiler.scala", 7 | "FocusedZipImporter.scala", 8 | ], 9 | # util_core is still needed as a dep for older versions of scrooge 10 | unused_dependency_checker_mode = "off", 11 | visibility = ["//visibility:public"], 12 | deps = [ 13 | "//twitter_scrooge:compiler_classpath", 14 | ], 15 | ) 16 | -------------------------------------------------------------------------------- /src/scala/scripts/ScalaPbCodeGeneratorWrapper.scala: -------------------------------------------------------------------------------- 1 | package scripts 2 | 3 | import protocgen.{CodeGenApp,CodeGenRequest,CodeGenResponse} 4 | 5 | object ScalaPbCodeGenerator extends CodeGenApp { 6 | def process(request: CodeGenRequest): CodeGenResponse = 7 | scalapb.ScalaPbCodeGenerator.process(request) 8 | } 9 | -------------------------------------------------------------------------------- /test/A.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | object A { 4 | def main(args: Array[String]) { 5 | println("4 8 15 16 23 42") 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/D.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | object D { 4 | def main(args: Array[String]) { 5 | A.main(args) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/DataRoot1.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | 4 | object TestPointA { 5 | def getV: Int = 33 6 | } 7 | -------------------------------------------------------------------------------- /test/DataRoot2.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | 4 | object TestPointB { 5 | def getV: Int = 66 6 | } 7 | -------------------------------------------------------------------------------- /test/Exported.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | object Exported { 4 | def message: String = { 5 | // terrible, don't do this in real code: 6 | val msg = Class.forName("scalarules.test.Runtime") 7 | .newInstance 8 | .toString 9 | "you all, everybody. " + msg 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/JavaUsesScalaStdLib.java: -------------------------------------------------------------------------------- 1 | package scalarules.test; 2 | 3 | public class JavaUsesScalaStdLib { 4 | 5 | public static scala.collection.immutable.Map scalaMap(java.util.Map javaMap) { 6 | return null; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/LibToBin.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | object LibToBin { 4 | def foo = ScalaLibBinary.main(Array("foo")) 5 | } 6 | -------------------------------------------------------------------------------- /test/LibToTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | object LibToTest { 4 | def foo = TestUtil.foo 5 | } 6 | -------------------------------------------------------------------------------- /test/MacroTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | import language.experimental.macros 4 | 5 | import reflect.macros.whitebox.Context 6 | 7 | object MacroTest { 8 | def hello(param: Any): Unit = macro hello_impl 9 | 10 | def hello_impl(c: Context)(param: c.Expr[Any]): c.Expr[Unit] = { 11 | import c.universe._ 12 | val paramRep = show(param.tree) 13 | val paramRepTree = Literal(Constant(paramRep)) 14 | val paramRepExpr = c.Expr[String](paramRepTree) 15 | reify { println(paramRepExpr.splice + " = " + param.splice) } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/Runtime.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | class Runtime { 4 | override def toString = "I am Runtime" 5 | } 6 | -------------------------------------------------------------------------------- /test/ScalaBinaryJdk11.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | object ScalaBinaryJdk11 { 4 | def main(args: Array[String]): Unit = { 5 | val expectedMajorVersion = "11"; 6 | val version = System.getProperty("java.version"); 7 | val majorVersionMatches = version.startsWith(expectedMajorVersion + "."); 8 | val failureMsg = "Expected major version of " + expectedMajorVersion + " but got version: " + version; 9 | require(majorVersionMatches, failureMsg); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/ScalaTestData.scala: -------------------------------------------------------------------------------- 1 | import org.scalatest.flatspec.AnyFlatSpec 2 | 3 | import scala.io.Source 4 | 5 | class RunfileSpec extends AnyFlatSpec { 6 | 7 | "The text property" should "point to a runfile" in { 8 | Option(System.getProperty("text")) 9 | .map { path => 10 | val bufferedSource = Source.fromFile(path) 11 | for (line <- bufferedSource.getLines) { 12 | println(line.toUpperCase) 13 | } 14 | bufferedSource.close 15 | } 16 | .getOrElse(throw new IllegalStateException("text property missing")) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/SuiteUsage.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | 4 | object Usage { 5 | def totV: Int = TestPointA.getV + TestPointA.getV 6 | } 7 | -------------------------------------------------------------------------------- /test/TestFilterTestA.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | import org.scalatest.funspec.AnyFunSpec 4 | 5 | class TestFilterTestA extends AnyFunSpec { 6 | describe("A") { 7 | it("tests a") { 8 | assert(true) 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/TestFilterTestB.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | import org.scalatest.funspec.AnyFunSpec 4 | 5 | class TestFilterTestB extends AnyFunSpec { 6 | describe("B") { 7 | it("tests b") { 8 | assert(true) 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/UnusedLib.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | object UnusedLib -------------------------------------------------------------------------------- /test/aspect/A.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | object A { 4 | def main(args: Array[String]) { 5 | println("4 8 15 16 23 42") 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/aspect/B.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | object B { 4 | def main(args: Array[String]) { 5 | println("4 8 15 16 23 42") 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/aspect/FakeJunitTest.scala: -------------------------------------------------------------------------------- 1 | package test.aspect 2 | 3 | import org.junit.Test 4 | import org.junit.runner.RunWith 5 | import org.junit.runners.JUnit4 6 | 7 | @RunWith(classOf[JUnit4]) 8 | class FakeJunitTest { 9 | @Test 10 | def fakeTest(): Unit = {} 11 | } 12 | -------------------------------------------------------------------------------- /test/coverage_filename_encoding/A1.scala: -------------------------------------------------------------------------------- 1 | package coverage_filename_encoding 2 | 3 | object A1 { 4 | def a1(flag: Boolean): String = 5 | if (flag) "B1" 6 | else sys.error("oh noes") 7 | } 8 | -------------------------------------------------------------------------------- /test/coverage_filename_encoding/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library", "scala_specs2_junit_test") 2 | 3 | scala_specs2_junit_test( 4 | name = "name-with-equals", 5 | size = "small", 6 | srcs = ["Test.scala"], 7 | prefixes = ["Test"], 8 | deps = [ 9 | "a1%3D=%3D%2Bagg", 10 | ], 11 | ) 12 | 13 | scala_library( 14 | name = "a1%3D=%3D%2Bagg", 15 | srcs = [ 16 | "A1.scala", 17 | ], 18 | deps = [ 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /test/coverage_filename_encoding/Test.scala: -------------------------------------------------------------------------------- 1 | package coverage_filename_encoding 2 | 3 | import org.specs2.mutable.SpecWithJUnit 4 | 5 | class Test extends SpecWithJUnit { 6 | "testA1" in { 7 | A1.a1(true) must be_!=(1) 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/coverage_scalatest/A1.scala: -------------------------------------------------------------------------------- 1 | package coverage_scalatest 2 | 3 | object A1 { 4 | def a1(flag: Boolean): B1.type = 5 | if (flag) B1 6 | else sys.error("oh noes") 7 | } 8 | -------------------------------------------------------------------------------- /test/coverage_scalatest/A2.scala: -------------------------------------------------------------------------------- 1 | package coverage_scalatest 2 | 3 | object A2 { 4 | def a2(): Unit = { 5 | println("a2: " + B2.b2_a() 6 | ) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/coverage_scalatest/B1.scala: -------------------------------------------------------------------------------- 1 | package coverage_scalatest 2 | 3 | object B1 { 4 | 5 | def not_called(): Unit = { 6 | println("hello world") 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/coverage_scalatest/B2.java: -------------------------------------------------------------------------------- 1 | package coverage_scalatest; 2 | 3 | 4 | class B2 { 5 | public static String b2_a() { 6 | return C2.c2("hello from b2_a"); 7 | } 8 | 9 | public static void b2_b() { 10 | System.out.println("this is b2_b"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/coverage_scalatest/C2.scala: -------------------------------------------------------------------------------- 1 | package coverage_scalatest 2 | 3 | object C2 { 4 | def c2(input: String): String = 5 | input.reverse 6 | 7 | } 8 | -------------------------------------------------------------------------------- /test/coverage_scalatest/TestB2.java: -------------------------------------------------------------------------------- 1 | package coverage_scalatest; 2 | 3 | import org.junit.Test; 4 | 5 | public class TestB2 { 6 | 7 | @Test 8 | public void testB2() { 9 | B2.b2_b(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/coverage_scalatest/TestWithScalaTest.scala: -------------------------------------------------------------------------------- 1 | package coverage_scalatest 2 | 3 | import org.scalatest.flatspec._ 4 | 5 | class TestWithScalaTest extends AnyFlatSpec { 6 | 7 | "testA1" should "work" in { 8 | assert(A1.a1(true) == B1) 9 | } 10 | 11 | "testA2" should "work" in { 12 | A2.a2() 13 | } 14 | 15 | "testD1" should "work" in { 16 | D1.veryLongFunctionNameIsHereAaaaaaaaa() 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/coverage_scalatest_resources/consumer/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library", "scala_test") 2 | 3 | scala_library( 4 | name = "consumer", 5 | srcs = ["src/main/scala/com/example/consumer/Consumer.scala"], 6 | deps = ["//test/coverage_scalatest_resources/resource"], 7 | ) 8 | 9 | scala_test( 10 | name = "tests", 11 | srcs = [ 12 | "src/test/scala/com/example/consumer/ConsumerSpec.scala", 13 | ], 14 | deps = [":consumer"], 15 | ) 16 | -------------------------------------------------------------------------------- /test/coverage_scalatest_resources/consumer/src/main/scala/com/example/consumer/Consumer.scala: -------------------------------------------------------------------------------- 1 | package com.example.consumer 2 | 3 | import com.example.resource.Util 4 | 5 | import java.lang.Thread 6 | import java.net.URL 7 | import java.util.Enumeration 8 | 9 | class Consumer { 10 | val hello: String = Util.hello 11 | 12 | val classLoader = Thread.currentThread.getContextClassLoader 13 | val resourceList: Enumeration[URL] = classLoader.getResources("com/example/resource") 14 | } -------------------------------------------------------------------------------- /test/coverage_scalatest_resources/resource/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "resource", 5 | srcs = ["src/main/scala/com/example/resource/Util.scala"], 6 | resource_strip_prefix = "{}/{}".format( 7 | package_name(), 8 | "src/main/resources", 9 | ), 10 | resources = ["src/main/resources/com/example/resource/example.sql"], 11 | visibility = ["//visibility:public"], 12 | ) 13 | -------------------------------------------------------------------------------- /test/coverage_scalatest_resources/resource/src/main/resources/com/example/resource/example.sql: -------------------------------------------------------------------------------- 1 | Select * from TBL; -------------------------------------------------------------------------------- /test/coverage_scalatest_resources/resource/src/main/scala/com/example/resource/Util.scala: -------------------------------------------------------------------------------- 1 | package com.example.resource 2 | 3 | object Util { 4 | def hello: String = "Hello!" 5 | } -------------------------------------------------------------------------------- /test/coverage_specs2_with_junit/A1.scala: -------------------------------------------------------------------------------- 1 | package coverage_specs2_with_junit 2 | 3 | object A1 { 4 | def a1(flag: Boolean): B1.type = 5 | if (flag) B1 6 | else sys.error("oh noes") 7 | } 8 | -------------------------------------------------------------------------------- /test/coverage_specs2_with_junit/A2.scala: -------------------------------------------------------------------------------- 1 | package coverage_specs2_with_junit 2 | 3 | object A2 { 4 | def a2(): Unit = { 5 | println("a2: " + B2.b2_a() 6 | ) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/coverage_specs2_with_junit/B1.scala: -------------------------------------------------------------------------------- 1 | package coverage_specs2_with_junit 2 | 3 | object B1 { 4 | 5 | def not_called(): Unit = { 6 | println("hello world") 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/coverage_specs2_with_junit/B2.java: -------------------------------------------------------------------------------- 1 | package coverage_specs2_with_junit; 2 | 3 | 4 | class B2 { 5 | public static String b2_a() { 6 | return C2.c2("hello from b2_a"); 7 | } 8 | 9 | public static void b2_b() { 10 | System.out.println("this is b2_b"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/coverage_specs2_with_junit/C2.scala: -------------------------------------------------------------------------------- 1 | package coverage_specs2_with_junit 2 | 3 | object C2 { 4 | def c2(input: String): String = 5 | input.reverse 6 | 7 | } 8 | -------------------------------------------------------------------------------- /test/coverage_specs2_with_junit/E1.scala: -------------------------------------------------------------------------------- 1 | package coverage_specs2_with_junit 2 | 3 | object E1 { 4 | def e1(input: String): String = 5 | input.reverse 6 | } 7 | -------------------------------------------------------------------------------- /test/coverage_specs2_with_junit/TestWithSpecs2WithJUnit.scala: -------------------------------------------------------------------------------- 1 | package coverage_specs2_with_junit 2 | 3 | import org.specs2.mutable.SpecWithJUnit 4 | 5 | class TestWithSpecs2WithJUnit extends SpecWithJUnit { 6 | "testA1" in { 7 | A1.a1(true) must be_==(B1) 8 | } 9 | 10 | "testA2" in { 11 | A2.a2() 12 | success 13 | } 14 | 15 | "testD1" in { 16 | D1.veryLongFunctionNameIsHereAaaaaaaaa() 17 | success 18 | } 19 | 20 | "testE1" in { 21 | E1.e1("test") 22 | success 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/data/BUILD: -------------------------------------------------------------------------------- 1 | exports_files([ 2 | "some.txt", 3 | "more.txt", 4 | "foo.txt", 5 | ]) 6 | -------------------------------------------------------------------------------- /test/data/foo.txt: -------------------------------------------------------------------------------- 1 | this is a test of just random data in some path (not resources) 2 | -------------------------------------------------------------------------------- /test/data/more.txt: -------------------------------------------------------------------------------- 1 | more hellos 2 | -------------------------------------------------------------------------------- /test/data/some.txt: -------------------------------------------------------------------------------- 1 | this is a test of just random data in some path (not resources) 2 | -------------------------------------------------------------------------------- /test/example_jars/expected_service_manifest.txt: -------------------------------------------------------------------------------- 1 | org.apache.beam.sdk.extensions.gcp.storage.GcsFileSystemRegistrar 2 | org.apache.beam.sdk.io.LocalFileSystemRegistrar 3 | -------------------------------------------------------------------------------- /test/example_jars/src/main/resources/META-INF/services/org.apache.beam.sdk.io.FileSystemRegistrar: -------------------------------------------------------------------------------- 1 | org.apache.beam.sdk.io.LocalFileSystemRegistrar 2 | -------------------------------------------------------------------------------- /test/gen_src/BUILD: -------------------------------------------------------------------------------- 1 | load( 2 | "//scala:scala.bzl", 3 | "scala_binary", 4 | ) 5 | 6 | scala_binary( 7 | name = "src_generator", 8 | srcs = ["SrcGenerator.scala"], 9 | main_class = "build.bazel.rulesscala.test.srcgen.SrcGenerator", 10 | ) 11 | 12 | genrule( 13 | name = "foo", 14 | srcs = [], 15 | outs = ["foo.scala"], 16 | cmd = "./$(location src_generator) hello foo > \"$@\"", 17 | tools = ["src_generator"], 18 | ) 19 | 20 | scala_binary( 21 | name = "uses_gen_file", 22 | srcs = ["foo.scala"], 23 | main_class = "Foo", 24 | ) 25 | -------------------------------------------------------------------------------- /test/gen_src/SrcGenerator.scala: -------------------------------------------------------------------------------- 1 | package build.bazel.rulesscala.test.srcgen 2 | 3 | object SrcGenerator { 4 | def main(args: Array[String]): Unit = { 5 | println(s""" 6 | object Foo { 7 | def hello: String = "hello ${args.toList}" 8 | def main(args: Array[String]): Unit = println(hello) 9 | }""") 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/jar_lister.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | import zipfile 3 | import sys 4 | 5 | for n in zipfile.ZipFile(sys.argv[1]).namelist(): 6 | print(n) 7 | -------------------------------------------------------------------------------- /test/jmh/AddNumbers.scala: -------------------------------------------------------------------------------- 1 | package foo 2 | 3 | object AddNumbers { 4 | def addUntil1000: Int = { 5 | (0 until 1000).reduce(_ + _) 6 | } 7 | } -------------------------------------------------------------------------------- /test/jmh/JavaType.java: -------------------------------------------------------------------------------- 1 | package foo; 2 | 3 | public class JavaType { 4 | public int i = 0; 5 | } 6 | -------------------------------------------------------------------------------- /test/jmh/ScalaType.scala: -------------------------------------------------------------------------------- 1 | package foo 2 | 3 | case class ScalaType(n : Int) -------------------------------------------------------------------------------- /test/jmh/TestBenchmark.scala: -------------------------------------------------------------------------------- 1 | package foo 2 | 3 | import org.openjdk.jmh.annotations.{Benchmark, Scope, State} 4 | import java.nio.file.{Files, Paths} 5 | 6 | class TestBenchmark { 7 | @State(Scope.Benchmark) 8 | class BenchmarkState { 9 | val myScalaType = ScalaType(100) 10 | val myJavaType = new JavaType 11 | } 12 | 13 | @Benchmark 14 | def sumIntegersBenchmark: Int = 15 | AddNumbers.addUntil1000 16 | 17 | @Benchmark 18 | def fileAccessBenchmark: Unit = { 19 | val path = Paths.get("test/jmh/data.txt") 20 | Files.readAllLines(path) 21 | } 22 | } -------------------------------------------------------------------------------- /test/jmh/data.txt: -------------------------------------------------------------------------------- 1 | Hello world! -------------------------------------------------------------------------------- /test/jmh/test_binary.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "Executing: " $@ 4 | $@ 5 | -------------------------------------------------------------------------------- /test/longnames/looooooongnaaaaaaame/anooooootherlooooooooongname/anooooootherlooooooooongname2/anooooootherlooooooooongname3/LongNamesTest.scala: -------------------------------------------------------------------------------- 1 | package test.longnames.looooooongnaaaaaaame.anooooootherlooooooooongname.anooooootherlooooooooongname2.anooooootherlooooooooongname3 2 | 3 | import org.scalatest._ 4 | import flatspec._ 5 | import matchers.should._ 6 | 7 | class SomeLoooooooongTestNaaaaaaaaaaaaaaaaaaaaaaaame extends AnyFlatSpec with Matchers { 8 | "This test" should "pass" in { 9 | assert(true) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/macros/IdentityMacro.scala: -------------------------------------------------------------------------------- 1 | package macros 2 | 3 | import scala.language.experimental.macros 4 | import scala.reflect.macros.blackbox 5 | 6 | object IdentityMacro { 7 | def identityMacro[A](value: A): A = macro identityMacroImpl[A] 8 | def identityMacroImpl[A](context: blackbox.Context)(value: context.Expr[A]): context.Expr[A] = value 9 | } 10 | -------------------------------------------------------------------------------- /test/macros/MacroDependency.scala: -------------------------------------------------------------------------------- 1 | package macros 2 | 3 | object MacroDependency { 4 | def isEven(number: Int): Boolean = number % 2 == 0 5 | } 6 | -------------------------------------------------------------------------------- /test/macros/MacroUser.scala: -------------------------------------------------------------------------------- 1 | package macros 2 | 3 | object Main { 4 | def main(arguments: Array[String]): Unit = println(IdentityMacro.identityMacro("Hello, world!")) 5 | } 6 | -------------------------------------------------------------------------------- /test/macros/MacroWithDependenciesUser.scala: -------------------------------------------------------------------------------- 1 | package macros 2 | 3 | object MacroWithDependenciesUser { 4 | def main(arguments: Array[String]): Unit = { 5 | println(s"0 is even via macro: ${MacroWithDependencies.isEvenMacro(0)}") 6 | println(s"1 is even via macro: ${MacroWithDependencies.isEvenMacro(1)}") 7 | println(s"1 + 1 is even macro: ${MacroWithDependencies.isEvenMacro(1 + 1)}") 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/no_sigs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | OUTPUT1=`$1 $2 | grep DSA` 4 | OUTPUT2=`$1 $2 | grep RSA` 5 | 6 | if [[ $OUTPUT1 ]]; then 7 | echo $OUTPUT1 8 | exit 1 9 | fi 10 | if [[ $OUTPUT2 ]]; then 11 | echo $OUTPUT2 12 | exit 1 13 | fi 14 | -------------------------------------------------------------------------------- /test/phase/add_to_all_rules/PhaseBinary.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.phase.add_to_all_rules 2 | 3 | object PhaseBinary { 4 | def main(args: Array[String]) { 5 | val message = "You can customize binary phases!" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/phase/add_to_all_rules/PhaseJunitTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.phase.add_to_all_rules 2 | 3 | import org.junit.Test 4 | 5 | class PhaseJunitTest { 6 | @Test 7 | def someTest: Unit = { 8 | val message = "You can customize junit test phases!" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/phase/add_to_all_rules/PhaseLibrary.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.phase.add_to_all_rules 2 | 3 | object PhaseLibrary { 4 | val message = "You can customize library phases!" 5 | } 6 | -------------------------------------------------------------------------------- /test/phase/add_to_all_rules/PhaseTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.phase.add_to_all_rules 2 | 3 | import org.scalatest.flatspec._ 4 | 5 | class PhaseTest extends AnyFlatSpec { 6 | val message = "You can customize test phases!" 7 | "HelloTest" should "be able to customize test phases!" in { 8 | assert(message.equals("You can customize test phases!")) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/phase/add_to_all_rules/phase_add_to_all_rules.bzl: -------------------------------------------------------------------------------- 1 | # 2 | # PHASE: add to all rules 3 | # 4 | # A dummy test phase to make sure phase is working for all rules 5 | # 6 | def phase_add_to_all_rules(ctx, p): 7 | ctx.actions.write( 8 | output = ctx.outputs.custom_output, 9 | content = ctx.attr.custom_content, 10 | ) 11 | -------------------------------------------------------------------------------- /test/phase/adjustment/PhaseLibrary.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.phase.adjustment 2 | 3 | object PhaseLibrary { 4 | val message = "You can customize library phases!" 5 | } 6 | -------------------------------------------------------------------------------- /test/plugins/trivial.scala: -------------------------------------------------------------------------------- 1 | package trivial 2 | 3 | object Trivial { 4 | // feel free to reuse this file for other plugin tests 5 | } 6 | -------------------------------------------------------------------------------- /test/proto/BlackListedProtoTest.scala: -------------------------------------------------------------------------------- 1 | import org.scalatest.flatspec._ 2 | 3 | import scala.util.Try 4 | 5 | class BlackListedProtoTest extends AnyFlatSpec { 6 | 7 | "looking for a blacklisted proto" should "fail" in { 8 | // The direct test dep should be here. 9 | test.proto.test_service.TestServiceGrpc 10 | 11 | assert( 12 | Try(Class.forName("test.proto.blacklisted_proto.BlackListedProtoMessage")).isFailure) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/proto/CustomGeneratedObjectTest.scala: -------------------------------------------------------------------------------- 1 | import org.scalatest.flatspec._ 2 | 3 | import scala.util.Try 4 | 5 | class CustomGeneratedObjectTest extends AnyFlatSpec { 6 | 7 | "Looking for the custom generated class" should "succeed" in { 8 | test_external_dep.CustomTestMessage 9 | assert( 10 | Try(Class.forName("test_external_dep.CustomTestMessage$")).isSuccess) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/proto/blacklisted_proto.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | option java_package = "test.proto"; 4 | 5 | message BlackListedProtoMessage { 6 | optional uint32 c = 1; 7 | optional bool d = 2; 8 | } 9 | -------------------------------------------------------------------------------- /test/proto/custom_generator/DummyGeneratorTest.scala: -------------------------------------------------------------------------------- 1 | package test.proto.custom_generator 2 | 3 | import org.scalatest.flatspec.AnyFlatSpec 4 | import org.scalatest.matchers._ 5 | 6 | class DummyGeneratorTest extends AnyFlatSpec with should.Matchers { 7 | 8 | "dummy generator" should "generate a dummy object" in { 9 | noException should be thrownBy Class.forName("custom_generator.dummy") 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/proto/custom_generator/FailingGenerator.scala: -------------------------------------------------------------------------------- 1 | package test.proto.custom_generator 2 | 3 | object FailingGenerator extends protocbridge.ProtocCodeGenerator { 4 | override def run(request: Array[Byte]): Array[Byte] = 5 | throw new RuntimeException("expected generator failure") 6 | } 7 | -------------------------------------------------------------------------------- /test/proto/different_root.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "different_root2.proto"; 4 | 5 | message TestMessage { 6 | TestMessage2 message = 1; 7 | } -------------------------------------------------------------------------------- /test/proto/different_root2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | message TestMessage2 { 4 | string message = 1; 5 | } -------------------------------------------------------------------------------- /test/proto/some/path/nested.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | message Message { 4 | } 5 | -------------------------------------------------------------------------------- /test/proto/standalone.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | message Message { 4 | } 5 | -------------------------------------------------------------------------------- /test/proto/test2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | import "test/proto2/test.proto"; 4 | option java_package = "test.proto"; 5 | 6 | message TestResponse1 { 7 | optional uint32 c = 1; 8 | optional bool d = 2; 9 | optional TestMessage testMsg = 3; 10 | } 11 | -------------------------------------------------------------------------------- /test/proto/test3.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | import "test/proto2/test.proto"; 4 | option java_package = "test.proto"; 5 | 6 | message TestResponse2 { 7 | optional uint32 e = 1; 8 | optional bool f = 2; 9 | optional TestMessage testMsg = 3; 10 | } 11 | -------------------------------------------------------------------------------- /test/proto/test_external_dep.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "google/protobuf/wrappers.proto"; 4 | 5 | message TestMessage { 6 | string message = 1; 7 | } -------------------------------------------------------------------------------- /test/proto/test_service.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | import "test/proto2/test.proto"; 4 | import "test/proto/test2.proto"; 5 | import "test/proto/test3.proto"; 6 | 7 | option java_package = "test.proto"; 8 | 9 | service TestService { 10 | rpc TestMethod1 (TestRequest) returns (TestResponse1) {} 11 | rpc TestMethod2 (TestRequest) returns (TestResponse2) {} 12 | } 13 | -------------------------------------------------------------------------------- /test/proto2/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_proto//proto:defs.bzl", "proto_library") 2 | 3 | proto_library( 4 | name = "test", 5 | srcs = ["test.proto"], 6 | visibility = ["//visibility:public"], 7 | ) 8 | -------------------------------------------------------------------------------- /test/proto2/test.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | option java_package = "test.proto"; 4 | 5 | message TestRequest { 6 | optional uint32 a = 1; 7 | optional bool b = 2; 8 | } 9 | 10 | message TestMessage { 11 | optional string foo = 1; 12 | } 13 | -------------------------------------------------------------------------------- /test/proto3/test.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | option java_package = "test.proto"; 4 | 5 | message TestRequest { 6 | optional uint32 a = 1; 7 | optional bool b = 2; 8 | } 9 | 10 | message TestMessage { 11 | optional string foo = 1; 12 | } 13 | -------------------------------------------------------------------------------- /test/proto_cross_repo_boundary/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala_proto:scala_proto.bzl", "scala_proto_library") 2 | 3 | scala_proto_library( 4 | name = "sample_scala_proto", 5 | visibility = ["//visibility:public"], 6 | deps = ["@proto_cross_repo_boundary//:sample_proto"], 7 | ) 8 | -------------------------------------------------------------------------------- /test/proto_cross_repo_boundary/repo/.bazelversion: -------------------------------------------------------------------------------- 1 | 7.6.1 2 | -------------------------------------------------------------------------------- /test/proto_cross_repo_boundary/repo/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_proto//proto:defs.bzl", "proto_library") 2 | 3 | proto_library( 4 | name = "sample_proto", 5 | srcs = ["sample.proto"], 6 | visibility = ["//visibility:public"], 7 | ) 8 | -------------------------------------------------------------------------------- /test/proto_cross_repo_boundary/repo/MODULE.bazel: -------------------------------------------------------------------------------- 1 | module(name = "proto_cross_repo_boundary") 2 | 3 | bazel_dep(name = "rules_proto", version = "7.1.0") 4 | -------------------------------------------------------------------------------- /test/proto_cross_repo_boundary/repo/WORKSPACE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/test/proto_cross_repo_boundary/repo/WORKSPACE -------------------------------------------------------------------------------- /test/proto_cross_repo_boundary/repo/sample.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package sample; 4 | 5 | option java_package = "sample"; 6 | 7 | message Sample { 8 | repeated string foobar = 1; 9 | } -------------------------------------------------------------------------------- /test/py_resource.py: -------------------------------------------------------------------------------- 1 | # Empty file just need to be used for reference -------------------------------------------------------------------------------- /test/rootpaths_binary.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eou pipefail 4 | 5 | content="$(cat $1)" 6 | 7 | function is_windows() { 8 | [[ "${OSTYPE}" =~ msys* ]] || [[ "${OSTYPE}" =~ cygwin* ]] 9 | } 10 | 11 | # Windows needs .exe suffix 12 | if is_windows; then 13 | binary_ext=".exe" 14 | else 15 | binary_ext="" 16 | fi 17 | 18 | expected="test/ScalaBinary${binary_ext}"$'\ntest/ScalaBinary.jar' 19 | 20 | if [ "$content" != "$expected" ]; then 21 | echo "Unexpected rootpaths: $content" 22 | echo "$expected" 23 | exit 1 24 | fi 25 | -------------------------------------------------------------------------------- /test/scala_test/A.scala: -------------------------------------------------------------------------------- 1 | import org.scalatest.funsuite._ 2 | 3 | abstract class A extends AnyFunSuite { 4 | val Number: Int 5 | 6 | test("number is positive") { 7 | assert(Number > 0) 8 | } 9 | } -------------------------------------------------------------------------------- /test/scala_test/B.scala: -------------------------------------------------------------------------------- 1 | 2 | class B extends A { 3 | override val Number: Int = 12 4 | } 5 | -------------------------------------------------------------------------------- /test/scala_test/CustomReporter.scala: -------------------------------------------------------------------------------- 1 | package test.scala_test 2 | 3 | import java.io.{File, PrintWriter} 4 | import java.nio.file.Paths 5 | 6 | import org.scalatest._ 7 | import org.scalatest.events.Event 8 | 9 | class CustomReporter extends Reporter { 10 | override def apply(event: Event): Unit = { 11 | val flagDir = sys.env("TEST_UNDECLARED_OUTPUTS_DIR") 12 | val file = new File(Paths.get(flagDir, "custom_reporter_check").toUri) 13 | val writer = new PrintWriter(file) 14 | writer.write("It's from custom reporter") 15 | writer.close() 16 | } 17 | } -------------------------------------------------------------------------------- /test/scalac/srcjars/DuplicatesTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.scalac.srcjars 2 | 3 | import org.scalatest.funsuite.AnyFunSuite 4 | import org.scalatest.matchers.must.Matchers._ 5 | import test.{A, ADuplicate} 6 | 7 | class DuplicatesTest extends AnyFunSuite { 8 | test("all classes from duplicated files are available") { 9 | noException should be thrownBy classOf[A] 10 | noException should be thrownBy classOf[ADuplicate] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/scalac/srcjars/duplicate/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//test/scalac/srcjars:setup.bzl", "single_scala_file_srcjar") 2 | 3 | single_scala_file_srcjar(content = "package test {class ADuplicate}") 4 | -------------------------------------------------------------------------------- /test/scalacopts/A.scala: -------------------------------------------------------------------------------- 1 | package scalacopts 2 | 3 | import scala.reflect.macros.blackbox 4 | import scala.language.experimental.macros 5 | 6 | object Macros { 7 | def hello: String = macro macroSettings 8 | 9 | def macroSettings(c: blackbox.Context): c.Expr[String] = { 10 | import c.universe._ 11 | // c.settings are the values from scalac's -Xmacro-settings 12 | val s = c.settings.mkString(",") 13 | c.Expr(q"""${s}""") 14 | } 15 | } -------------------------------------------------------------------------------- /test/scalacopts/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_macro_library", "scala_test") 2 | 3 | scala_macro_library( 4 | name = "A", 5 | srcs = ["A.scala"], 6 | ) 7 | 8 | scala_test( 9 | name = "EchoMacroSettings", 10 | srcs = ["EchoMacroSettings.scala"], 11 | scalacopts = [ 12 | # The macro settings are used in the test itself. 13 | "-Xmacro-settings:name=Mike,location=US", 14 | "-Xmacro-settings:hobby=basketball,soccer", 15 | ], 16 | deps = [ 17 | ":A", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /test/scalafmt/.scalafmt.conf: -------------------------------------------------------------------------------- 1 | version = "3.9.6" 2 | runner.dialect = scala213 3 | maxColumn = 40 4 | lineEndings = preserve 5 | -------------------------------------------------------------------------------- /test/scalafmt/formatted/formatted-custom-conf.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.scalafmt 2 | object Format { 3 | def main(args: Array[String]) { 4 | val warnings: String = 5 | "Be careful with this test. The column number is limited to 40, so it should be in new line." 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/scalafmt/formatted/formatted-encoding.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.scalafmt 2 | object Format { 3 | def main(args: Array[String]) { 4 | val warnings: List[String] = List( 5 | "Be careful with this test", 6 | "小心這個測試", 7 | "このテストに注意してください", 8 | "이 시험에 조심하십시오", 9 | "😁✊🚀🍟💯" 10 | ) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/scalafmt/formatted/formatted-test.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.scalafmt 2 | import org.scalatest.flatspec._ 3 | class FormatTest extends AnyFlatSpec { 4 | "FormatTest" should "be formatted" in { 5 | assert(true) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/scalafmt/phase_scalafmt_test.bzl: -------------------------------------------------------------------------------- 1 | load( 2 | "//scala:advanced_usage/scala.bzl", 3 | "make_scala_binary", 4 | "make_scala_library", 5 | "make_scala_test", 6 | ) 7 | load( 8 | "//scala/scalafmt:phase_scalafmt_ext.bzl", 9 | "ext_scalafmt", 10 | ) 11 | 12 | scalafmt_scala_binary = make_scala_binary(ext_scalafmt) 13 | 14 | scalafmt_scala_library = make_scala_library(ext_scalafmt) 15 | 16 | scalafmt_scala_test = make_scala_test(ext_scalafmt) 17 | -------------------------------------------------------------------------------- /test/scalafmt/unformatted/unformatted-custom-conf.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.scalafmt 2 | object Format { 3 | def main(args: Array[String]) { 4 | val warnings: String = "Be careful with this test. The column number is limited to 40, so it should be in new line." 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/scalafmt/unformatted/unformatted-encoding.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.scalafmt 2 | object Format { 3 | def main ( args: 4 | 5 | 6 | Array [String ]) { 7 | val warnings : List [ String ] = List( 8 | "Be careful with this test", 9 | "小心這個測試", 10 | "このテストに注意してください", 11 | "이 시험에 조심하십시오", 12 | "😁✊🚀🍟💯" 13 | ) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/scalafmt/unformatted/unformatted-test.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.scalafmt 2 | import org.scalatest.flatspec._ 3 | class FormatTest extends AnyFlatSpec { 4 | "FormatTest" should "be formatted" in { 5 | assert ( true ) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/semanticdb/A.scala: -------------------------------------------------------------------------------- 1 | class A {} 2 | -------------------------------------------------------------------------------- /test/semanticdb/B.scala: -------------------------------------------------------------------------------- 1 | class B {} 2 | -------------------------------------------------------------------------------- /test/semanticdb/semantic_provider_vars.sh.template: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | semanticdb_target_root="%TARGETROOT%" 3 | semanticdb_enabled=%ENABLED% 4 | semanticdb_is_bundled=%ISBUNDLED% 5 | semanticdb_pluginjarpath="%PLUGINPATH%" -------------------------------------------------------------------------------- /test/shell/test_inherited_environment.sh: -------------------------------------------------------------------------------- 1 | # shellcheck source=./test_runner.sh 2 | dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 3 | . "${dir}"/test_runner.sh 4 | . "${dir}"/test_helper.sh 5 | runner=$(get_test_runner "${1:-local}") 6 | 7 | function test_inherited_environment() { 8 | a=b bazel test //test_expect_failure/scala_test_env_inherit:inherit_a 9 | } 10 | 11 | $runner test_inherited_environment -------------------------------------------------------------------------------- /test/src/main/resources/META-INF/BUILD: -------------------------------------------------------------------------------- 1 | exports_files([ 2 | "FAKE.DSA", 3 | "FAKE.RSA", 4 | ]) 5 | -------------------------------------------------------------------------------- /test/src/main/resources/META-INF/FAKE.DSA: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/test/src/main/resources/META-INF/FAKE.DSA -------------------------------------------------------------------------------- /test/src/main/resources/META-INF/FAKE.RSA: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/test/src/main/resources/META-INF/FAKE.RSA -------------------------------------------------------------------------------- /test/src/main/resources/META-INF/services/BUILD: -------------------------------------------------------------------------------- 1 | exports_files([ 2 | "org.apache.beam.sdk.io.FileSystemRegistrar", 3 | ]) 4 | -------------------------------------------------------------------------------- /test/src/main/resources/META-INF/services/org.apache.beam.sdk.io.FileSystemRegistrar: -------------------------------------------------------------------------------- 1 | org.apache.beam.sdk.extensions.gcp.storage.GcsFileSystemRegistrar -------------------------------------------------------------------------------- /test/src/main/resources/java_sources/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | scala_library( 6 | name = "CompiledWithJava8", 7 | srcs = ["SimpleJavaSourceFileA.java"], 8 | java_compile_toolchain = "@rules_java//toolchains:toolchain_java8", 9 | ) 10 | 11 | scala_library( 12 | name = "CompiledWithJava11", 13 | srcs = ["SimpleJavaSourceFileB.java"], 14 | java_compile_toolchain = "@rules_java//toolchains:toolchain_java11", 15 | ) 16 | -------------------------------------------------------------------------------- /test/src/main/resources/java_sources/SimpleJavaSourceFileA.java: -------------------------------------------------------------------------------- 1 | package java_sources; 2 | 3 | public class SimpleJavaSourceFileA { 4 | 5 | public int someIntField; 6 | 7 | public SimpleJavaSourceFileA() { 8 | this.someIntField = 0; 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/src/main/resources/java_sources/SimpleJavaSourceFileB.java: -------------------------------------------------------------------------------- 1 | package java_sources; 2 | 3 | public class SimpleJavaSourceFileB { 4 | 5 | public int someIntField; 6 | 7 | public SimpleJavaSourceFileB() { 8 | this.someIntField = 0; 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/src/main/resources/scalarules/test/BUILD: -------------------------------------------------------------------------------- 1 | exports_files([ 2 | "byes", 3 | "hellos", 4 | "more-byes", 5 | "more-hellos", 6 | "Foo.thrift", 7 | "Bar.thrift", 8 | "Baz.thrift", 9 | ]) 10 | 11 | genrule( 12 | name = "generated-hello", 13 | outs = ["generated-hello.txt"], 14 | cmd = "echo 'hello' > $@", 15 | visibility = ["//visibility:public"], 16 | ) 17 | -------------------------------------------------------------------------------- /test/src/main/resources/scalarules/test/Bar.thrift: -------------------------------------------------------------------------------- 1 | namespace java com.foo.bar.baz 2 | 3 | struct Bar { 4 | 1: optional string Bar 5 | } 6 | -------------------------------------------------------------------------------- /test/src/main/resources/scalarules/test/Baz.thrift: -------------------------------------------------------------------------------- 1 | namespace java com.foo.bar.baz 2 | 3 | struct Baz { 4 | 1: optional string Baz 5 | } 6 | -------------------------------------------------------------------------------- /test/src/main/resources/scalarules/test/Foo.thrift: -------------------------------------------------------------------------------- 1 | namespace java com.foo.bar.baz 2 | 3 | struct Foo { 4 | 1: optional string foo 5 | } 6 | -------------------------------------------------------------------------------- /test/src/main/resources/scalarules/test/byes: -------------------------------------------------------------------------------- 1 | see ya 2 | later 3 | A hui hou 4 | -------------------------------------------------------------------------------- /test/src/main/resources/scalarules/test/classpath_resource1/BUILD: -------------------------------------------------------------------------------- 1 | exports_files(["classpath-resource"]) 2 | -------------------------------------------------------------------------------- /test/src/main/resources/scalarules/test/classpath_resource1/classpath-resource: -------------------------------------------------------------------------------- 1 | classpath resource 1 2 | -------------------------------------------------------------------------------- /test/src/main/resources/scalarules/test/classpath_resource2/BUILD: -------------------------------------------------------------------------------- 1 | exports_files(["classpath-resource"]) 2 | -------------------------------------------------------------------------------- /test/src/main/resources/scalarules/test/classpath_resource2/classpath-resource: -------------------------------------------------------------------------------- 1 | classpath resource 2 2 | -------------------------------------------------------------------------------- /test/src/main/resources/scalarules/test/hellos: -------------------------------------------------------------------------------- 1 | Hello 2 | Guten Tag 3 | Bonjour 4 | -------------------------------------------------------------------------------- /test/src/main/resources/scalarules/test/more-byes: -------------------------------------------------------------------------------- 1 | more see ya 2 | more later 3 | A more hui hou 4 | -------------------------------------------------------------------------------- /test/src/main/resources/scalarules/test/more-hellos: -------------------------------------------------------------------------------- 1 | More Hello 2 | More Bonjour 3 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/BinaryDependentOnJava.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | object BinaryDependentOnJava extends App { 4 | println(classOf[Alpha]) 5 | } 6 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/classpath_resources/ObjectWithDuplicateClasspathResources.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.classpathresources 2 | 3 | object ObjectWithDuplicateClasspathResources extends App 4 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/compiler_plugin/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "compiler_plugin", 5 | testonly = True, 6 | srcs = ["KindProjected.scala"], 7 | plugins = ["@org_typelevel_kind_projector//jar"], 8 | visibility = ["//visibility:public"], 9 | ) 10 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/compiler_plugin/KindProjected.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.compiler_plugin 2 | 3 | import scala.language.higherKinds 4 | 5 | class HKT[F[_]] 6 | class KKTImpl extends HKT[Either[String, *]] -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/disappearing_class/ClassProvider.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | object BackgroundNoise{} 4 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/duplicated_resources/child/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_test") 2 | 3 | # https://github.com/bazelbuild/rules_scala/issues/1455 4 | scala_test( 5 | name = "child", 6 | size = "small", 7 | srcs = ["ScalaLibResourcesDuplicatedTest.scala"], 8 | resource_strip_prefix = "test/src/main/scala/scalarules/test/duplicated_resources/child/", 9 | resources = ["resource.txt"], 10 | unused_dependency_checker_mode = "off", 11 | deps = ["//test/src/main/scala/scalarules/test/duplicated_resources/parent"], 12 | ) 13 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/duplicated_resources/child/resource.txt: -------------------------------------------------------------------------------- 1 | I am a text resource from child! 2 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/duplicated_resources/parent/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "parent", 5 | resource_strip_prefix = "test/src/main/scala/scalarules/test/duplicated_resources/parent/", 6 | resources = ["resource.txt"], 7 | visibility = ["//test/src/main/scala/scalarules/test/duplicated_resources/child:__pkg__"], 8 | ) 9 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/duplicated_resources/parent/resource.txt: -------------------------------------------------------------------------------- 1 | I am a text resource from parent! 2 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/extra_protobuf_generator/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | load("//scala:scala_cross_version_select.bzl", "select_for_scala_version") 3 | 4 | scala_library( 5 | name = "extra_protobuf_generator", 6 | srcs = select_for_scala_version( 7 | any_2_11 = ["ProtobufAdapter_2_11.scala"], 8 | since_2_12 = ["ProtobufAdapter.scala"], 9 | ) + ["ExtraProtobufGenerator.scala"], 10 | visibility = ["//visibility:public"], 11 | deps = [ 12 | "//scala_proto:scalapb_worker_deps", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/extra_protobuf_generator/ProtobufAdapter.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.extra_protobuf_generator 2 | 3 | import com.google.protobuf.Descriptors.{Descriptor, FileDescriptor} 4 | import scalapb.compiler.DescriptorImplicits 5 | 6 | class ProtobufAdapter(implicits: DescriptorImplicits) { 7 | import implicits._ 8 | 9 | def nameSymbol(message: Descriptor): String = message.scalaType.nameSymbol 10 | 11 | def fileDescriptorObjectName(file: FileDescriptor): String = 12 | file.fileDescriptorObject.name 13 | } 14 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/extra_protobuf_generator/ProtobufAdapter_2_11.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.extra_protobuf_generator 2 | 3 | import com.google.protobuf.Descriptors.{Descriptor, FileDescriptor} 4 | import scalapb.compiler.DescriptorImplicits 5 | 6 | class ProtobufAdapter(implicits: DescriptorImplicits) { 7 | import implicits._ 8 | 9 | def nameSymbol(message: Descriptor): String = message.nameSymbol 10 | 11 | def fileDescriptorObjectName(file: FileDescriptor): String = 12 | file.fileDescriptorObjectName 13 | } 14 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/fetch_sources/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "fetch_sources", 5 | testonly = True, 6 | srcs = ["FetchSources.scala"], 7 | deps = ["@com_google_guava_guava_21_0//jar"], 8 | ) 9 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/fetch_sources/FetchSources.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.src.main.scala.scalarules.test.fetch_sources 2 | 3 | /* This file's only purpose is to materialize the dependency in guava and be built! */ 4 | class FetchSources { 5 | println(classOf[com.google.common.cache.Cache[_, _]]) 6 | } 7 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/ijar/A.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.ijar 2 | 3 | object A { 4 | def foo = { 5 | B.foo 6 | C.foo 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/ijar/B.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.ijar 2 | 3 | object B { 4 | def foo = { 5 | println("orig") 6 | } 7 | 8 | def bar = { 9 | println("orig_sibling") 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/ijar/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | scala_library( 6 | name = "user", 7 | srcs = [ 8 | "A.scala", 9 | ], 10 | deps = ["dependency"], 11 | ) 12 | 13 | scala_library( 14 | name = "dependency", 15 | srcs = [ 16 | "B.scala", 17 | "C.java", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/ijar/C.java: -------------------------------------------------------------------------------- 1 | package scalarules.test.ijar; 2 | 3 | class C { 4 | public static void foo() { 5 | System.out.println("orig"); 6 | } 7 | 8 | public C() { 9 | B$.MODULE$.bar(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/io_utils/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_test") 2 | 3 | scala_test( 4 | name = "directory_utils", 5 | srcs = [ 6 | "DeleteDirectoryTest.scala", 7 | ], 8 | deps = [ 9 | "//src/java/io/bazel/rulesscala/io_utils", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/HelloWorldJunitTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit 2 | 3 | import org.junit.Test 4 | 5 | class HelloWorldJunitTest { 6 | 7 | @Test 8 | def helloWorld: Unit = { 9 | println("hello world") 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/JunitAbstractClassAndInterface.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit 2 | 3 | import org.junit.Test 4 | 5 | abstract class SomeAbstractTest { 6 | @Test 7 | def abstractTest: Unit = 8 | println("abstract") 9 | } 10 | 11 | trait SomeTraitTest { 12 | @Test 13 | def traitTest: Unit = 14 | println("trait") 15 | } 16 | 17 | class SingleTestSoTargetWillNotFailDueToNoTestsTest { 18 | @Test 19 | def someTest: Unit = 20 | println("passing") 21 | } 22 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/JunitCustomRunnerTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit 2 | 3 | import org.junit.Test 4 | import org.junit.runner.RunWith 5 | 6 | @RunWith(classOf[JunitCustomRunner]) 7 | class JunitCustomRunnerTest { 8 | @Test 9 | def myTest() = { 10 | assert(JunitCustomRunner.message == JunitCustomRunner.EXPECTED_MESSAGE, 11 | "JunitCustomRunner did not run, check the wiring in JUnitFilteringRunnerBuilder") 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/JunitIncludesRunWith.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit 2 | 3 | import org.junit.Test 4 | import org.junit.runner.RunWith 5 | import org.junit.runners.Suite 6 | import org.junit.runners.Suite.SuiteClasses 7 | 8 | @RunWith(classOf[Suite]) 9 | @SuiteClasses(Array(classOf[DeclaredInRunWith])) 10 | class RunWithSupportedTest 11 | 12 | class DeclaredInRunWith { 13 | @Test 14 | def runWith: Unit = 15 | println("Test Method From RunWith") 16 | } 17 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/JunitIncludesTestHierarchies.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit 2 | 3 | import org.junit.Test 4 | 5 | abstract class ContractTest { 6 | @Test 7 | def abstractTest: Unit = 8 | println("Test Method From Parent") 9 | } 10 | class ConcreteImplementationTest extends ContractTest 11 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/JunitInnerClass.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit 2 | 3 | import org.junit.Test 4 | 5 | class TestClass { 6 | @Test 7 | def someTest: Unit = 8 | println("passing") 9 | 10 | class SomeHelper 11 | } 12 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/JunitJavaTest.java: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit; 2 | 3 | import org.junit.Test; 4 | 5 | public class JunitJavaTest { 6 | @Test 7 | public void someTest() {} 8 | } 9 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/JunitMultiplePrefixes.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit 2 | 3 | import org.junit.Test 4 | import org.junit.Assert._ 5 | 6 | class TestJunitCustomPrefix { 7 | 8 | @Test 9 | def someTest: Unit = { 10 | assertEquals(1, 1) 11 | } 12 | 13 | } 14 | class OtherCustomPrefixJunit { 15 | 16 | @Test 17 | def someTest: Unit = { 18 | assertEquals(1, 1) 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/JunitMultipleSuffixes.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit 2 | 3 | import org.junit.Test 4 | import org.junit.Assert._ 5 | 6 | class JunitSuffixE2E { 7 | 8 | @Test 9 | def someTest: Unit = { 10 | assertEquals(1, 1) 11 | } 12 | 13 | } 14 | class JunitSuffixIT { 15 | 16 | @Test 17 | def someTest: Unit = { 18 | assertEquals(1, 1) 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/JunitNoTestEnvironmentTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit 2 | 3 | import org.junit.Assert.fail 4 | import org.junit.Test 5 | 6 | class JunitNoTestEnvironmentTest { 7 | 8 | @Test 9 | def testUnsetEnvVarIsNull: Unit = { 10 | System.getenv("my_unset_env_var") match { 11 | case null => () 12 | case x => fail(s"Unexpectedly obtained my_unset_env_var=$x") 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/JunitNoTests.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit 2 | 3 | import org.junit.Test 4 | 5 | class SomeHelpreForTest 6 | 7 | class SingleTestSoTargetWillNotFailDueToNoTestsTest { 8 | @Test 9 | def someTest: Unit = 10 | println("passing") 11 | } 12 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/JunitSetTestEnvironmentTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit 2 | 3 | import org.junit.Assert 4 | import org.junit.Assert.fail 5 | import org.junit.Test 6 | 7 | class JunitSetTestEnvironmentTest { 8 | 9 | @Test 10 | def testSetEnvVarEqualsValue: Unit = { 11 | System.getenv("my_unset_env_var") match { 12 | case null => () 13 | case x => fail(s"Unexpectedly obtained my_unset_env_var=$x") 14 | } 15 | Assert.assertEquals(System.getenv("my_env_var"), "my_value") 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/scala.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit 2 | 3 | import org.junit.Test 4 | //Used to verify a folder doesn't match in test discovery. 5 | //See JunitMatchesOnlyFilesEvenIfFolderMatchesPattern target 6 | class scala { 7 | 8 | @Test 9 | def atLeastOneTestIsNeeded: Unit = { 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/separate_target/FailingTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit.separate_target 2 | 3 | import org.junit.Test 4 | 5 | class FailingTest { 6 | 7 | @Test 8 | def someFailingTest(): Unit = { 9 | throw new RuntimeException("boom! should not run") 10 | } 11 | 12 | } 13 | 14 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/separate_target/JunitJavaSeparateTargetTest.java: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit.separate_target; 2 | 3 | import org.junit.Test; 4 | 5 | public class JunitJavaSeparateTargetTest { 6 | 7 | @Test 8 | public void someTest() {} 9 | } 10 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/separate_target/JunitSeparateTargetTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit.separate_target 2 | 3 | import org.junit.Test 4 | 5 | class JunitSeparateTargetTest { 6 | 7 | @Test 8 | def someTest(): Unit = { 9 | } 10 | 11 | } 12 | 13 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/separate_target/SomeScalaClass.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit.separate_target 2 | 3 | class SomeScalaClass { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/support/JUnitCompileTimeDep.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit.support 2 | object JUnitCompileTimeDep { 3 | val hello = "hello" 4 | } 5 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/support/JUnitRuntimeDep.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit.support 2 | class JUnitRuntimeDep 3 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/junit/test_discovery/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_specs2_junit_test") 2 | 3 | scala_specs2_junit_test( 4 | name = "ArchiveEntriesTest", 5 | srcs = ["ArchiveEntriesTest.scala"], 6 | suffixes = ["Test"], 7 | deps = [ 8 | "//src/java/io/bazel/rulesscala/test_discovery", 9 | ], 10 | ) 11 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/large_classpath/ObjectWithLargeClasspath.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.large_classpath 2 | 3 | object ObjectWithLargeClasspath extends App { 4 | println("running") 5 | } 6 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/large_classpath/helper.bzl: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | def create_dependencies(amount, length): 4 | for i in range(amount): 5 | scala_library(name = "dependency_" * length + str(i)) 6 | 7 | def get_dependency_labels(amount, length): 8 | return [":" + "dependency_" * length + str(i) for i in range(amount)] 9 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/location_expansion/LocationExpansionTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.location_expansion 2 | 3 | import org.specs2.mutable.SpecWithJUnit 4 | class LocationExpansionTest extends SpecWithJUnit { 5 | 6 | "tests" >> { 7 | "support location expansion" >> { 8 | sys.props.get("location.expanded") must beSome(contain("worker")) 9 | 10 | } 11 | } 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/mix_java_scala/Bar.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | class Foo 3 | class Bar extends Baz 4 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/mix_java_scala/Baz.java: -------------------------------------------------------------------------------- 1 | package scalarules.test; 2 | 3 | public class Baz extends Foo {} 4 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/mix_java_scala/Baz.srcjar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/test/src/main/scala/scalarules/test/mix_java_scala/Baz.srcjar -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/mix_java_scala/FooBar.java: -------------------------------------------------------------------------------- 1 | package scalarules.test; 2 | 3 | public class FooBar extends Foo {} 4 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/neverlink/A.scala: -------------------------------------------------------------------------------- 1 | package neverlink 2 | 3 | class A -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/neverlink/B.scala: -------------------------------------------------------------------------------- 1 | package neverlink 2 | 3 | class B -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/neverlink/NeverlinkTest.scala: -------------------------------------------------------------------------------- 1 | package neverlink 2 | 3 | import org.scalatest.flatspec._ 4 | 5 | class NeverlinkTest extends AnyFlatSpec { 6 | "neverlink=False" should "include jar into classpath" in { 7 | getClass.getClassLoader.loadClass("neverlink.A") 8 | } 9 | 10 | "neverlink=True" should "exclude jar from classpath" in { 11 | assertThrows[ClassNotFoundException] { 12 | getClass.getClassLoader.loadClass("neverlink.B") 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/only_java/Alpha.java: -------------------------------------------------------------------------------- 1 | package scalarules.test; 2 | 3 | public class Alpha { 4 | public static void main(String[] args) { 5 | return; // we just want this to be compiled and run 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/resources/ScalaLibOnlyResourcesTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.resources 2 | 3 | import org.specs2.mutable.SpecWithJUnit 4 | 5 | class ScalaLibOnlyResourcesTest extends SpecWithJUnit { 6 | 7 | "Scala library with no srcs and only resources" >> { 8 | "allow to load resources" >> { 9 | get("/resource.txt") must beEqualTo("I am a text resource!") 10 | } 11 | } 12 | 13 | private def get(s: String): String = 14 | scala.io.Source.fromInputStream(getClass.getResourceAsStream(s)).mkString 15 | 16 | } 17 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/resources/resource.txt: -------------------------------------------------------------------------------- 1 | I am a text resource! -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/resources/strip/ResourceStripPrefixTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.resources.strip 2 | 3 | import org.specs2.mutable.SpecificationWithJUnit 4 | 5 | class ResourceStripPrefixTest extends SpecificationWithJUnit { 6 | 7 | "resource_strip_prefix" >> { 8 | "strip the prefix on nosrc jar" in { 9 | val resource = getClass.getResourceAsStream("/nosrc_jar_resource.txt") 10 | resource must not beNull 11 | } 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/resources/strip/nosrc_jar_resource.txt: -------------------------------------------------------------------------------- 1 | I am a text resource! -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/resources/subdir/resource.txt: -------------------------------------------------------------------------------- 1 | I am a text resource in a subdir! -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/scala_import/ReferCatsImplicits.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.scala_import 2 | 3 | import cats.implicits._ 4 | 5 | object TestObj {} 6 | 7 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/scala_import/ScalaImportExposesFileJarsTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.scala_import 2 | 3 | import scalarules.test.scala_import.generic.Generic 4 | 5 | import org.specs2.mutable.SpecificationWithJUnit 6 | 7 | class ScalaImportExposesJarsTest extends SpecificationWithJUnit { 8 | 9 | "scala_import" >> { 10 | "enable importing jars from files" in { 11 | assert(Generic.foo == "bar") 12 | success 13 | } 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/scala_import/ScalaImportExposesJarsTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.scala_import 2 | 3 | import com.google.common.cache.Cache 4 | import org.apache.commons.lang3.ArrayUtils 5 | import org.specs2.mutable.SpecWithJUnit 6 | 7 | class ScalaImportExposesJarsTest extends SpecWithJUnit { 8 | "scala_import" >> { 9 | "enable using the jars it exposes" in { 10 | println(classOf[Cache[String, String]]) 11 | println(classOf[ArrayUtils]) 12 | success 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/scala_import/ScalaImportPropagatesRuntimeDepsTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.scala_import 2 | 3 | import org.specs2.mutable.SpecificationWithJUnit 4 | 5 | class ScalaImportPropagatesRuntimeDepsTest extends SpecificationWithJUnit { 6 | 7 | "scala_import" >> { 8 | "propagate runtime deps" in { 9 | println(Class.forName("com.google.common.cache.Cache")) 10 | println(Class.forName("org.apache.commons.lang3.ArrayUtils")) 11 | println(Class.forName("cats.Applicative")) 12 | success 13 | } 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/scala_import/generic/Generic.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.scala_import.generic 2 | 3 | object Generic { 4 | val foo = "bar" 5 | } 6 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/scala_import/nl/ScalaImportNeverLink.java: -------------------------------------------------------------------------------- 1 | package scalarules.test.scala_import.nl; 2 | 3 | public class ScalaImportNeverLink {} 4 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/sources_jars_in_deps/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "source_jar_not_oncp", 5 | testonly = True, 6 | srcs = ["ReferCatsImplicits.scala"], 7 | deps = [ 8 | "@org_typelevel__cats_core//jar", 9 | ], 10 | ) 11 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/sources_jars_in_deps/ReferCatsImplicits.scala: -------------------------------------------------------------------------------- 1 | package scala_rules.bazel 2 | import cats.implicits._ 3 | 4 | 5 | object TestObj {} 6 | 7 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/srcjars/SourceJar1.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.srcjars 2 | 3 | object SourceJar1 { 4 | def msg = "I want to go back to the island" 5 | } 6 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/srcjars/SourceJar1.srcjar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/test/src/main/scala/scalarules/test/srcjars/SourceJar1.srcjar -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/srcjars/SourceJar2.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.srcjars 2 | 3 | object SourceJar2 { 4 | def msg = SourceJar1.msg 5 | } 6 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/srcjars/SourceJar2.srcjar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/test/src/main/scala/scalarules/test/srcjars/SourceJar2.srcjar -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/srcjars_with_java/JavaDependent.scala: -------------------------------------------------------------------------------- 1 | package fish 2 | 3 | object JavaDependent { 4 | val poem = JavaSource.line + "\nred fish, blue fish\nblack fish, blue fish\nold fish, new fish" 5 | } -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/srcjars_with_java/JavaSource.java: -------------------------------------------------------------------------------- 1 | package fish; 2 | 3 | public class JavaSource { 4 | // We do not make this final - a bug in dependency analyzer in 2.11 5 | // and below means that dependencies on static final variables are not 6 | // detected 7 | public static String line = "one fish, two fish"; 8 | } 9 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/srcjars_with_java/JavaSourceJar.srcjar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/test/src/main/scala/scalarules/test/srcjars_with_java/JavaSourceJar.srcjar -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/srcjars_with_java/MixedLanguageDependent.scala: -------------------------------------------------------------------------------- 1 | package fish 2 | 3 | object MixedLanguageDependent { 4 | final val poem = List(JavaSource.line, ScalaSource.line).mkString("\n") 5 | } -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/srcjars_with_java/MixedLanguageSourceJar.srcjar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/test/src/main/scala/scalarules/test/srcjars_with_java/MixedLanguageSourceJar.srcjar -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/srcjars_with_java/ScalaSource.scala: -------------------------------------------------------------------------------- 1 | package fish 2 | 3 | object ScalaSource { 4 | final val line = "red fish, blue fish"; 5 | } -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/stamping/ClassFromLibrary.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.stamping 2 | 3 | class ClassFromLibrary 4 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/stamping/ClassFromMacroLibrary.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.stamping 2 | 3 | import scala.language.experimental.macros 4 | import scala.reflect.macros.blackbox 5 | 6 | object ClassFromMacroLibrary { 7 | def hello(): Unit = macro helloMacro 8 | 9 | def helloMacro(c: blackbox.Context)(): c.Expr[Unit] = { 10 | import c.universe._ 11 | reify { println("Hello World!") } 12 | } 13 | } -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/strict_deps/no_recompilation/A.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.strict_deps.no_recompilation; 2 | 3 | object A { 4 | def foo = { 5 | B.foo 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/strict_deps/no_recompilation/B.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.strict_deps.no_recompilation; 2 | 3 | object B { 4 | def foo = { 5 | C.foo 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/strict_deps/no_recompilation/C.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.strict_deps.no_recompilation; 2 | 3 | object C { 4 | def foo = { 5 | println("orig") 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/BareThrifts.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.twitter_scrooge 2 | 3 | import com.foo.bar.baz.Foo 4 | import com.foo.bar.baz.Bar 5 | import com.foo.bar.baz.Baz 6 | 7 | object BareThrifts { 8 | val classes = Seq(classOf[Foo], classOf[Bar], classOf[Baz]) 9 | 10 | def main(args: Array[String]) { 11 | print(s"classes ${classes.mkString(",")}") 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/JustScrooge1.java: -------------------------------------------------------------------------------- 1 | package scalarules.test.twitter_scrooge; 2 | 3 | 4 | public class JustScrooge1 { 5 | public static void main(String[] args) {} 6 | } 7 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/JustScrooge2a.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.twitter_scrooge 2 | 3 | import scalarules.test.twitter_scrooge.thrift.thrift2.Struct2A 4 | import scalarules.test.twitter_scrooge.thrift.thrift2.thrift3.Struct3 5 | 6 | object JustScrooge2a { 7 | val classes = Seq(classOf[Struct2A], classOf[Struct3]) 8 | } 9 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/JustScrooge2b.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.twitter_scrooge 2 | 3 | import scalarules.test.twitter_scrooge.thrift.thrift2.Struct2B 4 | import scalarules.test.twitter_scrooge.thrift.thrift2.thrift3.Struct3 5 | 6 | object JustScrooge2b { 7 | val classes = Seq(classOf[Struct2B], classOf[Struct3]) 8 | 9 | def main(args: Array[String]) { 10 | classes foreach println 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/JustScrooge3.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.twitter_scrooge 2 | 3 | import scalarules.test.twitter_scrooge.thrift.thrift2.thrift3.Struct3 4 | 5 | object JustScrooge3 { 6 | val classes = Seq(classOf[Struct3]) 7 | } 8 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/Scrooge2.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.twitter_scrooge 2 | 3 | import scalarules.test.twitter_scrooge.thrift.thrift2.{Struct2A, Struct2B} 4 | import scalarules.test.twitter_scrooge.thrift.thrift2.thrift3.Struct3 5 | 6 | object Scrooge2 { 7 | val classes = Seq(classOf[Struct2A], classOf[Struct2B], classOf[Struct3]) 8 | } 9 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/Twodeep.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.twitter_scrooge 2 | 3 | import scalarules.test.twitter_scrooge.thrift.thrift2.thrift3.Struct3 4 | 5 | object Twodeep { 6 | val classes = 7 | Seq( 8 | classOf[Struct3], 9 | JustScrooge3.getClass 10 | ) 11 | 12 | def main(args: Array[String]) { 13 | classes foreach println 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/prefix_test/a/b/c/d/A.thrift: -------------------------------------------------------------------------------- 1 | namespace java scalarules.test.twitter_scrooge.prefix_test.a.b.c.d 2 | 3 | struct StructA { 4 | 1: string field 5 | } 6 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/prefix_test/a/b/c/d/BUILD: -------------------------------------------------------------------------------- 1 | load("//thrift:thrift.bzl", "thrift_library") 2 | load("//twitter_scrooge:twitter_scrooge.bzl", "scrooge_scala_library") 3 | 4 | thrift_library( 5 | name = "a_thrift", 6 | srcs = ["A.thrift"], 7 | absolute_prefix = "prefix_test/a", 8 | visibility = ["//visibility:public"], 9 | ) 10 | 11 | scrooge_scala_library( 12 | name = "d", 13 | visibility = ["//visibility:public"], 14 | deps = [ 15 | ":a_thrift", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/prefix_test/e/f/b/c/d/B.thrift: -------------------------------------------------------------------------------- 1 | namespace java scalarules.test.twitter_scrooge.prefix_test.a.b.c.d 2 | 3 | include "b/c/d/A.thrift" 4 | 5 | struct StructB { 6 | 1: A.StructA field 7 | } 8 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/thrift/ThriftMany1.thrift: -------------------------------------------------------------------------------- 1 | struct Many1 { 2 | 1: i32 one 3 | } 4 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/thrift/ThriftMany2.thrift: -------------------------------------------------------------------------------- 1 | struct Many2 { 2 | 1: i16 two 3 | } 4 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/BareJar.thrift: -------------------------------------------------------------------------------- 1 | namespace java com.foo.bar.baz 2 | 3 | include "Foo.thrift" 4 | include "Bar.thrift" 5 | include "Baz.thrift" 6 | 7 | struct BareJar { 8 | 1: Foo foo 9 | 2: Bar bar 10 | 3: Baz baz 11 | } 12 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_1/BUILD: -------------------------------------------------------------------------------- 1 | load("//thrift:thrift.bzl", "thrift_library") 2 | 3 | thrift_library( 4 | name = "bar", 5 | srcs = ["//test/src/main/resources/scalarules/test:Bar.thrift"], 6 | ) 7 | 8 | thrift_library( 9 | name = "bare_jar_1", 10 | external_jars = [ 11 | ":libbar.jar", 12 | ], 13 | visibility = ["//visibility:public"], 14 | ) 15 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_2/BUILD: -------------------------------------------------------------------------------- 1 | load("//thrift:thrift.bzl", "thrift_library") 2 | 3 | thrift_library( 4 | name = "baz", 5 | srcs = ["//test/src/main/resources/scalarules/test:Baz.thrift"], 6 | ) 7 | 8 | thrift_library( 9 | name = "bare_jar_2", 10 | external_jars = [ 11 | ":libbaz.jar", 12 | ], 13 | visibility = ["//visibility:public"], 14 | ) 15 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/Thrift2_A.thrift: -------------------------------------------------------------------------------- 1 | namespace java scalarules.test.twitter_scrooge.thrift.thrift2 2 | 3 | include "thrift3/Thrift3.thrift" 4 | 5 | struct Struct2A { 6 | 1: Thrift3.Struct3 msg 7 | } -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/Thrift2_B.thrift: -------------------------------------------------------------------------------- 1 | namespace java scalarules.test.twitter_scrooge.thrift.thrift2 2 | 3 | // TODO We should be able to do a full import based on the full package 4 | // which will make refactoring targets much less fragile 5 | include "thrift3/Thrift3.thrift" 6 | 7 | struct Struct2B { 8 | 1: Thrift3.Struct3 msg 9 | } -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/thrift3/Thrift3.thrift: -------------------------------------------------------------------------------- 1 | namespace java scalarules.test.twitter_scrooge.thrift.thrift2.thrift3 2 | 3 | struct Struct3 { 4 | 1: string msg 5 | } 6 | 7 | struct Struct3Extra { 8 | 1: string msg 9 | } -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/thrift4/Thrift4.thrift: -------------------------------------------------------------------------------- 1 | namespace java scalarules.test.twitter_scrooge.thrift.thrift2.thrift3 2 | 3 | include "../Thrift2_A.thrift" 4 | 5 | struct Struct4 { 6 | 1: Thrift2_A.Struct2A nested 7 | } 8 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/thrift4/Thrift4a.thrift: -------------------------------------------------------------------------------- 1 | include "./Thrift4.thrift" 2 | 3 | struct Struct4a { 4 | 1: Thrift4.Struct4 nest; 5 | } 6 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift_with_compiler_args/BUILD: -------------------------------------------------------------------------------- 1 | load("//thrift:thrift.bzl", "thrift_library") 2 | 3 | thrift_library( 4 | name = "thrift5", 5 | srcs = ["Thrift5.thrift"], 6 | compiler_args = [ 7 | "--namespace-map", 8 | "scalarules.test.twitter_scrooge.thrift.thrift_with_compiler_args.thrift5=scalarules.test.twitter_scrooge.thrift.thrift_with_compiler_args.thrift999", 9 | ], 10 | visibility = ["//visibility:public"], 11 | ) 12 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift_with_compiler_args/Thrift5.thrift: -------------------------------------------------------------------------------- 1 | namespace java scalarules.test.twitter_scrooge.thrift.thrift_with_compiler_args.thrift5 2 | 3 | struct Struct5 { 4 | 1: string msg 5 | } 6 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/utf8/JavaClassWithUtf8.java: -------------------------------------------------------------------------------- 1 | package scalarules.test.utf8; 2 | 3 | class JavaClassWithUtf8 { 4 | public static final String UTF_8_STR = "‡"; 5 | } 6 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/utf8/ScalaClassWithUtf8.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.utf8 2 | 3 | class ScalaClassWithUtf8 { 4 | val Utf8String: String = "‡" 5 | } 6 | -------------------------------------------------------------------------------- /test/test_binary.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "Executing: " $@ 4 | $@ 5 | -------------------------------------------------------------------------------- /test/test_binary_run_with_large_classpath.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "Executing: " $@ 4 | #limiting the classpath to simulate a large classpath which is over the OS limit 5 | export CLASSPATH_LIMIT=10 6 | $@ 7 | -------------------------------------------------------------------------------- /test/test_scala_library_outputs_mixed_java_scala_jars.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echoerr() { 4 | echo "$@" 1>&2; 5 | } 6 | 7 | assert() { 8 | $@ || (echo "FAILED: $@"; exit 1) 9 | } 10 | 11 | contains() { 12 | grep $@ 13 | } 14 | 15 | set -e 16 | 17 | assert contains "test/${2}.jar" $1 18 | assert contains "test/${2}_java.jar" $1 19 | -------------------------------------------------------------------------------- /test/unstable/BUILD: -------------------------------------------------------------------------------- 1 | load( 2 | "//scala/unstable:defs.bzl", 3 | "scala_binary", 4 | "scala_library", 5 | "scala_test", 6 | ) 7 | 8 | scala_binary( 9 | name = "binary", 10 | srcs = ["binary.scala"], 11 | main_class = "test.v2.Binary", 12 | deps = [":library"], 13 | ) 14 | 15 | scala_library( 16 | name = "library", 17 | srcs = ["library.scala"], 18 | deps = [], 19 | ) 20 | 21 | scala_test( 22 | name = "test", 23 | srcs = ["test.scala"], 24 | deps = [ 25 | ":library", 26 | ], 27 | ) 28 | -------------------------------------------------------------------------------- /test/unstable/binary.scala: -------------------------------------------------------------------------------- 1 | package test.v2 2 | 3 | object Binary { 4 | def main(args: Array[String]): Unit = { 5 | println(s"${Library.method1} ${Library.method2}") 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/unstable/library.scala: -------------------------------------------------------------------------------- 1 | package test.v2 2 | 3 | object Library { 4 | def method1(): String = "hello" 5 | def method2(): String = "world" 6 | } 7 | -------------------------------------------------------------------------------- /test/unstable/test.scala: -------------------------------------------------------------------------------- 1 | package test.v2 2 | 3 | import org.scalatest.funsuite._ 4 | 5 | class Test extends AnyFunSuite { 6 | test("method1") { 7 | assert(Library.method1 == "hello") 8 | } 9 | 10 | test("method2") { 11 | assert(Library.method2 == "world") 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test_all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 6 | "${dir}"/test_lint.sh 7 | "${dir}"/test_rules_scala.sh 8 | "${dir}"/test_version.sh 9 | "${dir}"/test_dependency_versions.sh 10 | "${dir}"/test_cross_build.sh 11 | "${dir}"/test_reproducibility.sh 12 | #"${dir}"/test_intellij_aspect.sh 13 | "${dir}"/test_examples.sh 14 | "${dir}"/test_coverage.sh 15 | "${dir}"/test_thirdparty_version.sh 16 | "${dir}"/dt_patches/dt_patch_test.sh 17 | -------------------------------------------------------------------------------- /test_cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Cleans the output base and shuts down the Bazel servers of nested repos. 4 | # 5 | # There shouldn't be a need to run this regularly. However, if disk space gets 6 | # tight, this will clean all nested repos. 7 | 8 | dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 9 | 10 | while IFS= read -r repo; do 11 | repo="${repo%/MODULE.bazel}" 12 | echo "cleaning: $repo" 13 | 14 | cd "$repo" 15 | bazel clean --expunge_async 2>/dev/null 16 | cd "$dir" 17 | done < <(git ls-files '*/*MODULE.bazel') 18 | -------------------------------------------------------------------------------- /test_coverage.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | if ! bazel_loc="$(type -p 'bazel')" || [[ -z "$bazel_loc" ]]; then 6 | export PATH="$(cd "$(dirname "$0")"; pwd)"/tools:$PATH 7 | echo 'Using ./tools/bazel directly for bazel calls' 8 | fi 9 | 10 | test_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/test/shell 11 | 12 | . "${test_dir}"/test_coverage_specs2_with_junit.sh 13 | . "${test_dir}"/test_coverage_scalatest.sh 14 | . "${test_dir}"/test_coverage_equals_in_target.sh 15 | . "${test_dir}"/test_coverage_scalatest_resources.sh 16 | -------------------------------------------------------------------------------- /test_cross_build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | test_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/test/shell 6 | 7 | . "${test_dir}"/test_cross_build.sh 8 | -------------------------------------------------------------------------------- /test_cross_build/.bazelrc: -------------------------------------------------------------------------------- 1 | # Remove after moving to Bazel 7. 2 | import ../.bazelrc 3 | -------------------------------------------------------------------------------- /test_cross_build/.bazelversion: -------------------------------------------------------------------------------- 1 | 7.6.1 2 | -------------------------------------------------------------------------------- /test_cross_build/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/test_cross_build/BUILD -------------------------------------------------------------------------------- /test_cross_build/protobuf.patch: -------------------------------------------------------------------------------- 1 | ../protoc/0001-protobuf-19679-rm-protoc-dep.patch -------------------------------------------------------------------------------- /test_cross_build/scalafmt/.scalafmt2.conf: -------------------------------------------------------------------------------- 1 | version = "3.9.6" 2 | runner.dialect = scala213 3 | maxColumn = 40 4 | lineEndings = preserve 5 | -------------------------------------------------------------------------------- /test_cross_build/scalafmt/.scalafmt3.conf: -------------------------------------------------------------------------------- 1 | version = "3.9.6" 2 | runner.dialect = scala3 3 | maxColumn = 40 4 | lineEndings = preserve 5 | -------------------------------------------------------------------------------- /test_cross_build/scalafmt/formatted/formatted-binary2.scala: -------------------------------------------------------------------------------- 1 | object UnformattedBinary { 2 | val info = 3 | " unformatted file " 4 | 5 | def main( 6 | args: Array[String] 7 | ): Unit = { 8 | println(info) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test_cross_build/scalafmt/formatted/formatted-binary3.scala: -------------------------------------------------------------------------------- 1 | @main def UnformattedBinary(): Unit = 2 | val message = 3 | " unformatted binary " 4 | 5 | println(message) 6 | -------------------------------------------------------------------------------- /test_cross_build/scalafmt/formatted/formatted-library2.scala: -------------------------------------------------------------------------------- 1 | object Unformatted { 2 | val info = 3 | " unformatted file " 4 | } 5 | -------------------------------------------------------------------------------- /test_cross_build/scalafmt/formatted/formatted-library3.scala: -------------------------------------------------------------------------------- 1 | object Unformatted: 2 | val info = 3 | " unformatted file " 4 | -------------------------------------------------------------------------------- /test_cross_build/scalafmt/formatted/formatted-test2.scala: -------------------------------------------------------------------------------- 1 | import org.scalatest.flatspec._ 2 | 3 | class Test extends AnyFlatSpec { 4 | 5 | "Test" should "be formatted" in { 6 | assert(true) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test_cross_build/scalafmt/formatted/formatted-test3.scala: -------------------------------------------------------------------------------- 1 | import org.scalatest.flatspec._ 2 | 3 | class Test extends AnyFlatSpec: 4 | 5 | "Test" should "be formatted" in { 6 | assert(true) 7 | } 8 | -------------------------------------------------------------------------------- /test_cross_build/scalafmt/scalafmt_rules.bzl: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_scala//scala:advanced_usage/scala.bzl", 3 | "make_scala_binary", 4 | "make_scala_library", 5 | "make_scala_test", 6 | ) 7 | load( 8 | "@rules_scala//scala/scalafmt:phase_scalafmt_ext.bzl", 9 | "ext_scalafmt", 10 | ) 11 | 12 | scalafmt_scala_binary = make_scala_binary(ext_scalafmt) 13 | 14 | scalafmt_scala_library = make_scala_library(ext_scalafmt) 15 | 16 | scalafmt_scala_test = make_scala_test(ext_scalafmt) 17 | -------------------------------------------------------------------------------- /test_cross_build/scalafmt/unformatted/unformatted-binary2.scala: -------------------------------------------------------------------------------- 1 | 2 | object UnformattedBinary { 3 | val info = " unformatted file " 4 | 5 | def main(args: Array[String]): Unit = 6 | { 7 | println(info) 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test_cross_build/scalafmt/unformatted/unformatted-binary3.scala: -------------------------------------------------------------------------------- 1 | @main def UnformattedBinary(): Unit = 2 | val message = " unformatted binary " 3 | 4 | println(message) 5 | -------------------------------------------------------------------------------- /test_cross_build/scalafmt/unformatted/unformatted-library2.scala: -------------------------------------------------------------------------------- 1 | object Unformatted { 2 | val info = " unformatted file " 3 | } 4 | -------------------------------------------------------------------------------- /test_cross_build/scalafmt/unformatted/unformatted-library3.scala: -------------------------------------------------------------------------------- 1 | object Unformatted: 2 | val info = " unformatted file " 3 | -------------------------------------------------------------------------------- /test_cross_build/scalafmt/unformatted/unformatted-test2.scala: -------------------------------------------------------------------------------- 1 | import org.scalatest.flatspec._ 2 | 3 | class Test extends AnyFlatSpec 4 | { 5 | 6 | "Test" should "be formatted" in { 7 | assert(true) 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test_cross_build/scalafmt/unformatted/unformatted-test3.scala: -------------------------------------------------------------------------------- 1 | import org.scalatest.flatspec._ 2 | 3 | class Test extends 4 | AnyFlatSpec: 5 | 6 | "Test" should "be formatted" in { 7 | assert(true) 8 | } 9 | -------------------------------------------------------------------------------- /test_cross_build/version_specific/before_3_2.scala: -------------------------------------------------------------------------------- 1 | class Example(using String)(i: Int) 2 | given String = "something" 3 | val instance = Example()(6) -------------------------------------------------------------------------------- /test_cross_build/version_specific/before_3_3.scala: -------------------------------------------------------------------------------- 1 | class Outer: 2 | type Inner 3 | 4 | inline def method(inline param: Outer): param.Inner = ??? -------------------------------------------------------------------------------- /test_cross_build/version_specific/since_3_1.scala: -------------------------------------------------------------------------------- 1 | type Choice[A] = A match { case Int => Long ; case Long => Int } -------------------------------------------------------------------------------- /test_cross_build/version_specific/since_3_2.scala: -------------------------------------------------------------------------------- 1 | class Example(using String)(i: Int) 2 | given String = "something" 3 | val instance = Example(6) -------------------------------------------------------------------------------- /test_cross_build/version_specific/since_3_3.scala: -------------------------------------------------------------------------------- 1 | import util.boundary, boundary.break -------------------------------------------------------------------------------- /test_examples.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | test_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/test/shell 6 | 7 | . "${test_dir}"/test_examples.sh -------------------------------------------------------------------------------- /test_expect_failure/compiler_dependency_tracker/A.scala: -------------------------------------------------------------------------------- 1 | class A 2 | -------------------------------------------------------------------------------- /test_expect_failure/compiler_dependency_tracker/B.scala: -------------------------------------------------------------------------------- 1 | class B extends D 2 | -------------------------------------------------------------------------------- /test_expect_failure/compiler_dependency_tracker/C.scala: -------------------------------------------------------------------------------- 1 | class C extends D { 2 | val e: E = ??? 3 | } -------------------------------------------------------------------------------- /test_expect_failure/compiler_dependency_tracker/D.scala: -------------------------------------------------------------------------------- 1 | class D extends E { 2 | } -------------------------------------------------------------------------------- /test_expect_failure/compiler_dependency_tracker/E.scala: -------------------------------------------------------------------------------- 1 | class E -------------------------------------------------------------------------------- /test_expect_failure/compiler_dependency_tracker/F.scala: -------------------------------------------------------------------------------- 1 | class F { 2 | 3 | -------------------------------------------------------------------------------- /test_expect_failure/compiler_dependency_tracker/sdeps/AnotherScalaDep.scala: -------------------------------------------------------------------------------- 1 | package sdeps 2 | 3 | class AnotherScalaDep 4 | -------------------------------------------------------------------------------- /test_expect_failure/compiler_dependency_tracker/sdeps/IgnoredScalaDep.scala: -------------------------------------------------------------------------------- 1 | package sdeps 2 | 3 | class IgnoredScalaDep -------------------------------------------------------------------------------- /test_expect_failure/compiler_dependency_tracker/sdeps/ScalaDep.scala: -------------------------------------------------------------------------------- 1 | package sdeps 2 | 3 | object ScalaDep { 4 | val foo = "bar" 5 | } 6 | -------------------------------------------------------------------------------- /test_expect_failure/compiler_dependency_tracker/sdeps/SomeJava.java: -------------------------------------------------------------------------------- 1 | package sdeps; 2 | 3 | public class SomeJava { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /test_expect_failure/compiler_dependency_tracker/sdeps/SomeScalaWithDeps.scala: -------------------------------------------------------------------------------- 1 | package sdeps 2 | 3 | class SomeScalaWithDeps { 4 | val bar = ScalaDep.foo 5 | } 6 | -------------------------------------------------------------------------------- /test_expect_failure/compilers_javac_opts/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "can_configure_jvm_flags_for_javac_via_javacopts", 5 | srcs = ["WillNotCompileSinceJavaToolchainAddsAnInvalidJvmFlag.java"], 6 | ) 7 | 8 | scala_library( 9 | name = "can_override_default_toolchain_flags_for_javac_via_javacopts", 10 | srcs = ["WillNotCompileSinceJavaToolchainAddsAnInvalidJvmFlag.java"], 11 | javacopts = ["-target InvalidTarget"], 12 | ) 13 | -------------------------------------------------------------------------------- /test_expect_failure/compilers_javac_opts/WillNotCompileSinceJavaToolchainAddsAnInvalidJvmFlag.java: -------------------------------------------------------------------------------- 1 | package test_expect_failure.compilers_javac_opts; 2 | 3 | public class WillNotCompileSinceJavaToolchainAddsAnInvalidJvmFlag {} 4 | -------------------------------------------------------------------------------- /test_expect_failure/compilers_jvm_flags/WillNotCompileJavaSinceXmxTooLow.java: -------------------------------------------------------------------------------- 1 | class WillNotCompileJavaSinceXmxTooLow {} 2 | -------------------------------------------------------------------------------- /test_expect_failure/compilers_jvm_flags/WillNotCompileScalaSinceXmxTooLow.scala: -------------------------------------------------------------------------------- 1 | class WillNotCompileScalaSinceXmxTooLow -------------------------------------------------------------------------------- /test_expect_failure/compilers_jvm_flags/args.txt: -------------------------------------------------------------------------------- 1 | -Xmx1M 2 | -------------------------------------------------------------------------------- /test_expect_failure/diagnostics_reporter/ErrorAndWarningFile.scala: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList 2 | 3 | object ErrorAndWarningFile { 4 | def main(args: Array[String]): Unit = { 5 | printn("this is not a print") 6 | } 7 | } -------------------------------------------------------------------------------- /test_expect_failure/diagnostics_reporter/ErrorFile.scala: -------------------------------------------------------------------------------- 1 | object ErrorFile { 2 | val value = "someVal" 3 | 4 | def main(args: Array[String]): Unit = { 5 | println(value 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test_expect_failure/diagnostics_reporter/InfoFile.scala: -------------------------------------------------------------------------------- 1 | object InfoFile { 2 | def main(args: Array[String]): Unit = { 3 | println("this is not a print") 4 | } 5 | } -------------------------------------------------------------------------------- /test_expect_failure/diagnostics_reporter/TwoErrorsFile.scala: -------------------------------------------------------------------------------- 1 | object SimpleFile { 2 | val value = "someVal" 3 | 4 | def main(args: Array[String]): Unit = { 5 | printn(value) 6 | prinf(value) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test_expect_failure/diagnostics_reporter/WarningFile.scala: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList 2 | 3 | object WarningFile { 4 | def main(args: Array[String]): Unit = { 5 | println("this is a print") 6 | } 7 | } -------------------------------------------------------------------------------- /test_expect_failure/disappearing_class/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "uses_class", 5 | srcs = ["UsesClass.scala"], 6 | deps = [":class_provider"], 7 | ) 8 | 9 | scala_library( 10 | name = "class_provider", 11 | srcs = ["ClassProvider.scala"], 12 | ) 13 | -------------------------------------------------------------------------------- /test_expect_failure/disappearing_class/ClassProvider.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | object ClassProvider { 4 | def dissappearingClassMethod: String = "testContents" 5 | } 6 | 7 | 8 | object BackgroundNoise{} 9 | -------------------------------------------------------------------------------- /test_expect_failure/disappearing_class/UsesClass.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | object UsesClass { 4 | val x = ClassProvider.dissappearingClassMethod 5 | } 6 | -------------------------------------------------------------------------------- /test_expect_failure/java_in_src_jar_when_disabled/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "java_source_jar", 5 | # JavaSourceJar.srcjar was constructed with 6 | # `jar -cfM JavaSourceJar.srcjar JavaSource.java` 7 | srcs = ["JavaSourceJar.srcjar"], 8 | expect_java_output = False, 9 | ) 10 | -------------------------------------------------------------------------------- /test_expect_failure/java_in_src_jar_when_disabled/JavaSourceJar.srcjar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/test_expect_failure/java_in_src_jar_when_disabled/JavaSourceJar.srcjar -------------------------------------------------------------------------------- /test_expect_failure/jmh/BUILD: -------------------------------------------------------------------------------- 1 | load( 2 | "//jmh:jmh.bzl", 3 | "scala_benchmark_jmh", 4 | ) 5 | 6 | scala_benchmark_jmh( 7 | name = "jmh_reports_failure", 8 | srcs = [ 9 | "InvalidBenchmark.scala", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /test_expect_failure/jmh/InvalidBenchmark.scala: -------------------------------------------------------------------------------- 1 | package foo 2 | 3 | import org.openjdk.jmh.annotations.Benchmark 4 | 5 | // Benchmark classes cannot be final. 6 | final class InvalidBenchmark { 7 | @Benchmark 8 | def sumIntegersBenchmark: Int = 9 | (1 to 100).sum 10 | } 11 | -------------------------------------------------------------------------------- /test_expect_failure/mismatching_resource_strip_prefix/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "noSrcsJarWithWrongStripPrefix", 5 | resource_strip_prefix = "wrong_prefix", 6 | resources = ["resource.txt"], 7 | ) 8 | -------------------------------------------------------------------------------- /test_expect_failure/mismatching_resource_strip_prefix/resource.txt: -------------------------------------------------------------------------------- 1 | some resource :-) -------------------------------------------------------------------------------- /test_expect_failure/missing_direct_deps/external_deps/A.scala: -------------------------------------------------------------------------------- 1 | package test_expect_failure.missing_direct_deps.external_deps 2 | 3 | object A { 4 | def foo = { 5 | B.foo 6 | com.google.common.base.Strings.commonPrefix("abc", "abcd") 7 | } 8 | } -------------------------------------------------------------------------------- /test_expect_failure/missing_direct_deps/external_deps/B.scala: -------------------------------------------------------------------------------- 1 | package test_expect_failure.missing_direct_deps.external_deps 2 | 3 | object B { 4 | def foo = { 5 | println("in B") 6 | com.google.common.base.Strings.commonPrefix("abc", "abcd") 7 | } 8 | } -------------------------------------------------------------------------------- /test_expect_failure/missing_direct_deps/external_deps/Empty.java: -------------------------------------------------------------------------------- 1 | public class Empty {} 2 | -------------------------------------------------------------------------------- /test_expect_failure/missing_direct_deps/external_deps/UsesExternalDep.java: -------------------------------------------------------------------------------- 1 | import com.google.common.base.Charsets; 2 | 3 | public class UsesExternalDep { 4 | 5 | public void dependsOnExternalDep() { 6 | Empty useDirectDep = new Empty(); 7 | System.out.println(useDirectDep); 8 | System.out.println(Charsets.ISO_8859_1); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test_expect_failure/missing_direct_deps/filtering/UsesGuava.scala: -------------------------------------------------------------------------------- 1 | import com.google.common.base.Charsets 2 | 3 | class UsesGuava { 4 | println(Charsets.ISO_8859_1) 5 | } -------------------------------------------------------------------------------- /test_expect_failure/missing_direct_deps/internal_deps/A.scala: -------------------------------------------------------------------------------- 1 | package test_expect_failure.missing_direct_deps.internal_deps; 2 | 3 | object A { 4 | def foo = { 5 | B.foo 6 | C.foo 7 | } 8 | 9 | def main = foo 10 | } -------------------------------------------------------------------------------- /test_expect_failure/missing_direct_deps/internal_deps/B.scala: -------------------------------------------------------------------------------- 1 | package test_expect_failure.missing_direct_deps.internal_deps; 2 | 3 | object B { 4 | def foo = { 5 | C.foo 6 | } 7 | 8 | def main = foo 9 | } -------------------------------------------------------------------------------- /test_expect_failure/missing_direct_deps/internal_deps/C.scala: -------------------------------------------------------------------------------- 1 | package test_expect_failure.missing_direct_deps.internal_deps; 2 | 3 | object C { 4 | def foo = { 5 | println("in C") 6 | } 7 | } -------------------------------------------------------------------------------- /test_expect_failure/missing_direct_deps/internal_deps/D.scala: -------------------------------------------------------------------------------- 1 | package test_expect_failure.missing_direct_deps.internal_deps 2 | 3 | object D { 4 | def foo = { 5 | C.foo 6 | } 7 | 8 | def main = foo 9 | } -------------------------------------------------------------------------------- /test_expect_failure/missing_direct_deps/internal_deps/HasCustomJavaProviderDependency.scala: -------------------------------------------------------------------------------- 1 | package test_expect_failure.missing_direct_deps.internal_deps 2 | 3 | object HasCustomJavaProviderDependency { 4 | def foo = { 5 | C.foo 6 | } 7 | 8 | } -------------------------------------------------------------------------------- /test_expect_failure/missing_direct_deps/internal_deps/JavaLibraryHasCustomJavaProviderDependency.java: -------------------------------------------------------------------------------- 1 | package test_expect_failure.missing_direct_deps.internal_deps; 2 | 3 | public class JavaLibraryHasCustomJavaProviderDependency { 4 | public void foo() { 5 | C.foo(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test_expect_failure/missing_direct_deps/internal_deps/Placeholder.java: -------------------------------------------------------------------------------- 1 | package test_expect_failure.missing_direct_deps.internal_deps; 2 | 3 | public class Placeholder {} 4 | -------------------------------------------------------------------------------- /test_expect_failure/missing_direct_deps/internal_deps/User.java: -------------------------------------------------------------------------------- 1 | package test_expect_failure.missing_direct_deps.internal_deps; 2 | 3 | public class User { 4 | 5 | public void foo() { 6 | B.foo(); 7 | C.foo(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test_expect_failure/missing_direct_deps/scala_proto_deps/UseScalaProtoIndirectly.scala: -------------------------------------------------------------------------------- 1 | package scala_proto_deps 2 | 3 | import some.TestMessage 4 | 5 | class UseScalaProtoIndirectly { 6 | val foo: TestMessage = new UseTestMessage().getM 7 | } -------------------------------------------------------------------------------- /test_expect_failure/missing_direct_deps/scala_proto_deps/UseTestMessage.java: -------------------------------------------------------------------------------- 1 | package scala_proto_deps; 2 | 3 | import some.TestMessage; 4 | 5 | public class UseTestMessage { 6 | 7 | private final TestMessage m = new TestMessage("", null); 8 | 9 | public TestMessage getM() { 10 | return m; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test_expect_failure/missing_direct_deps/scala_proto_deps/some.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | message TestMessage { 4 | string message = 1; 5 | } -------------------------------------------------------------------------------- /test_expect_failure/plus_one_deps/deps_of_exports/A.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test_expect_failure.plus_one_deps.internal_deps 2 | 3 | class A { 4 | println(new B().hi) 5 | } 6 | -------------------------------------------------------------------------------- /test_expect_failure/plus_one_deps/deps_of_exports/B.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test_expect_failure.plus_one_deps.internal_deps 2 | 3 | class B extends C { 4 | def hi: String = "hi" 5 | } -------------------------------------------------------------------------------- /test_expect_failure/plus_one_deps/deps_of_exports/C.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test_expect_failure.plus_one_deps.internal_deps 2 | 3 | class C extends D -------------------------------------------------------------------------------- /test_expect_failure/plus_one_deps/deps_of_exports/D.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test_expect_failure.plus_one_deps.internal_deps 2 | 3 | class D { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /test_expect_failure/plus_one_deps/exports_of_deps/A.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test_expect_failure.plus_one_deps.internal_deps 2 | 3 | class A { 4 | println(new B().hi) 5 | } 6 | -------------------------------------------------------------------------------- /test_expect_failure/plus_one_deps/exports_of_deps/B.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test_expect_failure.plus_one_deps.internal_deps 2 | 3 | class B extends C { 4 | def hi: String = "hi" 5 | } -------------------------------------------------------------------------------- /test_expect_failure/plus_one_deps/exports_of_deps/C.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test_expect_failure.plus_one_deps.internal_deps 2 | 3 | class C extends D -------------------------------------------------------------------------------- /test_expect_failure/plus_one_deps/exports_of_deps/D.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test_expect_failure.plus_one_deps.internal_deps 2 | 3 | class D { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /test_expect_failure/plus_one_deps/external_deps/A.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test_expect_failure.plus_one_deps.external_deps 2 | import org.springframework.dao.DataAccessException 3 | 4 | class A { 5 | println(classOf[DataAccessException]) 6 | } -------------------------------------------------------------------------------- /test_expect_failure/plus_one_deps/external_deps/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "a", 5 | testonly = True, 6 | srcs = ["A.scala"], 7 | deps = ["@org_springframework_spring_tx"], 8 | ) 9 | -------------------------------------------------------------------------------- /test_expect_failure/plus_one_deps/internal_deps/A.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test_expect_failure.plus_one_deps.internal_deps 2 | 3 | class A { 4 | println(new B().hi) 5 | } 6 | -------------------------------------------------------------------------------- /test_expect_failure/plus_one_deps/internal_deps/B.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test_expect_failure.plus_one_deps.internal_deps 2 | 3 | class B extends C { 4 | def hi: String = "hi" 5 | } -------------------------------------------------------------------------------- /test_expect_failure/plus_one_deps/internal_deps/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "a", 5 | srcs = ["A.scala"], 6 | deps = [":b"], 7 | ) 8 | 9 | scala_library( 10 | name = "b", 11 | srcs = ["B.scala"], 12 | deps = [":c"], 13 | ) 14 | 15 | scala_library( 16 | name = "c", 17 | srcs = ["C.scala"], 18 | ) 19 | -------------------------------------------------------------------------------- /test_expect_failure/plus_one_deps/internal_deps/C.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test_expect_failure.plus_one_deps.internal_deps 2 | 3 | class C -------------------------------------------------------------------------------- /test_expect_failure/plus_one_deps/with_unused_deps/A.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test_expect_failure.plus_one_deps.with_unused_deps 2 | 3 | class A { 4 | println(new B().hi) 5 | } 6 | -------------------------------------------------------------------------------- /test_expect_failure/plus_one_deps/with_unused_deps/B.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test_expect_failure.plus_one_deps.with_unused_deps 2 | 3 | class B { 4 | def hi: String = { 5 | println(classOf[C]) 6 | "hi" 7 | } 8 | } -------------------------------------------------------------------------------- /test_expect_failure/plus_one_deps/with_unused_deps/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "a", 5 | srcs = ["A.scala"], 6 | deps = [ 7 | ":b", 8 | ":c", 9 | ], 10 | ) 11 | 12 | scala_library( 13 | name = "b", 14 | srcs = ["B.scala"], 15 | deps = [":c"], 16 | ) 17 | 18 | scala_library( 19 | name = "c", 20 | srcs = ["C.scala"], 21 | ) 22 | -------------------------------------------------------------------------------- /test_expect_failure/plus_one_deps/with_unused_deps/C.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test_expect_failure.plus_one_deps.with_unused_deps 2 | 3 | class C -------------------------------------------------------------------------------- /test_expect_failure/proto_source_root/dependency/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_proto//proto:defs.bzl", "proto_library") 2 | 3 | proto_library( 4 | name = "dependency", 5 | srcs = glob(["*.proto"]), 6 | strip_import_prefix = "", 7 | visibility = ["//visibility:public"], 8 | ) 9 | -------------------------------------------------------------------------------- /test_expect_failure/proto_source_root/dependency/zip_code.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package demo; // Requried to generate valid code. 4 | 5 | message ZipCode { 6 | string code = 1; 7 | } 8 | -------------------------------------------------------------------------------- /test_expect_failure/proto_source_root/user/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_proto//proto:defs.bzl", "proto_library") 2 | load( 3 | "//scala_proto:scala_proto.bzl", 4 | "scala_proto_library", 5 | ) 6 | 7 | proto_library( 8 | name = "user", 9 | srcs = glob(["*.proto"]), 10 | strip_import_prefix = "", 11 | deps = ["//test_expect_failure/proto_source_root/dependency"], 12 | ) 13 | 14 | scala_proto_library( 15 | name = "user_scala", 16 | visibility = ["//visibility:public"], 17 | deps = [":user"], 18 | ) 19 | -------------------------------------------------------------------------------- /test_expect_failure/proto_source_root/user/address.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package demo; // Requried to generate valid code. 4 | 5 | import "zip_code.proto"; 6 | 7 | message Address { 8 | string city = 1; 9 | ZipCode zip_code = 2; 10 | } 11 | -------------------------------------------------------------------------------- /test_expect_failure/proto_source_root/user/person.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package demo; // Requried to generate valid code. 4 | 5 | import "address.proto"; 6 | 7 | message Person { 8 | string name = 1; 9 | int32 id = 2; 10 | string email = 3; 11 | Address address = 4; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /test_expect_failure/scala_import/LeafScalaImportPassesLabelsDirectDeps.scala: -------------------------------------------------------------------------------- 1 | package test_expect_failure.scala_import 2 | 3 | class LeafScalaImportPassesLabelsDirectDeps { 4 | println(classOf[RootScalaImportPassesLabelsDirectDeps]) 5 | } -------------------------------------------------------------------------------- /test_expect_failure/scala_import/RootScalaImportPassesLabelsDirectDeps.scala: -------------------------------------------------------------------------------- 1 | package test_expect_failure.scala_import 2 | class RootScalaImportPassesLabelsDirectDeps -------------------------------------------------------------------------------- /test_expect_failure/scala_junit_test/JunitFailureTest.scala: -------------------------------------------------------------------------------- 1 | 2 | import org.junit.Test 3 | 4 | class JunitFailureTest { 5 | 6 | @Test 7 | def failing: Unit = { 8 | throw new RuntimeException("this test knows how to fail") 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test_expect_failure/scala_junit_test/JunitTest.scala: -------------------------------------------------------------------------------- 1 | 2 | import org.junit.Test 3 | 4 | class JunitTest { 5 | 6 | @Test 7 | def running: Unit = { 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /test_expect_failure/scala_junit_test/specs2/FailingTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit.specs2 2 | 3 | import org.specs2.mutable.SpecWithJUnit 4 | 5 | class FailingTest extends SpecWithJUnit { 6 | 7 | val boom: String = { throw new Exception("Boom") } 8 | 9 | "some test" >> { boom must beEmpty } 10 | } 11 | -------------------------------------------------------------------------------- /test_expect_failure/scala_junit_test/specs2/SuiteWithOneFailingTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit.specs2 2 | 3 | import org.specs2.mutable.SpecWithJUnit 4 | 5 | class SuiteWithOneFailingTest extends SpecWithJUnit { 6 | 7 | "specs2 tests" >> { 8 | "succeed" >> success 9 | "fail" >> failure("boom") 10 | } 11 | 12 | "some other suite" >> { 13 | "do stuff" >> success 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test_expect_failure/scala_library_suite/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library_suite") 2 | 3 | scala_library_suite( 4 | name = "library_suite_dep_on_children", 5 | srcs = glob(["Data*.scala"]), 6 | ) 7 | -------------------------------------------------------------------------------- /test_expect_failure/scala_library_suite/DataA.scala: -------------------------------------------------------------------------------- 1 | clearly not a valid scala file 2 | -------------------------------------------------------------------------------- /test_expect_failure/scala_test_env_inherit/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_test") 2 | 3 | scala_test( 4 | name = "inherit_a", 5 | srcs = ["InheritedEnvTest.scala"], 6 | env_inherit = ["a"], 7 | ) 8 | -------------------------------------------------------------------------------- /test_expect_failure/scala_test_env_inherit/InheritedEnvTest.scala: -------------------------------------------------------------------------------- 1 | import org.scalatest.funsuite._ 2 | import org.scalatest.matchers.should._ 3 | 4 | class InheritedEnvTest extends AnyFunSuite with Matchers { 5 | test("value from inherit_env") { 6 | sys.env("a") should equal("b") 7 | } 8 | } -------------------------------------------------------------------------------- /test_expect_failure/scala_test_jacocorunner/EmptyTest.scala: -------------------------------------------------------------------------------- 1 | package test_expect_failure.scala_test_jacocorunner 2 | 3 | import org.scalatest.FunSuite 4 | 5 | class EmptyTest extends FunSuite { 6 | test("empty test") { 7 | assert(true) 8 | } 9 | } -------------------------------------------------------------------------------- /test_expect_failure/scala_test_jvm_flags/EmptyTest.scala: -------------------------------------------------------------------------------- 1 | package test_expect_failure.scala_test_jvm_flags 2 | 3 | import org.scalatest.FunSuite 4 | 5 | class EmptyTest extends FunSuite { 6 | test("empty test") { 7 | assert(true) 8 | } 9 | } -------------------------------------------------------------------------------- /test_expect_failure/scala_test_testfilter/A.scala: -------------------------------------------------------------------------------- 1 | import org.scalatest.funsuite.AnyFunSuite 2 | 3 | class A extends AnyFunSuite { 4 | 5 | test("test 1") { 6 | 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test_expect_failure/scala_test_testfilter/B.scala: -------------------------------------------------------------------------------- 1 | import org.scalatest.funsuite.AnyFunSuite 2 | 3 | class B extends AnyFunSuite { 4 | 5 | test("test 1") { 6 | fail("This test should not be selected") 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test_expect_failure/scala_test_testfilter/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_test") 2 | 3 | scala_test( 4 | name = "tests", 5 | srcs = [ 6 | "A.scala", 7 | "B.scala", 8 | ], 9 | ) 10 | -------------------------------------------------------------------------------- /test_expect_failure/scalac_exceptions/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library", "scala_macro_library") 2 | 3 | scala_macro_library( 4 | name = "bad_macro", 5 | srcs = ["BadMacro.scala"], 6 | ) 7 | 8 | scala_library( 9 | name = "bad_macro_invocation", 10 | srcs = ["BadMacroInvocation.scala"], 11 | deps = [":bad_macro"], 12 | ) 13 | 14 | scala_library( 15 | name = "stack_overflow_macro_invocation", 16 | srcs = ["StackOverflowMacroInvocation.scala"], 17 | deps = [":bad_macro"], 18 | ) 19 | -------------------------------------------------------------------------------- /test_expect_failure/scalac_exceptions/BadMacro.scala: -------------------------------------------------------------------------------- 1 | import scala.language.experimental.macros 2 | 3 | object BadMacro { 4 | def badMacro(): Unit = macro badMacroImpl 5 | def stackOverflowMacro(): Unit = macro stackOverflowMacroImpl 6 | 7 | def badMacroImpl(c: scala.reflect.macros.blackbox.Context)(): c.Tree = { 8 | throw new NoSuchMethodError() 9 | } 10 | 11 | def uhOh(n: Int): Int = n + uhOh(n + 1) 12 | 13 | def stackOverflowMacroImpl(c: scala.reflect.macros.blackbox.Context)(): c.Tree = { 14 | import c.universe._ 15 | uhOh(1) 16 | q"" 17 | } 18 | } -------------------------------------------------------------------------------- /test_expect_failure/scalac_exceptions/BadMacroInvocation.scala: -------------------------------------------------------------------------------- 1 | object BadMacroInvocation { 2 | BadMacro.badMacro() 3 | } -------------------------------------------------------------------------------- /test_expect_failure/scalac_exceptions/StackOverflowMacroInvocation.scala: -------------------------------------------------------------------------------- 1 | object StackOverflowMacroInvocation { 2 | BadMacro.stackOverflowMacro() 3 | } 4 | -------------------------------------------------------------------------------- /test_expect_failure/scalac_jvm_opts/Empty.scala: -------------------------------------------------------------------------------- 1 | package test_expect_failure.scalac_jvm_opts 2 | 3 | class Empty -------------------------------------------------------------------------------- /test_expect_failure/scalacopts_from_toolchain/ClassWithUnused.scala: -------------------------------------------------------------------------------- 1 | package test_expect_failure.scalacopts_from_toolchain 2 | 3 | class ClassWithUnused(name:String){ 4 | def talk():String = { 5 | val unusedValue = "I am not used :-(" 6 | s"hello $name" 7 | } 8 | } -------------------------------------------------------------------------------- /test_expect_failure/scalacopts_invalid/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "empty", 5 | srcs = ["Empty.scala"], 6 | scalacopts = ["-source:not-existing"], 7 | ) 8 | -------------------------------------------------------------------------------- /test_expect_failure/scalacopts_invalid/Empty.scala: -------------------------------------------------------------------------------- 1 | package test_expect_failure.scalacopts_invalid 2 | 3 | class Empty 4 | -------------------------------------------------------------------------------- /test_expect_failure/scaladoc/A.scala: -------------------------------------------------------------------------------- 1 | 2 | object A { 3 | def main() { 4 | println("hi") 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test_expect_failure/scaladoc/B.scala: -------------------------------------------------------------------------------- 1 | object B { 2 | def myfunc() { 3 | A.main() 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test_expect_failure/scaladoc/C.scala: -------------------------------------------------------------------------------- 1 | //import cats.syntax.all._ 2 | 3 | object C { 4 | def myfunc() = { 5 | A.main() //Call into A, which is a transitive dependency of this lib 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test_expect_failure/scaladoc/scaladoc.bzl: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "make_scala_doc_rule", "scaladoc_intransitive_aspect") 2 | 3 | scala_doc_intransitive = make_scala_doc_rule(scaladoc_intransitive_aspect) #Only scaladoc specified deps 4 | -------------------------------------------------------------------------------- /test_expect_failure/transitive/java_to_scala/A.scala: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | object A { 4 | def foo { 5 | println("hi") 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test_expect_failure/transitive/java_to_scala/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_library") 2 | load("//scala:scala.bzl", "scala_library") 3 | 4 | scala_library( 5 | name = "a", 6 | srcs = ["A.scala"], 7 | ) 8 | 9 | java_library( 10 | name = "c", 11 | srcs = ["C.java"], 12 | deps = [":a"], 13 | ) 14 | 15 | java_library( 16 | name = "d", 17 | srcs = ["D.java"], 18 | tags = ["manual"], 19 | deps = [":c"], 20 | ) 21 | -------------------------------------------------------------------------------- /test_expect_failure/transitive/java_to_scala/C.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public class C {} 4 | -------------------------------------------------------------------------------- /test_expect_failure/transitive/java_to_scala/D.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public class D { 4 | public static void main(String[] args) { 5 | A.foo(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test_expect_failure/transitive/scala_to_java/A.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public class A { 4 | public static void foo() { 5 | System.out.println("yeah?"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test_expect_failure/transitive/scala_to_java/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_library") 2 | load("//scala:scala.bzl", "scala_library") 3 | 4 | java_library( 5 | name = "a", 6 | srcs = ["A.java"], 7 | ) 8 | 9 | scala_library( 10 | name = "b", 11 | exports = [":a"], 12 | ) 13 | 14 | scala_library( 15 | name = "c", 16 | deps = [":b"], 17 | ) 18 | 19 | scala_library( 20 | name = "d", 21 | srcs = ["D.scala"], 22 | tags = ["manual"], 23 | deps = [":c"], 24 | ) 25 | -------------------------------------------------------------------------------- /test_expect_failure/transitive/scala_to_java/D.scala: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | object D { 4 | def main(args: Array[String]) { 5 | A.foo 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test_expect_failure/transitive/scala_to_scala/A.scala: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | object A { 4 | def foo { 5 | println("hi") 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test_expect_failure/transitive/scala_to_scala/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "a", 5 | srcs = ["A.scala"], 6 | ) 7 | 8 | scala_library( 9 | name = "b", 10 | exports = [":a"], 11 | ) 12 | 13 | scala_library( 14 | name = "c", 15 | deps = [":b"], 16 | ) 17 | 18 | scala_library( 19 | name = "d", 20 | srcs = ["D.scala"], 21 | tags = ["manual"], 22 | deps = [":c"], 23 | ) 24 | -------------------------------------------------------------------------------- /test_expect_failure/transitive/scala_to_scala/D.scala: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | object D { 4 | def main(args: Array[String]) { 5 | A.foo 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test_expect_failure/unused_dependency_checker/A.scala: -------------------------------------------------------------------------------- 1 | class A {} 2 | -------------------------------------------------------------------------------- /test_expect_failure/unused_dependency_checker/B.scala: -------------------------------------------------------------------------------- 1 | class B {} 2 | -------------------------------------------------------------------------------- /test_expect_failure/unused_dependency_checker/filtering/Empty.scala: -------------------------------------------------------------------------------- 1 | class Empty -------------------------------------------------------------------------------- /test_lint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eou pipefail 4 | 5 | dir="${BASH_SOURCE[0]%/*}" 6 | dir="$( cd "${dir:-.}" && pwd )" 7 | 8 | bazel run //tools:lint_check 9 | 10 | . "${dir}/test/shell/test_bzlmod_tidy.sh" 11 | -------------------------------------------------------------------------------- /test_statsfile/Simple.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | object Simple { 4 | def main(args: Array[String]) { 5 | println(args) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test_version/protobuf.patch: -------------------------------------------------------------------------------- 1 | ../protoc/0001-protobuf-19679-rm-protoc-dep.patch -------------------------------------------------------------------------------- /test_version/test_reporter/ErrorFile.scala: -------------------------------------------------------------------------------- 1 | object ErrorFile { 2 | val value = "someVal" 3 | 4 | def main(args: Array[String]): Unit = { 5 | println(value 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/Exported.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | object Exported { 4 | def message: String = { 5 | // terrible, don't do this in real code: 6 | val msg = Class.forName("scalarules.test.Runtime") 7 | .newInstance 8 | .toString 9 | "you all, everybody. " + msg 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/MacroTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | import language.experimental.macros 4 | 5 | import reflect.macros.Context 6 | 7 | object MacroTest { 8 | def hello(param: Any): Unit = macro hello_impl 9 | 10 | def hello_impl(c: Context)(param: c.Expr[Any]): c.Expr[Unit] = { 11 | import c.universe._ 12 | val paramRep = show(param.tree) 13 | val paramRepTree = Literal(Constant(paramRep)) 14 | val paramRepExpr = c.Expr[String](paramRepTree) 15 | reify { println(paramRepExpr.splice + " = " + param.splice) } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/Runtime.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | class Runtime { 4 | override def toString = "I am Runtime" 5 | } 6 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/proto/test2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | import "proto2/test.proto"; 4 | option java_package = "test.proto"; 5 | 6 | message TestResponse1 { 7 | optional uint32 c = 1; 8 | optional bool d = 2; 9 | optional TestMessage testMsg = 3; 10 | } 11 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/proto/test3.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | import "proto2/test.proto"; 4 | option java_package = "test.proto"; 5 | 6 | message TestResponse2 { 7 | optional uint32 e = 1; 8 | optional bool f = 2; 9 | optional TestMessage testMsg = 3; 10 | } 11 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/proto/test_service.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | import "proto2/test.proto"; 4 | import "proto/test2.proto"; 5 | import "proto/test3.proto"; 6 | 7 | option java_package = "test.proto"; 8 | 9 | service TestService { 10 | rpc TestMethod1 (TestRequest) returns (TestResponse1) {} 11 | rpc TestMethod2 (TestRequest) returns (TestResponse2) {} 12 | } 13 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/proto2/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_proto//proto:defs.bzl", "proto_library") 2 | 3 | proto_library( 4 | name = "test", 5 | srcs = ["test.proto"], 6 | visibility = ["//visibility:public"], 7 | ) 8 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/proto2/test.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | option java_package = "test.proto"; 4 | 5 | message TestRequest { 6 | optional uint32 a = 1; 7 | optional bool b = 2; 8 | } 9 | 10 | message TestMessage { 11 | optional string foo = 1; 12 | } 13 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/resources/scalarules/test/BUILD: -------------------------------------------------------------------------------- 1 | exports_files([ 2 | "Foo.thrift", 3 | "Bar.thrift", 4 | "Baz.thrift", 5 | ]) 6 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/resources/scalarules/test/Bar.thrift: -------------------------------------------------------------------------------- 1 | namespace java com.foo.bar.baz 2 | 3 | struct Bar { 4 | 1: optional string Bar 5 | } 6 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/resources/scalarules/test/Baz.thrift: -------------------------------------------------------------------------------- 1 | namespace java com.foo.bar.baz 2 | 3 | struct Baz { 4 | 1: optional string Baz 5 | } 6 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/resources/scalarules/test/Foo.thrift: -------------------------------------------------------------------------------- 1 | namespace java com.foo.bar.baz 2 | 3 | struct Foo { 4 | 1: optional string foo 5 | } 6 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/junit/support/JUnitCompileTimeDep.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit.support 2 | object JUnitCompileTimeDep { 3 | val hello = "hello" 4 | } 5 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/junit/support/JUnitRuntimeDep.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit.support 2 | class JUnitRuntimeDep 3 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/mix_java_scala/Bar.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | class Foo 3 | class Bar extends Baz 4 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/mix_java_scala/Baz.java: -------------------------------------------------------------------------------- 1 | package scalarules.test; 2 | 3 | public class Baz extends Foo {} 4 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/mix_java_scala/FooBar.java: -------------------------------------------------------------------------------- 1 | package scalarules.test; 2 | 3 | public class FooBar extends Foo {} 4 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/BareThrifts.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.twitter_scrooge 2 | 3 | import com.foo.bar.baz.Foo 4 | import com.foo.bar.baz.Bar 5 | import com.foo.bar.baz.Baz 6 | 7 | object BareThrifts { 8 | val classes = Seq(classOf[Foo], classOf[Bar], classOf[Baz]) 9 | 10 | def main(args: Array[String]) { 11 | print(s"classes ${classes.mkString(",")}") 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/JustScrooge2a.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.twitter_scrooge 2 | 3 | import scalarules.test.twitter_scrooge.thrift.thrift2.Struct2A 4 | import scalarules.test.twitter_scrooge.thrift.thrift2.thrift3.Struct3 5 | 6 | object JustScrooge2a { 7 | val classes = Seq(classOf[Struct2A], classOf[Struct3]) 8 | } 9 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/JustScrooge2b.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.twitter_scrooge 2 | 3 | import scalarules.test.twitter_scrooge.thrift.thrift2.Struct2B 4 | import scalarules.test.twitter_scrooge.thrift.thrift2.thrift3.Struct3 5 | 6 | object JustScrooge2b { 7 | val classes = Seq(classOf[Struct2B], classOf[Struct3]) 8 | 9 | def main(args: Array[String]) { 10 | classes foreach println 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/JustScrooge3.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.twitter_scrooge 2 | 3 | import scalarules.test.twitter_scrooge.thrift.thrift2.thrift3.Struct3 4 | 5 | object JustScrooge3 { 6 | val classes = Seq(classOf[Struct3]) 7 | } 8 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/Scrooge2.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.twitter_scrooge 2 | 3 | import scalarules.test.twitter_scrooge.thrift.thrift2.{Struct2A, Struct2B} 4 | import scalarules.test.twitter_scrooge.thrift.thrift2.thrift3.Struct3 5 | 6 | object Scrooge2 { 7 | val classes = Seq(classOf[Struct2A], classOf[Struct2B], classOf[Struct3]) 8 | } 9 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/Twodeep.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.twitter_scrooge 2 | 3 | import scalarules.test.twitter_scrooge.thrift.thrift2.thrift3.Struct3 4 | 5 | object Twodeep { 6 | val classes = 7 | Seq( 8 | classOf[Struct3], 9 | JustScrooge3.getClass 10 | ) 11 | 12 | def main(args: Array[String]) { 13 | classes foreach println 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/grep.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | 4 | # this is used by a sh_test to test that a string is NOT 5 | # found in a file. This is used for instance to check if 6 | # stray jars are not making it onto the classpath 7 | 8 | if grep -q $1 $2 ; then 9 | echo "ERROR: found $1" 10 | exit 1 11 | else 12 | exit 0 13 | fi 14 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/prefix_test/a/b/c/d/A.thrift: -------------------------------------------------------------------------------- 1 | namespace java scalarules.test.twitter_scrooge.prefix_test.a.b.c.d 2 | 3 | struct StructA { 4 | 1: string field 5 | } 6 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/prefix_test/e/f/b/c/d/B.thrift: -------------------------------------------------------------------------------- 1 | namespace java scalarules.test.twitter_scrooge.prefix_test.a.b.c.d 2 | 3 | include "b/c/d/A.thrift" 4 | 5 | struct StructB { 6 | 1: A.StructA field 7 | } 8 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/Thrift1.thrift: -------------------------------------------------------------------------------- 1 | namespace java scalarules.test.twitter_scrooge.thrift 2 | 3 | include "thrift2/Thrift2_A.thrift" 4 | include "thrift2/Thrift2_B.thrift" 5 | include "thrift2/thrift3/Thrift3.thrift" 6 | 7 | struct Struct1 { 8 | 1: Thrift2_A.Struct2A msg_a 9 | 2: Thrift2_B.Struct2B msg_b 10 | 3: Thrift3.Struct3 msg 11 | } -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/ThriftMany1.thrift: -------------------------------------------------------------------------------- 1 | struct Many1 { 2 | 1: i32 one 3 | } 4 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/ThriftMany2.thrift: -------------------------------------------------------------------------------- 1 | struct Many2 { 2 | 1: i16 two 3 | } 4 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/BareJar.thrift: -------------------------------------------------------------------------------- 1 | namespace java com.foo.bar.baz 2 | 3 | include "Foo.thrift" 4 | include "Bar.thrift" 5 | include "Baz.thrift" 6 | 7 | struct BareJar { 8 | 1: Foo foo 9 | 2: Bar bar 10 | 3: Baz baz 11 | } 12 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_1/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_scala//thrift:thrift.bzl", "thrift_library") 2 | 3 | thrift_library( 4 | name = "bar", 5 | srcs = ["//src/main/resources/scalarules/test:Bar.thrift"], 6 | ) 7 | 8 | thrift_library( 9 | name = "bare_jar_1", 10 | external_jars = [ 11 | ":libbar.jar", 12 | ], 13 | visibility = ["//visibility:public"], 14 | ) 15 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_2/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_scala//thrift:thrift.bzl", "thrift_library") 2 | 3 | thrift_library( 4 | name = "baz", 5 | srcs = ["//src/main/resources/scalarules/test:Baz.thrift"], 6 | ) 7 | 8 | thrift_library( 9 | name = "bare_jar_2", 10 | external_jars = [ 11 | ":libbaz.jar", 12 | ], 13 | visibility = ["//visibility:public"], 14 | ) 15 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/Thrift2_A.thrift: -------------------------------------------------------------------------------- 1 | namespace java scalarules.test.twitter_scrooge.thrift.thrift2 2 | 3 | include "thrift3/Thrift3.thrift" 4 | 5 | struct Struct2A { 6 | 1: Thrift3.Struct3 msg 7 | } -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/Thrift2_B.thrift: -------------------------------------------------------------------------------- 1 | namespace java scalarules.test.twitter_scrooge.thrift.thrift2 2 | 3 | // TODO We should be able to do a full import based on the full package 4 | // which will make refactoring targets much less fragile 5 | include "thrift3/Thrift3.thrift" 6 | 7 | struct Struct2B { 8 | 1: Thrift3.Struct3 msg 9 | } -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/thrift3/Thrift3.thrift: -------------------------------------------------------------------------------- 1 | namespace java scalarules.test.twitter_scrooge.thrift.thrift2.thrift3 2 | 3 | struct Struct3 { 4 | 1: string msg 5 | } 6 | 7 | struct Struct3Extra { 8 | 1: string msg 9 | } -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/thrift4/Thrift4.thrift: -------------------------------------------------------------------------------- 1 | namespace java scalarules.test.twitter_scrooge.thrift.thrift2.thrift3 2 | 3 | include "../Thrift2_A.thrift" 4 | 5 | struct Struct4 { 6 | 1: Thrift2_A.Struct2A nested 7 | } 8 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/thrift4/Thrift4a.thrift: -------------------------------------------------------------------------------- 1 | include "./Thrift4.thrift" 2 | 3 | struct Struct4a { 4 | 1: Thrift4.Struct4 nest; 5 | } 6 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/test_binary.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "Executing: " $@ 4 | $@ 5 | -------------------------------------------------------------------------------- /testing/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_scala_config//:config.bzl", "SCALA_VERSION") 2 | load("//scala:scala_cross_version.bzl", "version_suffix") 3 | 4 | # Aliases for backward compatibility: 5 | [ 6 | alias( 7 | name = framework + "_toolchain", 8 | actual = ( 9 | "@rules_scala_toolchains//testing:testing_toolchain" + 10 | version_suffix(SCALA_VERSION) 11 | ), 12 | ) 13 | for framework in [ 14 | "testing", 15 | "scalatest", 16 | "specs2_junit", 17 | "junit", 18 | ] 19 | ] 20 | -------------------------------------------------------------------------------- /testing/toolchain/BUILD: -------------------------------------------------------------------------------- 1 | load("//testing:testing.bzl", "DEP_PROVIDERS") 2 | load(":toolchain_deps.bzl", "testing_toolchain_deps") 3 | 4 | toolchain_type( 5 | name = "testing_toolchain_type", 6 | visibility = ["//visibility:public"], 7 | ) 8 | 9 | [ 10 | testing_toolchain_deps( 11 | name = dep, 12 | deps_id = dep, 13 | visibility = ["//visibility:public"], 14 | ) 15 | for dep in DEP_PROVIDERS 16 | ] 17 | -------------------------------------------------------------------------------- /testing/toolchain/toolchain.bzl: -------------------------------------------------------------------------------- 1 | load("//scala:providers.bzl", _DepsInfo = "DepsInfo") 2 | 3 | def _scala_toolchain_impl(ctx): 4 | toolchain = platform_common.ToolchainInfo( 5 | dep_providers = ctx.attr.dep_providers, 6 | ) 7 | return [toolchain] 8 | 9 | scala_testing_toolchain = rule( 10 | _scala_toolchain_impl, 11 | attrs = { 12 | "dep_providers": attr.label_list( 13 | providers = [_DepsInfo], 14 | ), 15 | }, 16 | ) 17 | -------------------------------------------------------------------------------- /testing/toolchain/toolchain_deps.bzl: -------------------------------------------------------------------------------- 1 | load( 2 | "//scala/private/toolchain_deps:toolchain_deps.bzl", 3 | "expose_toolchain_deps", 4 | ) 5 | 6 | _toolchain_type = "//testing/toolchain:testing_toolchain_type" 7 | 8 | def _testing_toolchain_deps(ctx): 9 | return expose_toolchain_deps(ctx, _toolchain_type) 10 | 11 | testing_toolchain_deps = rule( 12 | implementation = _testing_toolchain_deps, 13 | attrs = { 14 | "deps_id": attr.string(mandatory = True), 15 | }, 16 | toolchains = [_toolchain_type], 17 | ) 18 | -------------------------------------------------------------------------------- /third_party/README.md: -------------------------------------------------------------------------------- 1 | # Third party dependencies 2 | 3 | This file lists license and version information of all code we did not author 4 | 5 | ## dependency_analyzer 6 | 7 | dependency_analyzer scala compiler plugin is based on [classpath-shrinker](https://github.com/scalacenter/classpath-shrinker) plugin. 8 | License: 3-clause revised BSD 9 | -------------------------------------------------------------------------------- /third_party/dependency_analyzer/src/main/resources/plugin.properties: -------------------------------------------------------------------------------- 1 | pluginClass=io.bazel.rulesscala.dependencyanalyzer.DependencyAnalyzer 2 | 3 | -------------------------------------------------------------------------------- /third_party/dependency_analyzer/src/main/resources/scalac-plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | dependency-analyzer 3 | io.bazel.rulesscala.dependencyanalyzer.DependencyAnalyzer 4 | -------------------------------------------------------------------------------- /third_party/dependency_analyzer/src/test/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_test") 2 | load(":analyzer_test.bzl", "tests", "version_specific_tests") 3 | 4 | tests() 5 | 6 | version_specific_tests() 7 | 8 | scala_test( 9 | name = "test_optionsparser", 10 | srcs = ["test_optionsparser.scala"], 11 | deps = ["//third_party/dependency_analyzer/src/main:dependency_analyzer"], 12 | ) 13 | -------------------------------------------------------------------------------- /third_party/repositories/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/third_party/repositories/BUILD -------------------------------------------------------------------------------- /third_party/test/example_external_workspace/.bazelrc: -------------------------------------------------------------------------------- 1 | import ../../../.bazelrc 2 | -------------------------------------------------------------------------------- /third_party/test/example_external_workspace/.bazelversion: -------------------------------------------------------------------------------- 1 | 7.6.1 2 | -------------------------------------------------------------------------------- /third_party/test/example_external_workspace/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/third_party/test/example_external_workspace/BUILD -------------------------------------------------------------------------------- /third_party/test/example_external_workspace/protobuf.patch: -------------------------------------------------------------------------------- 1 | ../../../protoc/0001-protobuf-19679-rm-protoc-dep.patch -------------------------------------------------------------------------------- /third_party/test/example_external_workspace/strip/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_scala//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "noSrcsWithResources", 5 | resource_strip_prefix = "strip", 6 | resources = ["nosrc_jar_resource.txt"], 7 | visibility = ["//visibility:public"], 8 | ) 9 | -------------------------------------------------------------------------------- /third_party/test/example_external_workspace/strip/nosrc_jar_resource.txt: -------------------------------------------------------------------------------- 1 | I am a text resource! 2 | -------------------------------------------------------------------------------- /third_party/test/example_external_workspace/test/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_scala//scala:scala.bzl", "scala_test") 2 | 3 | scala_test( 4 | name = "empty_test", 5 | srcs = ["EmptyTest.scala"], 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/test/example_external_workspace/test/EmptyTest.scala: -------------------------------------------------------------------------------- 1 | import org.scalatest.funsuite._ 2 | 3 | class EmptyTest extends AnyFunSuite { 4 | test("empty test") { 5 | assert(true) 6 | } 7 | } -------------------------------------------------------------------------------- /third_party/test/new_local_repo/.bazelversion: -------------------------------------------------------------------------------- 1 | 7.6.1 2 | -------------------------------------------------------------------------------- /third_party/test/new_local_repo/BUILD: -------------------------------------------------------------------------------- 1 | filegroup( 2 | name = "data", 3 | srcs = glob(["**/*.txt"]), 4 | visibility = ["//visibility:public"], 5 | ) 6 | -------------------------------------------------------------------------------- /third_party/test/new_local_repo/MODULE.bazel: -------------------------------------------------------------------------------- 1 | module(name = "test_new_local_repo") 2 | -------------------------------------------------------------------------------- /third_party/test/new_local_repo/WORKSPACE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/third_party/test/new_local_repo/WORKSPACE -------------------------------------------------------------------------------- /third_party/test/new_local_repo/resource.txt: -------------------------------------------------------------------------------- 1 | A resource 2 | -------------------------------------------------------------------------------- /third_party/test/proto/.bazelrc: -------------------------------------------------------------------------------- 1 | import ../../../.bazelrc 2 | -------------------------------------------------------------------------------- /third_party/test/proto/.bazelversion: -------------------------------------------------------------------------------- 1 | 7.6.1 2 | -------------------------------------------------------------------------------- /third_party/test/proto/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_proto//proto:defs.bzl", "proto_library") 2 | load("@rules_scala//scala_proto:scala_proto.bzl", "scala_proto_library") 3 | 4 | proto_library( 5 | name = "proto", 6 | srcs = ["test.proto"], 7 | ) 8 | 9 | scala_proto_library( 10 | name = "scala", 11 | deps = [":proto"], 12 | ) 13 | -------------------------------------------------------------------------------- /third_party/test/proto/protobuf.patch: -------------------------------------------------------------------------------- 1 | ../../../protoc/0001-protobuf-19679-rm-protoc-dep.patch -------------------------------------------------------------------------------- /third_party/test/proto/test.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | message Test { 4 | string field = 1; 5 | } 6 | -------------------------------------------------------------------------------- /third_party/utils/src/test/io/bazel/rulesscala/utils/CommandLineParserAdapter_before_2_13_9.scala: -------------------------------------------------------------------------------- 1 | package io.bazel.rulesscala.utils 2 | 3 | import scala.tools.cmd.CommandLineParser 4 | 5 | object CommandLineParserAdapter { 6 | def tokenize(cmd: String): List[String] = CommandLineParser.tokenize(cmd) 7 | } 8 | -------------------------------------------------------------------------------- /third_party/utils/src/test/io/bazel/rulesscala/utils/CommandLineParserAdapter_since_2_13_9.scala: -------------------------------------------------------------------------------- 1 | package scala { 2 | package rulesscala { 3 | // proxy to private[scala] compiler API 4 | object Proxy { 5 | def tokenize(cmd: String): List[String] = sys.process.Parser.tokenize(cmd) 6 | } 7 | } 8 | } 9 | 10 | package io.bazel.rulesscala.utils { 11 | object CommandLineParserAdapter { 12 | def tokenize(cmd: String): List[String] = 13 | scala.rulesscala.Proxy.tokenize(cmd) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /thrift/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazel-contrib/rules_scala/d222569ee056b617487ae8f584d161c29005fdc5/thrift/BUILD -------------------------------------------------------------------------------- /thrift/thrift_info.bzl: -------------------------------------------------------------------------------- 1 | ThriftInfo = provider(fields = [ 2 | "srcs", # The source files in this rule 3 | "transitive_srcs", # the transitive version of the above 4 | ]) 5 | -------------------------------------------------------------------------------- /tools/bazel.rc.buildkite: -------------------------------------------------------------------------------- 1 | # Remove once Bazel 8 becomes the default supported version. 2 | common --noenable_workspace --incompatible_use_plus_in_repo_names 3 | 4 | # Remove once proto toolchainization becomes the default 5 | # - https://bazel.build/reference/command-line-reference#flag--incompatible_enable_proto_toolchain_resolution 6 | # - https://docs.google.com/document/d/1CE6wJHNfKbUPBr7-mmk_0Yo3a4TaqcTPE0OWNuQkhPs/edit 7 | common --incompatible_enable_proto_toolchain_resolution 8 | 9 | build --strategy=Scalac=worker --strategy=ScroogeRule=worker --worker_max_instances=3 10 | -------------------------------------------------------------------------------- /twitter_scrooge/BUILD: -------------------------------------------------------------------------------- 1 | load( 2 | "//twitter_scrooge/toolchain:toolchain.bzl", 3 | "DEP_PROVIDERS", 4 | "export_scrooge_deps", 5 | ) 6 | 7 | [ 8 | export_scrooge_deps( 9 | name = dep, 10 | deps_id = dep, 11 | visibility = ["//visibility:public"], 12 | ) 13 | for dep in DEP_PROVIDERS 14 | ] 15 | -------------------------------------------------------------------------------- /twitter_scrooge/toolchain/BUILD: -------------------------------------------------------------------------------- 1 | toolchain_type( 2 | name = "scrooge_toolchain_type", 3 | visibility = ["//visibility:public"], 4 | ) 5 | --------------------------------------------------------------------------------