├── .bazelci └── presubmit.yml ├── .bazelrc.travis ├── .github └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .scalafmt.conf ├── .travis.yml ├── AUTHORS ├── BUILD ├── CODEOWNERS ├── CONTRIBUTING.md ├── CONTRIBUTORS ├── LICENSE.txt ├── README.md ├── WORKSPACE ├── dangerous_test_thirdparty_version.sh ├── docs ├── coverage.md ├── customizable_phase.md ├── phase_scalafmt.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 └── thrift_library.md ├── java_stub_template └── file │ ├── BUILD.bazel │ └── file.txt ├── jmh ├── BUILD └── jmh.bzl ├── junit ├── BUILD └── junit.bzl ├── lint.sh ├── manual_test ├── README.md ├── scala_test_jvm_flags │ ├── BUILD │ └── EmptyTest.scala └── scalac_jvm_opts │ ├── BUILD │ ├── Empty.scala │ └── test.proto ├── private ├── BUILD └── format.bzl ├── scala ├── BUILD ├── PlaceHolderClassToCreateEmptyJarForScalaImport.java ├── advanced_usage │ ├── providers.bzl │ └── scala.bzl ├── jars_to_labels.bzl ├── plusone.bzl ├── private │ ├── BUILD │ ├── common.bzl │ ├── common_attributes.bzl │ ├── common_outputs.bzl │ ├── coverage_replacements_provider.bzl │ ├── dependency.bzl │ ├── macros │ │ └── scala_repositories.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_scalafmt.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 ├── providers.bzl ├── scala.bzl ├── scala_cross_version.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 │ │ └── ScalafmtRunner.scala │ └── scalafmt_repositories.bzl ├── scalatest │ └── BUILD ├── support │ ├── BUILD │ └── JUnitXmlReporter.scala ├── toolchains.bzl └── unstable │ ├── BUILD │ └── defs.bzl ├── scala_proto ├── BUILD ├── default_dep_sets.bzl ├── private │ ├── BUILD │ ├── proto_to_scala_src.bzl │ ├── scala_proto_default_repositories.bzl │ └── scalapb_aspect.bzl ├── scala_proto.bzl ├── scala_proto_toolchain.bzl └── toolchains.bzl ├── scripts └── ij.bazelproject ├── 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 │ │ ├── jar │ │ ├── BUILD │ │ ├── JarCreator.java │ │ └── JarHelper.java │ │ ├── scala_test │ │ ├── BUILD │ │ └── Runner.java │ │ ├── scalac │ │ ├── BUILD │ │ ├── CompileOptions.java │ │ ├── Resource.java │ │ ├── ScalaCInvoker.java │ │ ├── ScalacProcessor.java │ │ └── jvm_export_toolchain.bzl │ │ ├── specs2 │ │ ├── BUILD │ │ ├── Specs2RunnerBuilder.scala │ │ └── package.scala │ │ ├── test_discovery │ │ ├── BUILD │ │ ├── DiscoveredTestSuite.scala │ │ └── FilteredRunnerBuilder.scala │ │ └── worker │ │ ├── BUILD │ │ ├── GenericWorker.java │ │ └── Processor.java └── scala │ ├── io │ └── bazel │ │ └── rules_scala │ │ ├── jmh_support │ │ ├── BUILD │ │ └── BenchmarkGenerator.scala │ │ ├── scaladoc_support │ │ └── BUILD │ │ ├── scrooge_support │ │ ├── BUILD │ │ ├── Compiler.scala │ │ └── FocusedZipImporter.scala │ │ └── tut_support │ │ ├── BUILD │ │ └── TutCompiler.scala │ └── scripts │ ├── BUILD │ ├── PBGenerateRequest.scala │ ├── ScalaPBGenerator.scala │ └── TwitterScroogeGenerator.scala ├── test ├── A.scala ├── BUILD ├── 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 ├── ScalaTestData.scala ├── ScalaTestResourcesFromLocalTargetTest.scala ├── SuiteUsage.scala ├── TestFilterTestA.scala ├── TestFilterTestB.scala ├── TestServer.scala ├── UnusedLib.scala ├── aspect │ ├── BUILD │ ├── FakeJunitTest.scala │ └── aspect.bzl ├── check_statsfile.bzl ├── coverage │ ├── A1.scala │ ├── A2.scala │ ├── B1.scala │ ├── B2.java │ ├── BUILD │ ├── C2.scala │ ├── TestAll.scala │ ├── TestB2.java │ └── expected-coverage.dat ├── data │ ├── BUILD │ ├── foo.txt │ ├── more.txt │ └── some.txt ├── example_jars │ ├── BUILD │ ├── example_jar1.jar │ ├── example_jar2.jar │ └── expected_service_manifest.txt ├── fake_sig.jar ├── gen_src │ ├── BUILD │ └── SrcGenerator.scala ├── jar_lister.py ├── jmh │ ├── AddNumbers.scala │ ├── BUILD │ ├── JavaType.java │ ├── ScalaType.scala │ ├── TestBenchmark.scala │ └── data.txt ├── longnames │ └── looooooongnaaaaaaame │ │ └── anooooootherlooooooooongname │ │ └── anooooootherlooooooooongname2 │ │ └── anooooootherlooooooooongname3 │ │ └── LongNamesTest.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 │ ├── 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.bzl │ └── repo │ │ ├── BUILD.repo │ │ └── sample.proto ├── py_resource.py ├── scala_test │ ├── A.scala │ ├── B.scala │ └── BUILD ├── 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 ├── shell │ ├── test_build_event_protocol.sh │ ├── test_compilation.sh │ ├── test_deps.sh │ ├── test_helper.sh │ ├── test_javac_jvm_flags.sh │ ├── test_junit.sh │ ├── test_misc.sh │ ├── test_phase.sh │ ├── test_runner.sh │ ├── test_scala_binary.sh │ ├── test_scala_classpath.sh │ ├── test_scala_import_source_jar.sh │ ├── test_scala_jvm_flags.sh │ ├── test_scala_library.sh │ ├── test_scala_library_jar.sh │ ├── test_scala_specs2.sh │ ├── test_scalac_jvm_flags.sh │ ├── test_scalafmt.sh │ ├── test_toolchain.sh │ └── test_unused_dependency.sh ├── src │ └── main │ │ ├── resources │ │ └── scalarules │ │ │ └── test │ │ │ ├── BUILD │ │ │ ├── byes │ │ │ ├── classpath_resource1 │ │ │ ├── BUILD │ │ │ └── classpath-resource │ │ │ ├── classpath_resource2 │ │ │ ├── BUILD │ │ │ └── classpath-resource │ │ │ ├── hellos │ │ │ ├── hellos-and-byes.jar │ │ │ ├── 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 │ │ ├── extra_protobuf_generator │ │ ├── BUILD │ │ └── ExtraProtobufGenerator.scala │ │ ├── fetch_sources │ │ ├── BUILD │ │ └── FetchSources.scala │ │ ├── ijar │ │ ├── A.scala │ │ ├── B.scala │ │ ├── BUILD │ │ └── C.java │ │ ├── junit │ │ ├── FilterTest.scala │ │ ├── HelloWorldJunitTest.scala │ │ ├── JunitAbstractClassAndInterface.scala │ │ ├── JunitCustomRunner.java │ │ ├── JunitCustomRunnerTest.scala │ │ ├── JunitIncludesRunWith.scala │ │ ├── JunitIncludesTestHierarchies.scala │ │ ├── JunitInnerClass.scala │ │ ├── JunitJavaTest.java │ │ ├── JunitMultiplePrefixes.scala │ │ ├── JunitMultipleSuffixes.scala │ │ ├── JunitNoTests.scala │ │ ├── JunitTests.scala │ │ ├── scala.scala │ │ ├── separate_target │ │ │ ├── FailingTest.scala │ │ │ ├── JunitJavaSeparateTargetTest.java │ │ │ ├── JunitSeparateTargetTest.scala │ │ │ └── SomeScalaClass.scala │ │ ├── specs2 │ │ │ └── Specs2Tests.scala │ │ └── support │ │ │ ├── JUnitCompileTimeDep.scala │ │ │ └── JUnitRuntimeDep.scala │ │ ├── large_classpath │ │ ├── BUILD │ │ ├── ObjectWithLargeClasspath.scala │ │ └── helper.bzl │ │ ├── location_expansion │ │ └── LocationExpansionTest.scala │ │ ├── mix_java_scala │ │ ├── Bar.scala │ │ ├── Baz.java │ │ ├── Baz.srcjar │ │ └── FooBar.java │ │ ├── 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 │ │ ├── nl │ │ │ ├── BUILD.bazel │ │ │ ├── ScalaImportNeverLink.java │ │ │ ├── ScalaImportNeverLinkTest.scala │ │ │ └── scala_import_never_link.jar │ │ └── relate_2.11-2.1.1.jar │ │ ├── scripts │ │ ├── BUILD │ │ └── PBGenerateRequestTest.scala │ │ ├── sources_jars_in_deps │ │ ├── BUILD │ │ └── ReferCatsImplicits.scala │ │ ├── srcjars │ │ ├── BUILD │ │ ├── SourceJar1.scala │ │ ├── SourceJar1.srcjar │ │ └── SourceJar2.scala │ │ ├── srcjars_with_java │ │ ├── BUILD │ │ ├── JavaDependent.scala │ │ ├── JavaSource.java │ │ ├── JavaSourceJar.srcjar │ │ ├── MixedLanguageDependent.scala │ │ ├── MixedLanguageSourceJar.srcjar │ │ └── ScalaSource.scala │ │ ├── strict_deps │ │ └── no_recompilation │ │ │ ├── A.scala │ │ │ ├── B.scala │ │ │ ├── BUILD │ │ │ └── C.scala │ │ ├── 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-thrift.jar │ │ │ │ ├── bare_jar_1 │ │ │ │ │ ├── BUILD │ │ │ │ │ └── bare-thrift-1.jar │ │ │ │ └── bare_jar_2 │ │ │ │ │ ├── BUILD │ │ │ │ │ └── bare-thrift-2.jar │ │ │ └── thrift2 │ │ │ │ ├── BUILD │ │ │ │ ├── Thrift2_A.thrift │ │ │ │ ├── Thrift2_B.thrift │ │ │ │ ├── thrift3 │ │ │ │ ├── BUILD │ │ │ │ ├── Thrift3.thrift │ │ │ │ └── thrift3_scrooge.jar │ │ │ │ └── thrift4 │ │ │ │ ├── BUILD │ │ │ │ ├── Thrift4.thrift │ │ │ │ └── Thrift4a.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 ├── tut │ ├── BUILD │ ├── SomeExample.md │ └── TestDep.scala └── unstable │ ├── BUILD │ ├── binary.scala │ ├── library.scala │ └── test.scala ├── test_all.sh ├── test_expect_failure ├── compilers_javac_opts │ ├── BUILD │ └── WillNotCompileSinceJavaToolchainAddsAnInvalidJvmFlag.java ├── compilers_jvm_flags │ ├── BUILD │ ├── WillNotCompileJavaSinceXmxTooLow.java │ ├── WillNotCompileScalaSinceXmxTooLow.scala │ └── args.txt ├── 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 │ └── internal_deps │ │ ├── A.scala │ │ ├── B.scala │ │ ├── BUILD │ │ ├── C.scala │ │ ├── D.scala │ │ ├── HasCustomJavaProviderDependency.scala │ │ ├── JavaLibraryHasCustomJavaProviderDependency.java │ │ ├── Placeholder.java │ │ ├── User.java │ │ └── custom-jvm-rule.bzl ├── 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_jvm_flags │ ├── BUILD │ └── EmptyTest.scala ├── scalac_jvm_opts │ ├── BUILD │ └── Empty.scala ├── scalacopts_from_toolchain │ ├── BUILD │ └── ClassWithUnused.scala ├── 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 ├── test_intellij_aspect.sh ├── test_lint.sh ├── test_reproducibility.sh ├── test_rules_scala.sh ├── test_version.sh ├── test_version ├── WORKSPACE.template └── 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 │ │ └── 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-thrift.jar │ │ ├── bare_jar_1 │ │ │ ├── BUILD │ │ │ └── bare-thrift-1.jar │ │ └── bare_jar_2 │ │ │ ├── BUILD │ │ │ └── bare-thrift-2.jar │ │ └── thrift2 │ │ ├── BUILD │ │ ├── Thrift2_A.thrift │ │ ├── Thrift2_B.thrift │ │ ├── thrift3 │ │ ├── BUILD │ │ ├── Thrift3.thrift │ │ └── thrift3_scrooge.jar │ │ └── thrift4 │ │ ├── BUILD │ │ ├── Thrift4.thrift │ │ └── Thrift4a.thrift │ ├── test_binary.sh │ └── tut │ ├── BUILD │ ├── SomeExample.md │ └── TestDep.scala ├── third_party ├── README.md ├── bazel │ └── src │ │ └── main │ │ └── protobuf │ │ ├── BUILD │ │ └── worker_protocol.proto ├── dependency_analyzer │ ├── LICENSE │ └── src │ │ ├── main │ │ ├── BUILD │ │ ├── io │ │ │ └── bazel │ │ │ │ └── rulesscala │ │ │ │ └── dependencyanalyzer │ │ │ │ ├── AstUsedJarFinder.scala │ │ │ │ ├── DependencyAnalyzer.scala │ │ │ │ ├── DependencyAnalyzerSettings.scala │ │ │ │ ├── HighLevelCrawlUsedJarFinder.scala │ │ │ │ ├── OptionsParser.scala │ │ │ │ └── ScalaVersion.scala │ │ └── resources │ │ │ └── scalac-plugin.xml │ │ └── test │ │ ├── BUILD │ │ └── io │ │ └── bazel │ │ └── rulesscala │ │ └── dependencyanalyzer │ │ ├── AstUsedJarFinderTest.scala │ │ ├── ScalaVersionTest.scala │ │ ├── ScalacDependencyTest.scala │ │ ├── StrictDepsTest.scala │ │ └── UnusedDependencyCheckerTest.scala ├── test │ ├── new_local_repo │ │ └── resource.txt │ └── strip_resource_external_workspace │ │ ├── WORKSPACE │ │ └── strip │ │ ├── BUILD.bazel │ │ └── nosrc_jar_resource.txt └── utils │ ├── LICENSE │ └── src │ └── test │ ├── BUILD │ └── io │ └── bazel │ └── rulesscala │ └── utils │ ├── JavaCompileUtil.scala │ └── TestUtil.scala ├── thrift ├── BUILD ├── thrift.bzl └── thrift_info.bzl ├── tools ├── BUILD ├── bazel └── bazel.rc.buildkite ├── tut_rule ├── BUILD └── tut.bzl └── twitter_scrooge ├── BUILD └── twitter_scrooge.bzl /.bazelci/presubmit.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platforms: 3 | ubuntu1604: 4 | shell_commands: 5 | # Disable local disk caching on CI. 6 | - mv tools/bazel.rc.buildkite tools/bazel.rc 7 | - echo "import %workspace%/tools/bazel.rc" > .bazelrc 8 | build_targets: 9 | - "//test/..." 10 | test_targets: 11 | - "//test/..." 12 | ubuntu1804: 13 | shell_commands: 14 | # Disable local disk caching on CI. 15 | - mv tools/bazel.rc.buildkite tools/bazel.rc 16 | - echo "import %workspace%/tools/bazel.rc" > .bazelrc 17 | build_targets: 18 | - "//test/..." 19 | test_targets: 20 | - "//test/..." 21 | macos: 22 | shell_commands: 23 | # Disable local disk caching on CI. 24 | - mv tools/bazel.rc.buildkite tools/bazel.rc 25 | - echo "import %workspace%/tools/bazel.rc" > .bazelrc 26 | build_targets: 27 | - "//test/..." 28 | test_targets: 29 | - "//test/..." 30 | rbe_ubuntu1604: 31 | build_targets: 32 | - "//test/..." 33 | test_targets: 34 | - "//test/..." 35 | -------------------------------------------------------------------------------- /.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 | .metals 10 | unformatted-*.backup.scala 11 | -------------------------------------------------------------------------------- /.scalafmt.conf: -------------------------------------------------------------------------------- 1 | align.openParenCallSite = false 2 | align.openParenDefnSite = false 3 | continuationIndent.defnSite = 2 4 | danglingParentheses = true 5 | docstrings = JavaDoc 6 | importSelectors = singleLine 7 | maxColumn = 120 8 | verticalMultiline.newlineBeforeImplicitKW = true 9 | rewrite.redundantBraces.stringInterpolation = true 10 | rewrite.rules = [ 11 | RedundantParens, 12 | PreferCurlyFors, 13 | SortImports 14 | ] 15 | unindentTopLevelOperators = false 16 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/BUILD -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @ittaiz @dinowernil 2 | -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # People who have agreed to one of the CLAs and can contribute patches. 2 | # The AUTHORS file lists the copyright holders; this file 3 | # lists people. For example, Google employees are listed here 4 | # but not in AUTHORS, because Google holds the copyright. 5 | # 6 | # https://developers.google.com/open-source/cla/individual 7 | # https://developers.google.com/open-source/cla/corporate 8 | # 9 | # Names should be added to this file as: 10 | # Name 11 | 12 | Alex Humesky 13 | Damien Martin-Guillerez 14 | David Chen 15 | Dino Wernli 16 | Ian O'Connell 17 | John Sullivan 18 | Laurent Le Brun 19 | Nathan Harmata 20 | Oscar Boykin 21 | Justine Alexandra Roberts Tunney 22 | Natan Silnitsky 23 | Nadav Wexler 24 | -------------------------------------------------------------------------------- /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. -------------------------------------------------------------------------------- /docs/scala_repl.md: -------------------------------------------------------------------------------- 1 | # scala_repl 2 | 3 | ```python 4 | scala_repl( 5 | name, 6 | deps, 7 | scalacopts, 8 | jvm_flags, 9 | scalac_jvm_flags, 10 | javac_jvm_flags, 11 | unused_dependency_checker_mode 12 | ) 13 | ``` 14 | 15 | `scala_repl` allows you to add library dependencies (but not currently `scala_binary` targets) 16 | and then generate a _script_ which starts a REPL. 17 | 18 | Since `bazel run` closes stdin, it cannot be used to start a REPL. 19 | Instead, use `bazel build` to build the script, then run that script as normal to start a REPL session. 20 | 21 | An example in this repo: 22 | ``` 23 | bazel build test:HelloLibRepl 24 | bazel-bin/test/HelloLibRepl 25 | ``` -------------------------------------------------------------------------------- /docs/scala_test.md: -------------------------------------------------------------------------------- 1 | # scala_test 2 | 3 | ```python 4 | scala_test( 5 | name, 6 | srcs, 7 | suites, 8 | deps, 9 | data, 10 | main_class, 11 | resources, 12 | resource_strip_prefix, 13 | scalacopts, 14 | jvm_flags, 15 | scalac_jvm_flags, 16 | javac_jvm_flags, 17 | unused_dependency_checker_mode 18 | ) 19 | ``` 20 | 21 | `scala_test` generates a Scala executable which runs unit test suites written 22 | using the `scalatest` library. It may depend on `scala_library`, 23 | `scala_macro_library` and `java_library` rules. 24 | 25 | By default, `scala_test` runs _all_ tests in a given target. 26 | For backwards compatibility, it accepts a `suites` attribute which 27 | is ignored due to the ease with which that field is not correctly 28 | populated and tests are not run. -------------------------------------------------------------------------------- /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. -------------------------------------------------------------------------------- /java_stub_template/file/BUILD.bazel: -------------------------------------------------------------------------------- 1 | filegroup( 2 | name = "file", 3 | srcs = ["file.txt"], 4 | visibility = ["//visibility:public"], 5 | ) 6 | -------------------------------------------------------------------------------- /jmh/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/jmh/BUILD -------------------------------------------------------------------------------- /junit/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/junit/BUILD -------------------------------------------------------------------------------- /lint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eou pipefail 4 | 5 | ./tools/bazel run //tools:buildifier@fix 6 | -------------------------------------------------------------------------------- /manual_test/README.md: -------------------------------------------------------------------------------- 1 | This directory contains tests that require extra setup such as extra bazel flags. -------------------------------------------------------------------------------- /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 FunSuite { 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 | -------------------------------------------------------------------------------- /private/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_binary") 2 | 3 | java_binary( 4 | name = "java_format", 5 | main_class = "com.google.googlejavaformat.java.Main", 6 | runtime_deps = ["@google_java_format"], 7 | ) 8 | -------------------------------------------------------------------------------- /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/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/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/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 | } 9 | -------------------------------------------------------------------------------- /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_exports_jars.bzl: -------------------------------------------------------------------------------- 1 | # 2 | # PHASE: collect exports jars 3 | # 4 | # DOCUMENT THIS 5 | # 6 | load( 7 | "@io_bazel_rules_scala//scala/private:common.bzl", 8 | "collect_jars", 9 | ) 10 | 11 | def phase_collect_exports_jars(ctx, p): 12 | # Add information from exports (is key that AFTER all build actions/runfiles analysis) 13 | # Since after, will not show up in deploy_jar or old jars runfiles 14 | # Notice that compile_jars is intentionally transitive for exports 15 | return collect_jars( 16 | ctx.attr.exports, 17 | "direct", 18 | False, 19 | False, 20 | ) 21 | -------------------------------------------------------------------------------- /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( 7 | "@io_bazel_rules_scala//scala/private:rule_impls.bzl", 8 | "is_windows", 9 | ) 10 | 11 | def phase_declare_executable(ctx, p): 12 | if (is_windows(ctx)): 13 | return struct( 14 | executable = ctx.actions.declare_file("%s.exe" % ctx.label.name), 15 | ) 16 | else: 17 | return struct( 18 | executable = ctx.actions.declare_file(ctx.label.name), 19 | ) 20 | -------------------------------------------------------------------------------- /scala/private/phases/phase_scalac_provider.bzl: -------------------------------------------------------------------------------- 1 | # 2 | # PHASE: scalac provider 3 | # 4 | # DOCUMENT THIS 5 | # 6 | load( 7 | "@io_bazel_rules_scala//scala:providers.bzl", 8 | _ScalacProvider = "ScalacProvider", 9 | ) 10 | 11 | def phase_scalac_provider(ctx, p): 12 | return ctx.toolchains["@io_bazel_rules_scala//scala:toolchain_type"].scalac_provider_attr[_ScalacProvider] 13 | -------------------------------------------------------------------------------- /scala/private/phases/phase_write_manifest.bzl: -------------------------------------------------------------------------------- 1 | # 2 | # PHASE: write manifest 3 | # 4 | # DOCUMENT THIS 5 | # 6 | load( 7 | "@io_bazel_rules_scala//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/providers.bzl: -------------------------------------------------------------------------------- 1 | ScalacProvider = provider( 2 | doc = "ScalacProvider", 3 | fields = [ 4 | "default_classpath", 5 | "default_macro_classpath", 6 | "default_repl_classpath", 7 | ], 8 | ) 9 | 10 | def _declare_scalac_provider(ctx): 11 | return [ 12 | ScalacProvider( 13 | default_classpath = ctx.attr.default_classpath, 14 | default_repl_classpath = ctx.attr.default_repl_classpath, 15 | default_macro_classpath = ctx.attr.default_macro_classpath, 16 | ), 17 | ] 18 | 19 | declare_scalac_provider = rule( 20 | implementation = _declare_scalac_provider, 21 | attrs = { 22 | "default_classpath": attr.label_list(allow_files = True), 23 | "default_repl_classpath": attr.label_list(allow_files = True), 24 | "default_macro_classpath": attr.label_list(allow_files = True), 25 | }, 26 | ) 27 | -------------------------------------------------------------------------------- /scala/scalafmt/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_binary") 2 | 3 | filegroup( 4 | name = "runner", 5 | srcs = ["private/format.template.sh"], 6 | visibility = ["//visibility:public"], 7 | ) 8 | 9 | filegroup( 10 | name = "testrunner", 11 | srcs = ["private/format-test.template.sh"], 12 | visibility = ["//visibility:public"], 13 | ) 14 | 15 | scala_binary( 16 | name = "scalafmt", 17 | srcs = ["scalafmt/ScalafmtRunner.scala"], 18 | main_class = "io.bazel.rules_scala.scalafmt.ScalafmtRunner", 19 | visibility = ["//visibility:public"], 20 | deps = [ 21 | "//src/java/io/bazel/rulesscala/worker", 22 | "@com_geirsson_metaconfig_core", 23 | "@org_scalameta_parsers", 24 | "@org_scalameta_scalafmt_core", 25 | ], 26 | ) 27 | 28 | load( 29 | "//scala/scalafmt:phase_scalafmt_ext.bzl", 30 | "scalafmt_singleton", 31 | ) 32 | 33 | scalafmt_singleton( 34 | name = "phase_scalafmt", 35 | visibility = ["//visibility:public"], 36 | ) 37 | -------------------------------------------------------------------------------- /scala/scalafmt/private/format-test.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 | EXIT=0 8 | while read original formatted; do 9 | if [[ ! -z "$original" ]] && [[ ! -z "$formatted" ]]; then 10 | if ! cmp -s "$WORKSPACE_ROOT/$original" "$RUNPATH/$formatted"; then 11 | echo $original 12 | diff "$WORKSPACE_ROOT/$original" "$RUNPATH/$formatted" || true 13 | EXIT=1 14 | fi 15 | fi 16 | done < "$RUNPATH"/%manifest% 17 | 18 | exit $EXIT 19 | -------------------------------------------------------------------------------- /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/scalatest/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | load("//scala:scala_import.bzl", "scala_import") 4 | 5 | scala_import( 6 | name = "scalatest", 7 | jars = [], 8 | exports = [ 9 | "//external:io_bazel_rules_scala/dependency/scala/scalactic/scalactic", 10 | "//external:io_bazel_rules_scala/dependency/scala/scalatest/scalatest", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /scala/support/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "test_reporter", 5 | srcs = ["JUnitXmlReporter.scala"], 6 | scalacopts = [ 7 | "-deprecation:true", 8 | "-encoding", 9 | "UTF-8", 10 | "-feature", 11 | "-language:existentials", 12 | "-language:higherKinds", 13 | "-language:implicitConversions", 14 | "-unchecked", 15 | "-Xfatal-warnings", 16 | "-Xlint", 17 | "-Yno-adapted-args", 18 | "-Ywarn-dead-code", 19 | "-Ywarn-numeric-widen", 20 | "-Ywarn-value-discard", 21 | "-Xfuture", 22 | "-Ywarn-unused-import", 23 | "-Ypartial-unification", 24 | ], 25 | visibility = ["//visibility:public"], 26 | deps = [ 27 | "//external:io_bazel_rules_scala/dependency/scala/scala_xml", 28 | "//external:io_bazel_rules_scala/dependency/scalatest/scalatest", 29 | ], 30 | ) 31 | -------------------------------------------------------------------------------- /scala/toolchains.bzl: -------------------------------------------------------------------------------- 1 | def scala_register_toolchains(): 2 | native.register_toolchains("@io_bazel_rules_scala//scala:default_toolchain") 3 | 4 | def scala_register_unused_deps_toolchains(): 5 | native.register_toolchains( 6 | "@io_bazel_rules_scala//scala:unused_dependency_checker_error_toolchain", 7 | ) 8 | -------------------------------------------------------------------------------- /scala/unstable/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/scala/unstable/BUILD -------------------------------------------------------------------------------- /scala_proto/private/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/scala_proto/private/BUILD -------------------------------------------------------------------------------- /scala_proto/toolchains.bzl: -------------------------------------------------------------------------------- 1 | def scala_proto_register_toolchains(): 2 | native.register_toolchains("@io_bazel_rules_scala//scala_proto:default_toolchain") 3 | 4 | def scala_proto_register_enable_all_options_toolchain(): 5 | native.register_toolchains("@io_bazel_rules_scala//scala_proto:enable_all_options_toolchain") 6 | -------------------------------------------------------------------------------- /scripts/ij.bazelproject: -------------------------------------------------------------------------------- 1 | # Setup IntelliJ for Bazel development using the IntelliJ Bazel Plugin. 2 | # See https://github.com/bazelbuild/intellij for installation instructions. 3 | # test_expect_failure and test/twitter_scrooge are not included in the targets section as they are known to have failures 4 | 5 | directories: 6 | . 7 | 8 | targets: 9 | //test/... 10 | -test/src/main/scala/scalarules/test/twitter_scrooge/... 11 | //jmh/... 12 | //junit/... 13 | //third_party/... 14 | //scala/... 15 | //specs2/... 16 | //src/... 17 | //thrift/... 18 | //tut_rule/... 19 | //twitter_scrooge/... 20 | 21 | additional_languages: 22 | scala 23 | 24 | bazel_binary: /usr/local/bin/bazel 25 | -------------------------------------------------------------------------------- /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 | "@io_bazel_rules_scala_org_specs2_specs2_common", 10 | "@io_bazel_rules_scala_org_specs2_specs2_core", 11 | "@io_bazel_rules_scala_org_specs2_specs2_fp", 12 | "@io_bazel_rules_scala_org_specs2_specs2_matcher", 13 | ], 14 | deps = [ 15 | "//external:io_bazel_rules_scala/dependency/scala/parser_combinators", 16 | "//external:io_bazel_rules_scala/dependency/scala/scala_library", 17 | "//external:io_bazel_rules_scala/dependency/scala/scala_reflect", 18 | "//external:io_bazel_rules_scala/dependency/scala/scala_xml", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /src/java/io/bazel/rulesscala/coverage/instrumenter/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_binary") 2 | 3 | java_binary( 4 | name = "instrumenter", 5 | srcs = [ 6 | "@io_bazel_rules_scala//src/java/io/bazel/rulesscala/coverage/instrumenter:instrumenter_files", 7 | ], 8 | javacopts = [ 9 | "-source 1.8", 10 | "-target 1.8", 11 | ], 12 | main_class = "io.bazel.rulesscala.coverage.instrumenter.JacocoInstrumenter", 13 | visibility = ["//visibility:public"], 14 | deps = [ 15 | "//third_party/bazel/src/main/protobuf:worker_protocol_java_proto", 16 | "@bazel_tools//tools/jdk:JacocoCoverage", 17 | "@io_bazel_rules_scala//src/java/io/bazel/rulesscala/jar", 18 | "@io_bazel_rules_scala//src/java/io/bazel/rulesscala/worker", 19 | ], 20 | ) 21 | 22 | filegroup( 23 | name = "instrumenter_files", 24 | srcs = [ 25 | "JacocoInstrumenter.java", 26 | ], 27 | visibility = ["//visibility:public"], 28 | ) 29 | -------------------------------------------------------------------------------- /src/java/io/bazel/rulesscala/exe/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_binary", "java_library") 2 | 3 | java_library( 4 | name = "exe-lib", 5 | srcs = [ 6 | "LaunchInfo.java", 7 | "LauncherFileWriter.java", 8 | ], 9 | visibility = ["//visibility:private"], 10 | deps = [ 11 | "//external:io_bazel_rules_scala/dependency/scala/guava", 12 | "@bazel_tools//tools/java/runfiles", 13 | ], 14 | ) 15 | 16 | java_binary( 17 | name = "exe", 18 | data = [ 19 | "@bazel_tools//tools/launcher", 20 | ], 21 | main_class = "io.bazel.rulesscala.exe.LauncherFileWriter", 22 | visibility = ["//visibility:public"], 23 | runtime_deps = [ 24 | ":exe-lib", 25 | ], 26 | ) 27 | -------------------------------------------------------------------------------- /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/io_utils/DeleteRecursively.java: -------------------------------------------------------------------------------- 1 | package io.bazel.rulesscala.io_utils; 2 | 3 | import java.io.IOException; 4 | import java.nio.file.*; 5 | import java.nio.file.attribute.BasicFileAttributes; 6 | 7 | public class DeleteRecursively { 8 | public static void run(Path path) throws IOException { 9 | Files.walkFileTree( 10 | path, 11 | new SimpleFileVisitor() { 12 | @Override 13 | public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) 14 | throws IOException { 15 | Files.delete(file); 16 | return FileVisitResult.CONTINUE; 17 | } 18 | 19 | @Override 20 | public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { 21 | Files.delete(dir); 22 | return FileVisitResult.CONTINUE; 23 | } 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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/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 | "//external:io_bazel_rules_scala/dependency/scalatest/scalatest", 9 | "@bazel_tools//tools/java/runfiles", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /src/java/io/bazel/rulesscala/scalac/Resource.java: -------------------------------------------------------------------------------- 1 | package io.bazel.rulesscala.scalac; 2 | 3 | public class Resource { 4 | public final String target; 5 | public final String source; 6 | 7 | public Resource(String target, String source) { 8 | this.target = target; 9 | this.source = source; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/java/io/bazel/rulesscala/scalac/jvm_export_toolchain.bzl: -------------------------------------------------------------------------------- 1 | load( 2 | "@io_bazel_rules_scala//scala:providers.bzl", 3 | _ScalacProvider = "ScalacProvider", 4 | ) 5 | 6 | def _files_of(deps): 7 | files = [] 8 | for dep in deps: 9 | files.append(dep[JavaInfo].transitive_compile_time_jars) 10 | return depset(transitive = files) 11 | 12 | def _export_scalac_repositories_from_toolchain_to_jvm_impl(ctx): 13 | default_repl_classpath_deps = ctx.toolchains["@io_bazel_rules_scala//scala:toolchain_type"].scalac_provider_attr[_ScalacProvider].default_repl_classpath 14 | default_repl_classpath_files = _files_of( 15 | default_repl_classpath_deps, 16 | ).to_list() 17 | providers = [JavaInfo(output_jar = jar, compile_jar = jar) for jar in default_repl_classpath_files] 18 | return [java_common.merge(providers)] 19 | 20 | export_scalac_repositories_from_toolchain_to_jvm = rule( 21 | _export_scalac_repositories_from_toolchain_to_jvm_impl, 22 | toolchains = ["@io_bazel_rules_scala//scala:toolchain_type"], 23 | ) 24 | -------------------------------------------------------------------------------- /src/java/io/bazel/rulesscala/specs2/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | load("//specs2:specs2_junit.bzl", "specs2_junit_dependencies", "specs2_junit_repositories") 3 | 4 | scala_library( 5 | name = "specs2_test_discovery", 6 | srcs = [ 7 | "Specs2RunnerBuilder.scala", 8 | "package.scala", 9 | ], 10 | visibility = ["//visibility:public"], 11 | deps = [ 12 | "//external:io_bazel_rules_scala/dependency/junit/junit", 13 | "//external:io_bazel_rules_scala/dependency/scala/scala_xml", 14 | "//external:io_bazel_rules_scala/dependency/specs2/specs2", 15 | "//external:io_bazel_rules_scala/dependency/specs2/specs2_junit", 16 | "//src/java/io/bazel/rulesscala/test_discovery", 17 | ], 18 | ) 19 | -------------------------------------------------------------------------------- /src/java/io/bazel/rulesscala/specs2/package.scala: -------------------------------------------------------------------------------- 1 | package io.bazel.rulesscala 2 | 3 | import org.junit.runner.Description 4 | import org.specs2.concurrent.ExecutionEnv 5 | import org.specs2.fp.TreeLoc 6 | import org.specs2.reporter.JUnitDescriptions 7 | import org.specs2.specification.core.{Fragment, SpecStructure} 8 | 9 | package object specs2 { 10 | type specs2_v4 = { 11 | //noinspection ScalaUnusedSymbol 12 | def createDescriptionTree(spec: SpecStructure)(ee: ExecutionEnv): TreeLoc[(Fragment, Description)] 13 | } 14 | type specs2_v3 = { 15 | //noinspection ScalaUnusedSymbol 16 | def createDescriptionTree(spec: SpecStructure): TreeLoc[(Fragment, Description)] 17 | } 18 | 19 | def allDescriptions[T]: T = JUnitDescriptions.asInstanceOf[T] 20 | } -------------------------------------------------------------------------------- /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 | "DiscoveredTestSuite.scala", 7 | "FilteredRunnerBuilder.scala", 8 | ], 9 | visibility = ["//visibility:public"], 10 | deps = ["//external:io_bazel_rules_scala/dependency/junit/junit"], 11 | ) 12 | -------------------------------------------------------------------------------- /src/java/io/bazel/rulesscala/worker/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_library") 2 | 3 | java_library( 4 | name = "worker", 5 | srcs = [ 6 | "GenericWorker.java", 7 | "Processor.java", 8 | ], 9 | visibility = ["//visibility:public"], 10 | deps = [ 11 | "//third_party/bazel/src/main/protobuf:worker_protocol_java_proto", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /src/java/io/bazel/rulesscala/worker/Processor.java: -------------------------------------------------------------------------------- 1 | package io.bazel.rulesscala.worker; 2 | 3 | import java.util.List; 4 | 5 | public interface Processor { 6 | void processRequest(List args) throws Exception; 7 | } 8 | -------------------------------------------------------------------------------- /src/scala/io/bazel/rules_scala/jmh_support/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_binary", "scala_library") 2 | 3 | scala_library( 4 | name = "benchmark_generator_lib", 5 | srcs = ["BenchmarkGenerator.scala"], 6 | visibility = ["//visibility:public"], 7 | runtime_deps = [ 8 | "//external:io_bazel_rules_scala/dependency/jmh/org_ows2_asm_asm", 9 | ], 10 | deps = [ 11 | "//external:io_bazel_rules_scala/dependency/jmh/jmh_core", 12 | "//external:io_bazel_rules_scala/dependency/jmh/jmh_generator_asm", 13 | "//external:io_bazel_rules_scala/dependency/jmh/jmh_generator_reflection", 14 | "//src/java/io/bazel/rulesscala/jar", 15 | ], 16 | ) 17 | 18 | scala_binary( 19 | name = "benchmark_generator", 20 | main_class = "io.bazel.rules_scala.jmh_support.BenchmarkGenerator", 21 | visibility = ["//visibility:public"], 22 | deps = [":benchmark_generator_lib"], 23 | ) 24 | -------------------------------------------------------------------------------- /src/scala/io/bazel/rules_scala/scaladoc_support/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_binary") 2 | 3 | # A simple scala_binary to run scaladoc. 4 | # `bazel run` this target with "-help" as a param for usage text: 5 | # bazel run -- "//src/scala/io/bazel/rules_scala/scaladoc_support:scaladoc_generator" -help 6 | scala_binary( 7 | name = "scaladoc_generator", 8 | main_class = "scala.tools.nsc.ScalaDoc", 9 | visibility = ["//visibility:public"], 10 | runtime_deps = [ 11 | "//external:io_bazel_rules_scala/dependency/scala/parser_combinators", 12 | "//external:io_bazel_rules_scala/dependency/scala/scala_compiler", 13 | "//external:io_bazel_rules_scala/dependency/scala/scala_library", 14 | "//external:io_bazel_rules_scala/dependency/scala/scala_reflect", 15 | "//external:io_bazel_rules_scala/dependency/scala/scala_xml", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /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 = ["Compiler.scala"], 6 | # util_core is still needed as a dep for older versions of scrooge 7 | unused_dependency_checker_mode = "off", 8 | visibility = ["//visibility:public"], 9 | deps = [ 10 | ":focused_zip_importer", 11 | "//external:io_bazel_rules_scala/dependency/scala/parser_combinators", 12 | "//external:io_bazel_rules_scala/dependency/thrift/scrooge_generator", 13 | "//external:io_bazel_rules_scala/dependency/thrift/util_core", 14 | "//external:io_bazel_rules_scala/dependency/thrift/util_logging", 15 | ], 16 | ) 17 | 18 | scala_library( 19 | name = "focused_zip_importer", 20 | srcs = ["FocusedZipImporter.scala"], 21 | visibility = ["//visibility:public"], 22 | deps = [ 23 | "//external:io_bazel_rules_scala/dependency/thrift/scrooge_generator", 24 | ], 25 | ) 26 | -------------------------------------------------------------------------------- /src/scala/io/bazel/rules_scala/tut_support/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_binary", "scala_library") 2 | 3 | scala_library( 4 | name = "tut_compiler_lib", 5 | srcs = ["TutCompiler.scala"], 6 | visibility = ["//visibility:public"], 7 | deps = [ 8 | "//external:io_bazel_rules_scala/dependency/scala/scala_compiler", 9 | "//external:io_bazel_rules_scala/dependency/tut/tut_core", 10 | "//src/java/io/bazel/rulesscala/io_utils", 11 | ], 12 | ) 13 | 14 | scala_binary( 15 | name = "tut_compiler", 16 | main_class = "io.bazel.rules_scala.tut_support.TutCompiler", 17 | visibility = ["//visibility:public"], 18 | deps = [":tut_compiler_lib"], 19 | ) 20 | -------------------------------------------------------------------------------- /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/JavaBinary.java: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package scalarules.test; 16 | 17 | /** Example class */ 18 | public class JavaBinary { 19 | public static void main(String[] args) { 20 | HelloLib.printMessage("Hello"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /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.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/OtherJavaLib.java: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package scalarules.test; 16 | 17 | /** Example class */ 18 | public class OtherJavaLib { 19 | public static String getMessage() { 20 | return "java!"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/OtherLib.scala: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package scalarules.test 16 | 17 | // It is just to show how a Scala library can depend on another Scala library. 18 | object OtherLib { 19 | def getMessage(): String = Exported.message 20 | } 21 | -------------------------------------------------------------------------------- /test/Runtime.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | class Runtime { 4 | override def toString = "I am Runtime" 5 | } 6 | -------------------------------------------------------------------------------- /test/ScalaBinary.scala: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package scalarules.test 16 | 17 | object ScalaBinary { 18 | def main(args: Array[String]) { 19 | println(MacroTest.hello(1 + 2)) 20 | HelloLib.printMessage("Hello"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/ScalaTestData.scala: -------------------------------------------------------------------------------- 1 | import java.io.File 2 | import org.scalatest.FlatSpec 3 | import scala.io.Source 4 | 5 | class RunfileSpec extends FlatSpec { 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/ScalaTestResourcesFromLocalTargetTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test 2 | 3 | class ScalaTestResourcesFromLocalTargetTest extends org.scalatest.FlatSpec { 4 | "scala_test's resources when referencing local target" should 5 | "assert that local target is not placed in bazel-out, but rather next to the packaged code" in { 6 | assert(getClass.getResource("/bazel-out/darwin-fastbuild/bin/test/py_resource_binary") == null) 7 | assert(getClass.getResource("/test/py_resource_binary") != null) 8 | } 9 | } -------------------------------------------------------------------------------- /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 4 | 5 | class TestFilterTestA extends FunSpec { 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 4 | 5 | class TestFilterTestB extends FunSpec { 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/BUILD: -------------------------------------------------------------------------------- 1 | load(":aspect.bzl", "aspect_test") 2 | load( 3 | "//scala:scala.bzl", 4 | "scala_junit_test", 5 | "scala_library", 6 | "scala_specs2_junit_test", 7 | "scala_test", 8 | ) 9 | 10 | aspect_test( 11 | name = "aspect_test", 12 | targets = [ 13 | ":scala_library", 14 | ":scala_test", 15 | ":scala_junit_test", 16 | ":scala_specs2_junit_test", 17 | ], 18 | ) 19 | 20 | scala_library(name = "scala_library") 21 | 22 | scala_test(name = "scala_test") 23 | 24 | scala_junit_test( 25 | name = "scala_junit_test", 26 | srcs = ["FakeJunitTest.scala"], 27 | suffixes = ["Test"], 28 | ) 29 | 30 | scala_specs2_junit_test( 31 | name = "scala_specs2_junit_test", 32 | srcs = ["FakeJunitTest.scala"], 33 | suffixes = ["Test"], 34 | ) 35 | -------------------------------------------------------------------------------- /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/check_statsfile.bzl: -------------------------------------------------------------------------------- 1 | def check_statsfile(target): 2 | statsfile = ":%s.statsfile" % target 3 | outfile = "%s.statsfile.good" % target 4 | 5 | cmd = """ 6 | TIME_MS=`awk -F '=' '$$1 == "build_time" {{ print $$2 }}' {statsfile}` 7 | if [ ! -z "$$TIME_MS" ]; then 8 | touch '{outfile}' 9 | fi 10 | """ 11 | cmd = cmd.format( 12 | statsfile = "$(location %s)" % statsfile, 13 | outfile = "$(location %s)" % outfile, 14 | ) 15 | 16 | native.genrule( 17 | name = "%s_statsfile" % target, 18 | outs = [outfile], 19 | tools = [statsfile], 20 | cmd = cmd, 21 | visibility = ["//visibility:public"], 22 | ) 23 | -------------------------------------------------------------------------------- /test/coverage/A1.scala: -------------------------------------------------------------------------------- 1 | package coverage; 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/A2.scala: -------------------------------------------------------------------------------- 1 | package coverage; 2 | 3 | object A2 { 4 | def a2(): Unit = { 5 | println("a2: " + B2.b2_a() 6 | ) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/coverage/B1.scala: -------------------------------------------------------------------------------- 1 | package coverage; 2 | 3 | object B1 { 4 | 5 | def not_called(): Unit = { 6 | println("hello world") 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/coverage/B2.java: -------------------------------------------------------------------------------- 1 | package coverage; 2 | 3 | class B2 { 4 | public static String b2_a() { 5 | return C2.c2("hello from b2_a"); 6 | } 7 | 8 | public static void b2_b() { 9 | System.out.println("this is b2_b"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/coverage/C2.scala: -------------------------------------------------------------------------------- 1 | package coverage; 2 | 3 | object C2 { 4 | def c2(input: String): String = 5 | input.reverse 6 | 7 | } 8 | -------------------------------------------------------------------------------- /test/coverage/TestAll.scala: -------------------------------------------------------------------------------- 1 | package coverage; 2 | import org.scalatest._ 3 | 4 | class TestAll extends FlatSpec { 5 | 6 | "testA1" should "work" in { 7 | assert(A1.a1(true) == B1) 8 | } 9 | 10 | "testA2" should "work" in { 11 | A2.a2() 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/coverage/TestB2.java: -------------------------------------------------------------------------------- 1 | package coverage; 2 | 3 | import org.junit.Test; 4 | import org.junit.Assert.*; 5 | 6 | public class TestB2 { 7 | 8 | @Test 9 | public void testB2() { 10 | B2.b2_b(); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /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/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_import") 2 | 3 | java_import( 4 | name = "example_jar1", 5 | jars = [ 6 | "example_jar1.jar", 7 | ], 8 | visibility = ["//visibility:public"], 9 | ) 10 | 11 | java_import( 12 | name = "example_jar2", 13 | jars = [ 14 | "example_jar2.jar", 15 | ], 16 | visibility = ["//visibility:public"], 17 | ) 18 | -------------------------------------------------------------------------------- /test/example_jars/example_jar1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/test/example_jars/example_jar1.jar -------------------------------------------------------------------------------- /test/example_jars/example_jar2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/test/example_jars/example_jar2.jar -------------------------------------------------------------------------------- /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/fake_sig.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/test/fake_sig.jar -------------------------------------------------------------------------------- /test/gen_src/BUILD: -------------------------------------------------------------------------------- 1 | load( 2 | "//scala:scala.bzl", 3 | "scala_binary", 4 | "scala_library", 5 | ) 6 | 7 | scala_binary( 8 | name = "src_generator", 9 | srcs = ["SrcGenerator.scala"], 10 | main_class = "build.bazel.rulesscala.test.srcgen.SrcGenerator", 11 | ) 12 | 13 | genrule( 14 | name = "foo", 15 | srcs = [], 16 | outs = ["foo.scala"], 17 | cmd = "./$(location src_generator) hello foo > \"$@\"", 18 | tools = ["src_generator"], 19 | ) 20 | 21 | scala_binary( 22 | name = "uses_gen_file", 23 | srcs = ["foo.scala"], 24 | main_class = "Foo", 25 | ) 26 | -------------------------------------------------------------------------------- /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/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_library") 2 | load("//scala:scala.bzl", "scala_library") 3 | load("//jmh:jmh.bzl", "scala_benchmark_jmh") 4 | 5 | java_library( 6 | name = "java_type", 7 | srcs = ["JavaType.java"], 8 | visibility = ["//visibility:public"], 9 | ) 10 | 11 | scala_library( 12 | name = "scala_type", 13 | srcs = ["ScalaType.scala"], 14 | visibility = ["//visibility:public"], 15 | ) 16 | 17 | scala_library( 18 | name = "add_numbers", 19 | srcs = ["AddNumbers.scala"], 20 | visibility = ["//visibility:public"], 21 | exports = [ 22 | ":java_type", 23 | ":scala_type", 24 | ], 25 | deps = [ 26 | ":java_type", 27 | ":scala_type", 28 | ], 29 | ) 30 | 31 | scala_benchmark_jmh( 32 | name = "test_benchmark", 33 | srcs = ["TestBenchmark.scala"], 34 | data = ["data.txt"], 35 | deps = [":add_numbers"], 36 | ) 37 | -------------------------------------------------------------------------------- /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/longnames/looooooongnaaaaaaame/anooooootherlooooooooongname/anooooootherlooooooooongname2/anooooootherlooooooooongname3/LongNamesTest.scala: -------------------------------------------------------------------------------- 1 | package test.longnames.looooooongnaaaaaaame.anooooootherlooooooooongname.anooooootherlooooooooongname2.anooooootherlooooooooongname3 2 | 3 | import org.scalatest._ 4 | 5 | class SomeLoooooooongTestNaaaaaaaaaaaaaaaaaaaaaaaame extends FlatSpec with Matchers { 6 | "This test" should "pass" in { 7 | assert(true) 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._ 4 | 5 | class PhaseTest extends FlatSpec { 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/BUILD: -------------------------------------------------------------------------------- 1 | load( 2 | "//test/phase/adjustment:phase_adjustment_test.bzl", 3 | "adjustment_replace_scala_library", 4 | "adjustment_replace_singleton", 5 | "adjustment_scala_library", 6 | "adjustment_singleton", 7 | ) 8 | 9 | adjustment_singleton( 10 | name = "phase_adjustment", 11 | visibility = ["//visibility:public"], 12 | ) 13 | 14 | adjustment_replace_singleton( 15 | name = "phase_adjustment_replace", 16 | visibility = ["//visibility:public"], 17 | ) 18 | 19 | adjustment_scala_library( 20 | name = "PhaseLibrary", 21 | srcs = ["PhaseLibrary.scala"], 22 | ) 23 | 24 | adjustment_replace_scala_library( 25 | name = "PhaseLibraryReplace", 26 | srcs = ["PhaseLibrary.scala"], 27 | ) 28 | -------------------------------------------------------------------------------- /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/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "check_expand_location", 5 | srcs = ["trivial.scala"], 6 | plugins = [ 7 | ":check_expand_location_plugin_deploy.jar", 8 | ], 9 | scalacopts = [ 10 | "-P:diablerie:location=$(location :check_expand_location_plugin_deploy.jar)", 11 | ], 12 | ) 13 | 14 | scala_library( 15 | name = "check_expand_location_plugin", 16 | srcs = [ 17 | "check_expand_location_plugin.scala", 18 | ], 19 | resource_strip_prefix = package_name(), 20 | resources = [ 21 | ":gen-scalac-plugin.xml", 22 | ], 23 | deps = [ 24 | "@io_bazel_rules_scala_scala_compiler", 25 | ], 26 | ) 27 | 28 | _gen_plugin_xml_cmd = """ 29 | cat > $@ << EOF 30 | 31 | plugin 32 | plugin.Plugin 33 | 34 | """ 35 | 36 | genrule( 37 | name = "gen-scalac-plugin.xml", 38 | outs = ["scalac-plugin.xml"], 39 | cmd = _gen_plugin_xml_cmd, 40 | ) 41 | -------------------------------------------------------------------------------- /test/plugins/check_expand_location_plugin.scala: -------------------------------------------------------------------------------- 1 | package plugin 2 | 3 | import scala.tools.nsc.Global 4 | import scala.tools.nsc.Phase 5 | import scala.tools.nsc.plugins.{ Plugin => NscPlugin} 6 | import scala.tools.nsc.plugins.PluginComponent 7 | 8 | import java.io.File 9 | 10 | final class Plugin(override val global: Global) extends NscPlugin { 11 | override val name: String = "diablerie" 12 | override val description: String = "just another plugin" 13 | override val components: List[PluginComponent] = Nil 14 | 15 | override def processOptions(options: List[String], error: String => Unit): Unit = { 16 | options 17 | .find(_.startsWith("location=")) 18 | .map(_.stripPrefix("location=")) 19 | .map(v => new File(v).exists) match { 20 | case Some(true) => () 21 | case Some(false) => error("expanded location doesn't exist") 22 | case None => error("missing location argument") 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /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 | import scala.util.Try 3 | 4 | class BlackListedProtoTest extends FlatSpec { 5 | 6 | "looking for a blacklisted proto" should "fail" in { 7 | // The direct test dep should be here. 8 | test.proto.test_service.TestServiceGrpc 9 | 10 | assert( 11 | Try(Class.forName("test.proto.blacklisted_proto.BlackListedProtoMessage")).isFailure) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/proto/CustomGeneratedObjectTest.scala: -------------------------------------------------------------------------------- 1 | import org.scalatest.FlatSpec 2 | import scala.util.Try 3 | 4 | class CustomGeneratedObjectTest extends FlatSpec { 5 | 6 | "Looking for the custom generated class" should "succeed" in { 7 | test_external_dep.CustomTestMessage 8 | assert( 9 | Try(Class.forName("test_external_dep.CustomTestMessage$")).isSuccess) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/proto/PackProtosTest.scala: -------------------------------------------------------------------------------- 1 | class PackProtosTest extends org.scalatest.FlatSpec { 2 | "scala_proto_library" should "pack input proto next to generated code" in { 3 | assert(getClass.getResource("test/proto/standalone.proto") != null) 4 | assert(getClass.getResource("proto/standalone.proto") != null) 5 | assert(getClass.getResource("standalone.proto") != null) 6 | assert(getClass.getResource("prefix/test/proto/standalone.proto") != null) 7 | assert(getClass.getResource("prefix/proto/standalone.proto") != null) 8 | assert(getClass.getResource("test/proto/some/path/nested.proto") != null) 9 | assert(getClass.getResource("path/nested.proto") != null) 10 | assert(getClass.getResource("prefix/test/proto/some/path/nested.proto") != null) 11 | assert(getClass.getResource("prefix/path/nested.proto") != null) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /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/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/BUILD: -------------------------------------------------------------------------------- 1 | load( 2 | "//scala_proto:scala_proto.bzl", 3 | "scala_proto_library", 4 | ) 5 | load("@rules_proto//proto:defs.bzl", "proto_library") 6 | 7 | genrule( 8 | name = "generated", 9 | srcs = ["test.proto"], 10 | outs = ["generated.proto"], 11 | cmd = "cp $(SRCS) \"$@\"", 12 | ) 13 | 14 | proto_library( 15 | name = "generated-proto-lib", 16 | srcs = [":generated"], 17 | visibility = ["//visibility:public"], 18 | ) 19 | 20 | scala_proto_library( 21 | name = "test_generated_proto", 22 | visibility = ["//visibility:public"], 23 | deps = [":generated-proto-lib"], 24 | ) 25 | -------------------------------------------------------------------------------- /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("@io_bazel_rules_scala//scala_proto:scala_proto.bzl", "scalapb_proto_library") 2 | 3 | scalapb_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.bzl: -------------------------------------------------------------------------------- 1 | def proto_cross_repo_boundary_repository(): 2 | native.new_local_repository( 3 | name = "proto_cross_repo_boundary", 4 | path = "test/proto_cross_repo_boundary/repo", 5 | build_file = "test/proto_cross_repo_boundary/repo/BUILD.repo", 6 | ) 7 | -------------------------------------------------------------------------------- /test/proto_cross_repo_boundary/repo/BUILD.repo: -------------------------------------------------------------------------------- 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/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/scala_test/A.scala: -------------------------------------------------------------------------------- 1 | 2 | import org.scalatest._ 3 | 4 | abstract class A extends FunSuite { 5 | val Number: Int 6 | 7 | test("number is positive") { 8 | assert(Number > 0) 9 | } 10 | } -------------------------------------------------------------------------------- /test/scala_test/B.scala: -------------------------------------------------------------------------------- 1 | 2 | class B extends A { 3 | override val Number: Int = 12 4 | } 5 | -------------------------------------------------------------------------------- /test/scala_test/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_scala//scala:scala.bzl", "scala_test") 2 | 3 | scala_test( 4 | name = "a", 5 | srcs = ["A.scala"], 6 | ) 7 | 8 | scala_test( 9 | name = "b", 10 | srcs = ["B.scala"], 11 | deps = [":a"], 12 | ) 13 | -------------------------------------------------------------------------------- /test/scalafmt/.scalafmt.conf: -------------------------------------------------------------------------------- 1 | maxColumn = 40 2 | -------------------------------------------------------------------------------- /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._ 3 | class FormatTest extends FlatSpec { 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._ 3 | class FormatTest extends FlatSpec { 4 | "FormatTest" should "be formatted" in { 5 | assert ( true ) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/shell/test_scala_classpath.sh: -------------------------------------------------------------------------------- 1 | # shellcheck source=./test_runner.sh 2 | dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 3 | . "${dir}"/test_runner.sh 4 | runner=$(get_test_runner "${1:-local}") 5 | 6 | test_scala_classpath_resources_expect_warning_on_namespace_conflict() { 7 | local output=$(bazel build \ 8 | --verbose_failures \ 9 | //test/src/main/scala/scalarules/test/classpath_resources:classpath_resource_duplicates 10 | ) 11 | 12 | local expected="Classpath resource file classpath-resourcehas a namespace conflict with another file: classpath-resource" 13 | 14 | if ! grep "$method" <<<$output; then 15 | echo "output:" 16 | echo "$output" 17 | echo "Expected $method in output, but was not found." 18 | exit 1 19 | fi 20 | } 21 | 22 | $runner test_scala_classpath_resources_expect_warning_on_namespace_conflict 23 | -------------------------------------------------------------------------------- /test/shell/test_scala_jvm_flags.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 | test_scala_jvm_flags_on_target_overrides_toolchain_passes() { 8 | bazel test --extra_toolchains="//manual_test/scala_test_jvm_flags:failing_scala_toolchain" //manual_test/scala_test_jvm_flags:empty_overriding_test 9 | } 10 | 11 | test_scala_jvm_flags_from_scala_toolchain_passes() { 12 | bazel test --extra_toolchains="//manual_test/scala_test_jvm_flags:passing_scala_toolchain" //manual_test/scala_test_jvm_flags:empty_test 13 | } 14 | 15 | test_scala_jvm_flags_from_scala_toolchain_fails() { 16 | action_should_fail test --extra_toolchains="//test_expect_failure/scala_test_jvm_flags:failing_scala_toolchain" //test_expect_failure/scala_test_jvm_flags:empty_test 17 | } 18 | 19 | $runner test_scala_jvm_flags_on_target_overrides_toolchain_passes 20 | $runner test_scala_jvm_flags_from_scala_toolchain_passes 21 | $runner test_scala_jvm_flags_from_scala_toolchain_fails 22 | -------------------------------------------------------------------------------- /test/shell/test_toolchain.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 | test_scalaopts_from_scala_toolchain() { 8 | action_should_fail build --extra_toolchains="//test_expect_failure/scalacopts_from_toolchain:failing_scala_toolchain" //test_expect_failure/scalacopts_from_toolchain:failing_build 9 | } 10 | 11 | java_toolchain_javacopts_are_used(){ 12 | action_should_fail_with_message \ 13 | "invalid flag: -InvalidFlag" \ 14 | build --java_toolchain=//test_expect_failure/compilers_javac_opts:a_java_toolchain \ 15 | --verbose_failures //test_expect_failure/compilers_javac_opts:can_configure_jvm_flags_for_javac_via_javacopts 16 | } 17 | 18 | $runner test_scalaopts_from_scala_toolchain 19 | $runner java_toolchain_javacopts_are_used 20 | -------------------------------------------------------------------------------- /test/src/main/resources/scalarules/test/BUILD: -------------------------------------------------------------------------------- 1 | exports_files([ 2 | "byes", 3 | "hellos", 4 | "hellos-and-byes.jar", 5 | "more-byes", 6 | "more-hellos", 7 | ]) 8 | 9 | genrule( 10 | name = "generated-hello", 11 | outs = ["generated-hello.txt"], 12 | cmd = "echo 'hello' > $@", 13 | visibility = ["//visibility:public"], 14 | ) 15 | -------------------------------------------------------------------------------- /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/hellos-and-byes.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/test/src/main/resources/scalarules/test/hellos-and-byes.jar -------------------------------------------------------------------------------- /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/MixJavaScalaLibBinary.scala: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package scalarules.test 16 | 17 | object MixJavaScalaLibBinary { 18 | def main(args: Array[String]) { 19 | val bar = new Bar() 20 | println("created an instance of a mixed java scala code from a library") 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/ResourcesStripScalaBinary.scala: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package scalarules.test 16 | 17 | object ResourcesStripScalaBinary { 18 | def main(args:Array[String]) { 19 | ResourcesStripScalaLib.getGreetings foreach println 20 | ResourcesStripScalaLib.getFarewells foreach println 21 | ResourcesStripScalaLib.getData foreach println 22 | ResourcesStripScalaLib.getGeneratedHello foreach println 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/ScalaLibBinary.scala: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package scalarules.test 16 | 17 | object ScalaLibBinary { 18 | def main(args:Array[String]) { 19 | ScalaLibResources.getGreetings foreach println 20 | ScalaLibResources.getFarewells foreach println 21 | ScalaLibResources.getData foreach println 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/classpath_resources/ObjectWithClasspathResources.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.classpathresources 2 | 3 | import scala.io.Source 4 | 5 | object ObjectWithClasspathResources extends App { 6 | val expectedSubstrings = Map( 7 | "byes" -> "later", 8 | "hellos" -> "Bonjour", 9 | "more-byes" -> "more see ya", 10 | "more-hellos" -> "More Hello" 11 | ) 12 | expectedSubstrings.foreach { 13 | case (resource_name, substring) => { 14 | val stream = getClass.getResourceAsStream("/" + resource_name) 15 | assert(stream != null, s"failed to find classpath resource $resource_name") 16 | val content = Source.fromInputStream(stream).getLines().mkString("\n") 17 | assert(content.contains(substring), s"classpath resource $resource_name did not contain substring $substring") 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /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 | srcs = ["KindProjected.scala"], 6 | plugins = ["@org_spire_math_kind_projector//jar"], 7 | visibility = ["//visibility:public"], 8 | ) 9 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/compiler_plugin/KindProjected.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.src.main.scala.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/extra_protobuf_generator/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "extra_protobuf_generator", 5 | srcs = ["ExtraProtobufGenerator.scala"], 6 | visibility = ["//visibility:public"], 7 | deps = [ 8 | "//external:io_bazel_rules_scala/dependency/com_google_protobuf/protobuf_java", 9 | "//external:io_bazel_rules_scala/dependency/proto/protoc_bridge", 10 | "//external:io_bazel_rules_scala/dependency/proto/scalapb_plugin", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /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 | srcs = ["FetchSources.scala"], 6 | deps = ["@com_google_guava_guava_21_0//jar"], 7 | ) 8 | -------------------------------------------------------------------------------- /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 | package(default_visibility = ["//visibility:public"]) 2 | 3 | load("//scala:scala.bzl", "scala_binary", "scala_library", "scala_test") 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/junit/FilterTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit 2 | 3 | import org.junit.Test 4 | 5 | class FirstFilterTest { 6 | @Test def method1 { println(this.getClass.getName + "#method1") } 7 | @Test def method2 { println(this.getClass.getName + "#method2") } 8 | @Test def method3 { println(this.getClass.getName + "#method3") } 9 | } 10 | 11 | class SecondFilterTest { 12 | @Test def method1 { println(this.getClass.getName + "#method1") } 13 | @Test def method2 { println(this.getClass.getName + "#method2") } 14 | @Test def method3 { println(this.getClass.getName + "#method3") } 15 | } 16 | 17 | class ThirdFilterTest { 18 | @Test def method1 { println(this.getClass.getName + "#method1") } 19 | @Test def method2 { println(this.getClass.getName + "#method2") } 20 | @Test def method3 { println(this.getClass.getName + "#method3") } 21 | } 22 | -------------------------------------------------------------------------------- /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/JunitCustomRunner.java: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit; 2 | 3 | import java.util.List; 4 | import org.junit.rules.TestRule; 5 | import org.junit.runners.BlockJUnit4ClassRunner; 6 | import org.junit.runners.model.InitializationError; 7 | 8 | public class JunitCustomRunner extends BlockJUnit4ClassRunner { 9 | 10 | public JunitCustomRunner(Class aClass) throws InitializationError { 11 | super(aClass); 12 | } 13 | 14 | public static final String EXPECTED_MESSAGE = "Hello from getTestRules!"; 15 | public static String message; 16 | 17 | @Override 18 | protected List getTestRules(Object target) { 19 | message = EXPECTED_MESSAGE; 20 | return super.getTestRules(target); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /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/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/JunitTests.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit 2 | 3 | import org.junit.Test 4 | import org.hamcrest.CoreMatchers._ 5 | import org.hamcrest.MatcherAssert._ 6 | import scalarules.test.junit.support.JUnitCompileTimeDep 7 | import java.lang.management.ManagementFactory 8 | import java.lang.management.RuntimeMXBean 9 | 10 | class JunitWithDepsTest { 11 | 12 | @Test 13 | def hasCompileTimeDependencies: Unit = { 14 | println(JUnitCompileTimeDep.hello) 15 | } 16 | 17 | @Test 18 | def hasRuntimeDependencies: Unit = { 19 | Class.forName("scalarules.test.junit.support.JUnitRuntimeDep") 20 | } 21 | 22 | @Test 23 | def supportsCustomJVMArgs: Unit = { 24 | assertThat(ManagementFactory.getRuntimeMXBean().getInputArguments(), 25 | hasItem("-XX:HeapDumpPath=/some/custom/path")) 26 | } 27 | 28 | } 29 | 30 | class ClassCoveringRegressionFromTakingAllClassesInArchive 31 | -------------------------------------------------------------------------------- /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 | } 11 | } 12 | -------------------------------------------------------------------------------- /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/large_classpath/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_binary", "scala_library") 2 | load(":helper.bzl", "create_dependencies", "get_dependency_labels") 3 | 4 | scala_binary( 5 | name = "largeClasspath", 6 | srcs = ["ObjectWithLargeClasspath.scala"], 7 | main_class = "scalarules.test.large_classpath.ObjectWithLargeClasspath", 8 | unused_dependency_checker_mode = "off", 9 | visibility = ["//visibility:public"], 10 | deps = get_dependency_labels( 11 | amount = 1000, 12 | length = 20, 13 | ), 14 | ) 15 | 16 | scala_library( 17 | name = "triggerDeployJarCreation", 18 | data = [":largeClasspath_deploy.jar"], 19 | ) 20 | 21 | create_dependencies( 22 | amount = 1000, 23 | length = 20, 24 | ) 25 | -------------------------------------------------------------------------------- /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" should { 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/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/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/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/resource_jars/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library", "scala_test") 2 | 3 | scala_test( 4 | name = "resource_jars", 5 | srcs = ["TestResourceJars.scala"], 6 | resource_jars = ["//test/src/main/resources/scalarules/test:hellos-and-byes.jar"], 7 | ) 8 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/resource_jars/TestResourceJars.scala: -------------------------------------------------------------------------------- 1 | package foo 2 | 3 | import scala.io.Source 4 | 5 | import org.scalatest._ 6 | 7 | 8 | class TestResourceJars extends FlatSpec { 9 | "this jar" should "contain resources from its resource jar dependency" in { 10 | val expectedSubstrings = Map( 11 | "byes" -> "later", 12 | "hellos" -> "Bonjour", 13 | "more-byes" -> "more see ya", 14 | "more-hellos" -> "More Hello" 15 | ) 16 | expectedSubstrings.foreach { 17 | case (resource_name, substring) => { 18 | val stream = getClass.getResourceAsStream("/" + resource_name) 19 | assert(stream != null, s"failed to find resource $resource_name") 20 | val content = Source.fromInputStream(stream).getLines().mkString("\n") 21 | assert(content.contains(substring), s"resource $resource_name did not contain substring $substring") 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/resources/ScalaLibOnlyResourcesFilegroupTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.resources 2 | 3 | import org.specs2.mutable.SpecWithJUnit 4 | 5 | class ScalaLibOnlyResourcesFilegroupTest extends SpecWithJUnit { 6 | 7 | "Scala library with no srcs and only filegroup resources" should { 8 | "allow to load resources" >> { 9 | get("/resource.txt") must beEqualTo("I am a text resource!") 10 | get("/subdir/resource.txt") must beEqualTo("I am a text resource in a subdir!") 11 | } 12 | } 13 | 14 | private def get(s: String): String = 15 | scala.io.Source.fromInputStream(getClass.getResourceAsStream(s)).mkString 16 | 17 | } 18 | 19 | -------------------------------------------------------------------------------- /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" should { 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/ScalaLibResourcesFromExternalDepTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.resources 2 | 3 | import org.specs2.mutable.SpecWithJUnit 4 | 5 | class ScalaLibResourcesFromExternalDepTest extends SpecWithJUnit { 6 | 7 | "Scala library depending on resources from external resource-only jar" should { 8 | "allow to load resources" >> { 9 | get("/external/test_new_local_repo/resource.txt") must beEqualTo("A resource\n") 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/ScalaLibResourcesFromExternalScalaTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.resources 2 | 3 | import org.scalatest.FunSuite 4 | 5 | class ScalaLibResourcesFromExternalScalaTest extends FunSuite { 6 | 7 | test("Scala library depending on resources from external resource-only jar should allow to load resources") { 8 | assert(get("/external/test_new_local_repo/resource.txt") === "A resource\n") 9 | } 10 | 11 | private def get(s: String): String = 12 | scala.io.Source.fromInputStream(getClass.getResourceAsStream(s)).mkString 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/resources/resource.txt: -------------------------------------------------------------------------------- 1 | I am a text resource! -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/resources/strip/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library", "scala_specs2_junit_test") 2 | 3 | scala_library( 4 | name = "noSrcsWithResources", 5 | resource_strip_prefix = "test/src/main/scala/scalarules/test/resources/strip", 6 | resources = ["nosrc_jar_resource.txt"], 7 | ) 8 | 9 | scala_specs2_junit_test( 10 | name = "resouceStripPrefixTest", 11 | size = "small", 12 | srcs = ["ResourceStripPrefixTest.scala"], 13 | suffixes = ["Test"], 14 | unused_dependency_checker_mode = "off", 15 | deps = [":noSrcsWithResources"], 16 | ) 17 | 18 | scala_specs2_junit_test( 19 | name = "resouceStripPrefixFromExternalRepoTest", 20 | size = "small", 21 | srcs = ["ResourceStripPrefixTest.scala"], 22 | suffixes = ["Test"], 23 | unused_dependency_checker_mode = "off", 24 | deps = ["@strip_resource_external_workspace//strip:noSrcsWithResources"], 25 | ) 26 | -------------------------------------------------------------------------------- /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" should { 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 org.specs2.mutable.SpecificationWithJUnit 4 | import com.lucidchart.relate.SqlRow 5 | 6 | class ScalaImportExposesJarsTest extends SpecificationWithJUnit { 7 | 8 | "scala_import" should { 9 | "enable importing jars from files" in { 10 | println(classOf[SqlRow]) 11 | success 12 | } 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /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.SpecificationWithJUnit 6 | 7 | class ScalaImportExposesJarsTest extends SpecificationWithJUnit { 8 | 9 | "scala_import" should { 10 | "enable using the jars it exposes" in { 11 | println(classOf[Cache[String, String]]) 12 | println(classOf[ArrayUtils]) 13 | success 14 | } 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /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" should { 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/nl/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_specs2_junit_test") 2 | load("//scala:scala_import.bzl", "scala_import") 3 | 4 | scala_import( 5 | name = "scala_import_never_link", 6 | jars = [ 7 | "scala_import_never_link.jar", 8 | ], 9 | neverlink = 1, 10 | ) 11 | 12 | scala_specs2_junit_test( 13 | name = "scala_import_never_link_test", 14 | size = "small", 15 | srcs = ["ScalaImportNeverLinkTest.scala"], 16 | suffixes = ["Test"], 17 | deps = [":scala_import_never_link"], 18 | ) 19 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/scala_import/nl/ScalaImportNeverLink.java: -------------------------------------------------------------------------------- 1 | package scalarules.test.scala_import.nl; 2 | 3 | /** 4 | * This class is packaged in scala_import_never_link.jar 5 | * 6 | *

The jar file was created with the following steps: 7 | * 8 | *

- javac ScalaImportNeverLink.java - makdir -p scalarules/test/scala_import/nl - mv 9 | * ScalaImportNeverLink.class scalarules/test/scala_import/nl - jar cf scala_import_never_link.jar 10 | * scalarules - rm -fr scalarules ScalaImportNeverLink.class 11 | * 12 | *

To stage the updated jar: git add -f scala_import_never_link.jar 13 | */ 14 | public class ScalaImportNeverLink {} 15 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/scala_import/nl/ScalaImportNeverLinkTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.scala_import.nl 2 | 3 | import org.specs2.mutable.SpecificationWithJUnit 4 | 5 | class ScalaImportNeverLinkTest extends SpecificationWithJUnit { 6 | "neverlinked scala_import" should { 7 | "not be available in runtime" in { 8 | //ScalaImportNeverLink class is packaged in scala_import_never_link.jar. Since the scala_import target 9 | //is marked as "neverlink" - this test class/target will be built successfully but will fail on runtime with 10 | //NoClassDefFoundError (neverlink targets are not available on runtime only on build/compile) 11 | createScalaImportNeverLink() must throwA[NoClassDefFoundError]("scalarules/test/scala_import/nl/ScalaImportNeverLink") 12 | } 13 | } 14 | 15 | private def createScalaImportNeverLink() = new ScalaImportNeverLink() 16 | 17 | } 18 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/scala_import/nl/scala_import_never_link.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/test/src/main/scala/scalarules/test/scala_import/nl/scala_import_never_link.jar -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/scala_import/relate_2.11-2.1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/test/src/main/scala/scalarules/test/scala_import/relate_2.11-2.1.1.jar -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/scripts/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library", "scala_specs2_junit_test") 2 | load("//scala:scala_import.bzl", "scala_import") 3 | 4 | scala_specs2_junit_test( 5 | name = "pb_generate_request_test", 6 | size = "small", 7 | srcs = ["PBGenerateRequestTest.scala"], 8 | suffixes = ["Test"], 9 | deps = ["//src/scala/scripts:scala_proto_request_extractor"], 10 | ) 11 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/scripts/PBGenerateRequestTest.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.scripts 2 | 3 | import java.nio.file.Paths 4 | import scripts.PBGenerateRequest 5 | import org.specs2.mutable.SpecWithJUnit 6 | 7 | class PBGenerateRequestTest extends SpecWithJUnit { 8 | "fixTransitiveProtoPath should fix path when included proto is available, ignore otherwise" >> { 9 | val includedProtos = List(Paths.get("a/b/c") -> Paths.get("a/b/c/d/e/f.proto")) 10 | Seq("d/e", "x/y/z").map(PBGenerateRequest.fixTransitiveProtoPath(includedProtos)) must 11 | beEqualTo(Seq("a/b/c/d/e", "x/y/z")) 12 | } 13 | 14 | "actual case observed in builds" >> { 15 | val includedProtos = List( 16 | Paths.get("bazel-out/k8-fastbuild/bin") -> 17 | Paths.get("bazel-out/k8-fastbuild/bin/external/com_google_protobuf/google/protobuf/source_context.proto")) 18 | Seq("external/com_google_protobuf").map(PBGenerateRequest.fixTransitiveProtoPath(includedProtos)) must 19 | beEqualTo(Seq("bazel-out/k8-fastbuild/bin/external/com_google_protobuf")) 20 | } 21 | } -------------------------------------------------------------------------------- /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 | srcs = ["ReferCatsImplicits.scala"], 6 | deps = [ 7 | "@org_typelevel__cats_core//jar", 8 | ], 9 | ) 10 | -------------------------------------------------------------------------------- /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/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | #TODO the way it SHOULD work (but isn't currently) is that 4 | # the source_jar target should make available a compiled jar, 5 | # and use_source_jar should depend on that internally 6 | 7 | scala_library( 8 | name = "source_jar", 9 | # SourceJar1.jar was created by: 10 | # jar -cfM test/src/main/scala/scalarules/test/srcjars/SourceJar1.srcjar \ 11 | # test/src/main/scala/scalarules/test/srcjars/SourceJar1.scala 12 | srcs = ["SourceJar1.srcjar"], 13 | ) 14 | 15 | scala_library( 16 | name = "use_source_jar", 17 | srcs = ["SourceJar2.scala"], 18 | deps = [":source_jar"], 19 | ) 20 | -------------------------------------------------------------------------------- /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/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/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_with_java/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | scala_library( 4 | name = "mixed_language_source_jar", 5 | # MixedLanguageSourceJar.srcjar was constructed with 6 | # `jar -cfM MixedLanguageSourceJar.srcjar JavaSource.java ScalaSource.scala` 7 | srcs = ["MixedLanguageSourceJar.srcjar"], 8 | ) 9 | 10 | scala_library( 11 | name = "mixed_language_dependent", 12 | srcs = ["MixedLanguageDependent.scala"], 13 | deps = [":mixed_language_source_jar"], 14 | ) 15 | 16 | scala_library( 17 | name = "java_source_jar", 18 | # JavaSourceJar.srcjar was constructed with 19 | # `jar -cfM JavaSourceJar.srcjar JavaSource.java` 20 | srcs = ["JavaSourceJar.srcjar"], 21 | ) 22 | 23 | scala_library( 24 | name = "java_dependent", 25 | srcs = ["JavaDependent.scala"], 26 | deps = [":java_source_jar"], 27 | ) 28 | -------------------------------------------------------------------------------- /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 | public static final String line = "one fish, two fish"; 5 | } 6 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/srcjars_with_java/JavaSourceJar.srcjar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/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/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/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/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/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | load("//scala:scala.bzl", "scala_binary", "scala_library", "scala_test") 4 | 5 | scala_library( 6 | name = "transitive_dependency_user", 7 | srcs = [ 8 | "A.scala", 9 | ], 10 | deps = ["direct_dependency"], 11 | ) 12 | 13 | scala_library( 14 | name = "direct_dependency", 15 | srcs = [ 16 | "B.scala", 17 | ], 18 | deps = ["transitive_dependency"], 19 | ) 20 | 21 | scala_library( 22 | name = "transitive_dependency", 23 | srcs = [ 24 | "C.scala", 25 | ], 26 | ) 27 | -------------------------------------------------------------------------------- /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.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.twitter_scrooge 2 | 3 | import scalarules.test.twitter_scrooge.thrift.Struct1 4 | import scalarules.test.twitter_scrooge.thrift.thrift2.Struct2A 5 | import scalarules.test.twitter_scrooge.thrift.thrift2.Struct2B 6 | import scalarules.test.twitter_scrooge.thrift.thrift2.thrift3.Struct3 7 | 8 | object JustScrooge1 { 9 | val classes = Seq(classOf[Struct1], classOf[Struct2A], classOf[Struct2B], classOf[Struct3]) 10 | 11 | def main(args: Array[String]) { 12 | print(s"classes ${classes.mkString(",")}") 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /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/Mixed.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.twitter_scrooge 2 | 3 | import scalarules.test.twitter_scrooge.thrift.Struct1 4 | import scalarules.test.twitter_scrooge.thrift.thrift2.Struct2A 5 | import scalarules.test.twitter_scrooge.thrift.thrift2.Struct2B 6 | import scalarules.test.twitter_scrooge.thrift.thrift2.thrift3.Struct3 7 | 8 | object Mixed { 9 | val classes = 10 | Seq( 11 | classOf[Struct1], 12 | classOf[Struct2A], 13 | classOf[Struct2B], 14 | classOf[Struct3], 15 | JustScrooge1.getClass, 16 | JustScrooge2a.getClass, 17 | JustScrooge2b.getClass, 18 | JustScrooge3.getClass 19 | ) 20 | } 21 | -------------------------------------------------------------------------------- /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/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/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/prefix_test/e/f/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 = "b_thrift", 6 | srcs = ["B.thrift"], 7 | absolute_prefixes = [ 8 | "prefix_test/a", 9 | "prefix_test/e/f", 10 | ], 11 | visibility = ["//visibility:public"], 12 | deps = ["//test/src/main/scala/scalarules/test/twitter_scrooge/prefix_test/a/b/c/d:a_thrift"], 13 | ) 14 | 15 | scrooge_scala_library( 16 | name = "d", 17 | visibility = ["//visibility:public"], 18 | exports = [ 19 | "//test/src/main/scala/scalarules/test/twitter_scrooge/prefix_test/a/b/c/d", 20 | ], 21 | deps = [ 22 | ":b_thrift", 23 | ], 24 | ) 25 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/thrift/BUILD: -------------------------------------------------------------------------------- 1 | load("//thrift:thrift.bzl", "thrift_library") 2 | 3 | thrift_library( 4 | name = "thrift", 5 | srcs = ["Thrift1.thrift"], 6 | visibility = ["//visibility:public"], 7 | deps = [ 8 | "//test/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2:thrift2_a", 9 | "//test/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2:thrift2_b", 10 | ], 11 | ) 12 | 13 | thrift_library( 14 | name = "thrift_many", 15 | srcs = [ 16 | "ThriftMany1.thrift", 17 | "ThriftMany2.thrift", 18 | ], 19 | visibility = ["//visibility:public"], 20 | ) 21 | -------------------------------------------------------------------------------- /test/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/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/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_import") 2 | load("//thrift:thrift.bzl", "thrift_library") 3 | 4 | java_import( 5 | name = "barejar", 6 | jars = ["bare-thrift.jar"], 7 | visibility = ["//visibility:public"], 8 | ) 9 | 10 | thrift_library( 11 | name = "bare_jar_thrifts", 12 | external_jars = [ 13 | ":barejar", 14 | ], 15 | visibility = ["//visibility:public"], 16 | deps = [ 17 | "//test/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_1", 18 | "//test/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_2", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /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-thrift.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/test/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare-thrift.jar -------------------------------------------------------------------------------- /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 = "bare_jar_1", 5 | external_jars = [ 6 | "bare-thrift-1.jar", 7 | ], 8 | visibility = ["//visibility:public"], 9 | ) 10 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_1/bare-thrift-1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/test/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_1/bare-thrift-1.jar -------------------------------------------------------------------------------- /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 = "bare_jar_2", 5 | external_jars = [ 6 | "bare-thrift-2.jar", 7 | ], 8 | visibility = ["//visibility:public"], 9 | ) 10 | -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_2/bare-thrift-2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/test/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_2/bare-thrift-2.jar -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/BUILD: -------------------------------------------------------------------------------- 1 | load("//thrift:thrift.bzl", "thrift_library") 2 | 3 | thrift_library( 4 | name = "thrift2_a", 5 | srcs = ["Thrift2_A.thrift"], 6 | visibility = ["//visibility:public"], 7 | deps = ["//test/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/thrift3"], 8 | ) 9 | 10 | thrift_library( 11 | name = "thrift2_b", 12 | srcs = ["Thrift2_B.thrift"], 13 | visibility = ["//visibility:public"], 14 | deps = ["//test/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/thrift3"], 15 | ) 16 | 17 | thrift_library( 18 | name = "thrift2_b_imp", 19 | srcs = ["Thrift2_B.thrift"], 20 | visibility = ["//visibility:public"], 21 | deps = ["//test/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/thrift3:thrift3_import"], 22 | ) 23 | -------------------------------------------------------------------------------- /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/BUILD: -------------------------------------------------------------------------------- 1 | load("//thrift:thrift.bzl", "thrift_library") 2 | load("//twitter_scrooge:twitter_scrooge.bzl", "scrooge_scala_import") 3 | 4 | thrift_library( 5 | name = "thrift3", 6 | srcs = ["Thrift3.thrift"], 7 | visibility = ["//visibility:public"], 8 | ) 9 | 10 | scrooge_scala_import( 11 | name = "thrift3_import", 12 | scala_jars = ["thrift3_scrooge.jar"], 13 | thrift_jars = ["libthrift3.jar"], 14 | visibility = ["//visibility:public"], 15 | ) 16 | -------------------------------------------------------------------------------- /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/thrift3/thrift3_scrooge.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/test/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/thrift3/thrift3_scrooge.jar -------------------------------------------------------------------------------- /test/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/thrift4/BUILD: -------------------------------------------------------------------------------- 1 | load("//thrift:thrift.bzl", "thrift_library") 2 | 3 | thrift_library( 4 | name = "thrift4", 5 | srcs = ["Thrift4.thrift"], 6 | visibility = ["//visibility:public"], 7 | deps = [ 8 | "//test/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2:thrift2_a", 9 | ], 10 | ) 11 | 12 | thrift_library( 13 | name = "thrift4a", 14 | srcs = ["Thrift4a.thrift"], 15 | visibility = ["//visibility:public"], 16 | deps = [ 17 | ":thrift4", 18 | "//test/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2:thrift2_a", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /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/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/tut/BUILD: -------------------------------------------------------------------------------- 1 | load("//tut_rule:tut.bzl", "scala_tut_doc") 2 | load("//scala:scala.bzl", "scala_library") 3 | 4 | scala_library( 5 | name = "test_dep", 6 | srcs = ["TestDep.scala"], 7 | ) 8 | 9 | #TODO - uncomment once tut repo flakiness is resolved 10 | #scala_tut_doc( 11 | # name = "some_example", 12 | # src = "SomeExample.md", 13 | # deps = [":test_dep"], 14 | #) 15 | -------------------------------------------------------------------------------- /test/tut/SomeExample.md: -------------------------------------------------------------------------------- 1 | # This is markdown 2 | 3 | ``` 4 | With some stuff 5 | ``` 6 | 7 | ```tut 8 | List(1, 2, 3).sum 9 | 10 | import foo.Bar 11 | Bar.values 12 | ``` 13 | -------------------------------------------------------------------------------- /test/tut/TestDep.scala: -------------------------------------------------------------------------------- 1 | package foo 2 | 3 | object Bar { 4 | def values: List[Int] = List(2, 3, 5, 7) 5 | } 6 | -------------------------------------------------------------------------------- /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 FunSuite { 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_rules_scala.sh 7 | "${dir}"/test_version.sh 8 | "${dir}"/test_reproducibility.sh 9 | #"${dir}"/test_intellij_aspect.sh 10 | -------------------------------------------------------------------------------- /test_expect_failure/compilers_javac_opts/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain") 3 | 4 | scala_library( 5 | name = "can_configure_jvm_flags_for_javac_via_javacopts", 6 | srcs = ["WillNotCompileSinceJavaToolchainAddsAnInvalidJvmFlag.java"], 7 | ) 8 | 9 | default_java_toolchain( 10 | name = "a_java_toolchain", 11 | bootclasspath = ["@bazel_tools//tools/jdk:platformclasspath.jar"], 12 | javac = ["@bazel_tools//third_party/java/jdk/langtools:javac_jar"], 13 | jvm_opts = ["-Xbootclasspath/p:$(location @bazel_tools//third_party/java/jdk/langtools:javac_jar)"], 14 | misc = [ 15 | "-InvalidFlag", 16 | ], 17 | visibility = ["//visibility:public"], 18 | ) 19 | -------------------------------------------------------------------------------- /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/disappearing_class/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_binary", "scala_library", "scala_macro_library", "scala_test") 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/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/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/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | load("//scala:scala.bzl", "scala_library", "scala_test") 4 | 5 | scala_library( 6 | name = "transitive_external_dependency_user", 7 | srcs = [ 8 | "A.scala", 9 | ], 10 | deps = ["external_dependency_user"], 11 | ) 12 | 13 | scala_library( 14 | name = "external_dependency_user", 15 | srcs = [ 16 | "B.scala", 17 | ], 18 | deps = ["@com_google_guava_guava_21_0//jar"], 19 | ) 20 | 21 | scala_library( 22 | name = "transitive_external_dependency_user_file_group", 23 | srcs = [ 24 | "A.scala", 25 | ], 26 | deps = ["external_dependency_user_file_group"], 27 | ) 28 | 29 | scala_library( 30 | name = "external_dependency_user_file_group", 31 | srcs = [ 32 | "B.scala", 33 | ], 34 | deps = ["@com_google_guava_guava_21_0_with_file//jar"], 35 | ) 36 | -------------------------------------------------------------------------------- /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/internal_deps/custom-jvm-rule.bzl: -------------------------------------------------------------------------------- 1 | #This rule is an example for a jvm rule that doesn't support Jars2Labels 2 | def _custom_jvm_impl(ctx): 3 | # TODO(#8867): Migrate away from the placeholder jar hack when #8867 is fixed. 4 | jar = ctx.file._placeholder_jar 5 | provider = JavaInfo( 6 | output_jar = jar, 7 | compile_jar = jar, 8 | deps = [target[JavaInfo] for target in ctx.attr.deps], 9 | ) 10 | return [provider] 11 | 12 | custom_jvm = rule( 13 | implementation = _custom_jvm_impl, 14 | attrs = { 15 | "deps": attr.label_list(), 16 | "_placeholder_jar": attr.label( 17 | allow_single_file = True, 18 | default = Label("@io_bazel_rules_scala//scala:libPlaceHolderClassToCreateEmptyJarForScalaImport.jar"), 19 | ), 20 | }, 21 | ) 22 | -------------------------------------------------------------------------------- /test_expect_failure/plus_one_deps/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//scala:scala_toolchain.bzl", "scala_toolchain") 2 | 3 | scala_toolchain( 4 | name = "plus_one_deps_impl", 5 | plus_one_deps_mode = "on", 6 | visibility = ["//visibility:public"], 7 | ) 8 | 9 | toolchain( 10 | name = "plus_one_deps", 11 | toolchain = "plus_one_deps_impl", 12 | toolchain_type = "@io_bazel_rules_scala//scala:toolchain_type", 13 | visibility = ["//visibility:public"], 14 | ) 15 | 16 | scala_toolchain( 17 | name = "plus_one_deps_with_unused_error_impl", 18 | plus_one_deps_mode = "on", 19 | unused_dependency_checker_mode = "error", 20 | visibility = ["//visibility:public"], 21 | ) 22 | 23 | toolchain( 24 | name = "plus_one_deps_with_unused_error", 25 | toolchain = "plus_one_deps_with_unused_error_impl", 26 | toolchain_type = "@io_bazel_rules_scala//scala:toolchain_type", 27 | visibility = ["//visibility:public"], 28 | ) 29 | -------------------------------------------------------------------------------- /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/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | #Make sure that plus-one-deps from exports of direct deps also propagate 3 | 4 | #example with target only in exports 5 | scala_library( 6 | name = "test_target_using_facade", 7 | srcs = ["A.scala"], 8 | deps = [":facade"], 9 | ) 10 | 11 | scala_library( 12 | name = "facade", 13 | exports = [":direct_dep"], 14 | ) 15 | 16 | #example with target in deps & exports 17 | scala_library( 18 | name = "test_target", 19 | srcs = ["A.scala"], 20 | deps = [":direct_dep"], 21 | ) 22 | 23 | scala_library( 24 | name = "direct_dep", 25 | srcs = ["B.scala"], 26 | exports = [":exported_dep"], 27 | deps = [":exported_dep"], 28 | ) 29 | 30 | #common 31 | scala_library( 32 | name = "exported_dep", 33 | srcs = ["C.scala"], 34 | deps = [":plus_one_dep_of_exported"], 35 | ) 36 | 37 | scala_library( 38 | name = "plus_one_dep_of_exported", 39 | srcs = ["D.scala"], 40 | ) 41 | -------------------------------------------------------------------------------- /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/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_library") 2 | 3 | #Make sure that plus-one-deps exported targets are also propagated (in addition to the plus-one-dep outputs) 4 | scala_library( 5 | name = "test_target", 6 | srcs = ["A.scala"], 7 | deps = [":direct_dep"], 8 | ) 9 | 10 | scala_library( 11 | name = "direct_dep", 12 | srcs = ["B.scala"], 13 | deps = [":plus_one_dep"], 14 | ) 15 | 16 | scala_library( 17 | name = "plus_one_dep", 18 | srcs = ["C.scala"], 19 | exports = ["exported_dep"], 20 | deps = [":exported_dep"], 21 | ) 22 | 23 | scala_library( 24 | name = "exported_dep", 25 | srcs = ["D.scala"], 26 | ) 27 | -------------------------------------------------------------------------------- /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 | srcs = ["A.scala"], 6 | deps = ["@org_springframework_spring_tx"], 7 | ) 8 | -------------------------------------------------------------------------------- /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_import/ScalaImportPropagatesCompileDepsTest.scala: -------------------------------------------------------------------------------- 1 | package test_expect_failure.scala_import 2 | 3 | import com.google.common.cache.Cache 4 | import org.apache.commons.lang3.ArrayUtils 5 | import org.specs2.mutable.SpecificationWithJUnit 6 | 7 | class ScalaImportPropagatesCompileDepsTest extends SpecificationWithJUnit { 8 | 9 | "scala_import" should { 10 | "propagate compile time deps" in { 11 | println(classOf[Cache[String, String]]) 12 | println(classOf[ArrayUtils]) 13 | println(classOf[cats.Applicative[Any]]) 14 | success 15 | } 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /test_expect_failure/scala_junit_test/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala.bzl", "scala_junit_test", "scala_specs2_junit_test") 2 | 3 | scala_junit_test( 4 | name = "failing_test", 5 | size = "small", 6 | srcs = ["JunitFailureTest.scala"], 7 | suffixes = ["Test"], 8 | ) 9 | 10 | scala_junit_test( 11 | name = "no_prefix_or_suffix", 12 | size = "small", 13 | srcs = ["JunitTest.scala"], 14 | ) 15 | 16 | scala_junit_test( 17 | name = "no_tests_found", 18 | size = "small", 19 | srcs = ["JunitTest.scala"], 20 | suffixes = ["DoesNotMatch"], 21 | ) 22 | 23 | scala_specs2_junit_test( 24 | name = "specs2_failing_test", 25 | size = "small", 26 | srcs = [ 27 | "specs2/FailingTest.scala", 28 | "specs2/SuiteWithOneFailingTest.scala", 29 | ], 30 | suffixes = ["Test"], 31 | ) 32 | -------------------------------------------------------------------------------- /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" should { 8 | "succeed" >> success 9 | "fail" >> failure("boom") 10 | } 11 | 12 | "some other suite" should { 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_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/scalac_jvm_opts/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala_toolchain.bzl", "scala_toolchain") 2 | load("//scala:scala.bzl", "scala_library") 3 | load( 4 | "//scala_proto:scala_proto.bzl", 5 | "scala_proto_library", 6 | ) 7 | 8 | scala_toolchain( 9 | name = "failing_toolchain_impl", 10 | # This will fail because 1M isn't enough 11 | scalac_jvm_flags = ["-Xmx1M"], 12 | visibility = ["//visibility:public"], 13 | ) 14 | 15 | toolchain( 16 | name = "failing_scala_toolchain", 17 | toolchain = "failing_toolchain_impl", 18 | toolchain_type = "@io_bazel_rules_scala//scala:toolchain_type", 19 | visibility = ["//visibility:public"], 20 | ) 21 | 22 | scala_library( 23 | name = "empty_build", 24 | srcs = ["Empty.scala"], 25 | ) 26 | -------------------------------------------------------------------------------- /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/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala_toolchain.bzl", "scala_toolchain") 2 | load("//scala:scala.bzl", "scala_library") 3 | 4 | scala_toolchain( 5 | name = "failing_toolchain_impl", 6 | scalacopts = ["-Ywarn-unused"], 7 | visibility = ["//visibility:public"], 8 | ) 9 | 10 | toolchain( 11 | name = "failing_scala_toolchain", 12 | toolchain = "failing_toolchain_impl", 13 | toolchain_type = "@io_bazel_rules_scala//scala:toolchain_type", 14 | visibility = ["//visibility:public"], 15 | ) 16 | 17 | scala_library( 18 | name = "failing_build", 19 | srcs = ["ClassWithUnused.scala"], 20 | scalacopts = ["-Xfatal-warnings"], 21 | ) 22 | -------------------------------------------------------------------------------- /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/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_export_to_java", "scala_library") 3 | 4 | scala_library( 5 | name = "a", 6 | srcs = ["A.scala"], 7 | ) 8 | 9 | scala_export_to_java( 10 | name = "b", 11 | exports = [":a"], 12 | runtime_deps = [], 13 | ) 14 | 15 | java_library( 16 | name = "c", 17 | srcs = ["C.java"], 18 | deps = [":b"], 19 | ) 20 | 21 | java_library( 22 | name = "d", 23 | srcs = ["D.java"], 24 | tags = ["manual"], 25 | deps = [":c"], 26 | ) 27 | -------------------------------------------------------------------------------- /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/BUILD: -------------------------------------------------------------------------------- 1 | load("//scala:scala_toolchain.bzl", "scala_toolchain") 2 | load("//scala:scala.bzl", "scala_library") 3 | 4 | scala_toolchain( 5 | name = "failing_toolchain_impl", 6 | unused_dependency_checker_mode = "error", 7 | visibility = ["//visibility:public"], 8 | ) 9 | 10 | toolchain( 11 | name = "failing_scala_toolchain", 12 | toolchain = "failing_toolchain_impl", 13 | toolchain_type = "@io_bazel_rules_scala//scala:toolchain_type", 14 | visibility = ["//visibility:public"], 15 | ) 16 | 17 | scala_library( 18 | name = "failing_build", 19 | srcs = ["A.scala"], 20 | unused_dependency_checker_mode = "error", 21 | deps = [":B"], 22 | ) 23 | 24 | scala_library( 25 | name = "toolchain_failing_build", 26 | srcs = ["A.scala"], 27 | deps = [":B"], 28 | ) 29 | 30 | scala_library( 31 | name = "toolchain_override", 32 | srcs = ["A.scala"], 33 | unused_dependency_checker_mode = "off", 34 | deps = [":B"], 35 | ) 36 | 37 | scala_library( 38 | name = "B", 39 | srcs = ["B.scala"], 40 | ) 41 | -------------------------------------------------------------------------------- /test_lint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eou pipefail 4 | 5 | ./tools/bazel run //tools:buildifier@check 6 | -------------------------------------------------------------------------------- /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/JavaBinary.java: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package scalarules.test; 16 | 17 | /** Example class */ 18 | public class JavaBinary { 19 | public static void main(String[] args) { 20 | HelloLib.printMessage("Hello"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /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/OtherJavaLib.java: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package scalarules.test; 16 | 17 | /** Example class */ 18 | public class OtherJavaLib { 19 | public static String getMessage() { 20 | return "java!"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/OtherLib.scala: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package scalarules.test 16 | 17 | // It is just to show how a Scala library can depend on another Scala library. 18 | object OtherLib { 19 | def getMessage(): String = Exported.message 20 | } 21 | -------------------------------------------------------------------------------- /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/ScalaBinary.scala: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package scalarules.test 16 | 17 | object ScalaBinary { 18 | def main(args: Array[String]) { 19 | println(MacroTest.hello(1 + 2)) 20 | HelloLib.printMessage("Hello"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /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/scala/scalarules/test/MixJavaScalaLibBinary.scala: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package scalarules.test 16 | 17 | object MixJavaScalaLibBinary { 18 | def main(args: Array[String]) { 19 | val bar = new Bar() 20 | println("created an instance of a mixed java scala code from a library") 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/ScalaLibBinary.scala: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package scalarules.test 16 | 17 | object ScalaLibBinary { 18 | def main(args:Array[String]) { 19 | ScalaLibResources.getGreetings foreach println 20 | ScalaLibResources.getFarewells foreach println 21 | ScalaLibResources.getData foreach println 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/junit/JunitTests.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.junit 2 | 3 | import org.junit.Test 4 | import org.hamcrest.CoreMatchers._ 5 | import org.hamcrest.MatcherAssert._ 6 | import scalarules.test.junit.support.JUnitCompileTimeDep 7 | import java.lang.management.ManagementFactory 8 | import java.lang.management.RuntimeMXBean 9 | 10 | class JunitWithDepsTest { 11 | 12 | @Test 13 | def hasCompileTimeDependencies: Unit = { 14 | println(JUnitCompileTimeDep.hello) 15 | } 16 | 17 | @Test 18 | def hasRuntimeDependencies: Unit = { 19 | Class.forName("scalarules.test.junit.support.JUnitRuntimeDep") 20 | } 21 | 22 | @Test 23 | def supportsCustomJVMArgs: Unit = { 24 | assertThat(ManagementFactory.getRuntimeMXBean().getInputArguments(), 25 | hasItem("-XX:HeapDumpPath=/some/custom/path")) 26 | } 27 | 28 | } 29 | 30 | class ClassCoveringRegressionFromTakingAllClassesInArchive 31 | -------------------------------------------------------------------------------- /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/JustScrooge1.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.twitter_scrooge 2 | 3 | import scalarules.test.twitter_scrooge.thrift.Struct1 4 | import scalarules.test.twitter_scrooge.thrift.thrift2.Struct2A 5 | import scalarules.test.twitter_scrooge.thrift.thrift2.Struct2B 6 | import scalarules.test.twitter_scrooge.thrift.thrift2.thrift3.Struct3 7 | 8 | object JustScrooge1 { 9 | val classes = Seq(classOf[Struct1], classOf[Struct2A], classOf[Struct2B], classOf[Struct3]) 10 | 11 | def main(args: Array[String]) { 12 | print(s"classes ${classes.mkString(",")}") 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /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/Mixed.scala: -------------------------------------------------------------------------------- 1 | package scalarules.test.twitter_scrooge 2 | 3 | import scalarules.test.twitter_scrooge.thrift.Struct1 4 | import scalarules.test.twitter_scrooge.thrift.thrift2.Struct2A 5 | import scalarules.test.twitter_scrooge.thrift.thrift2.Struct2B 6 | import scalarules.test.twitter_scrooge.thrift.thrift2.thrift3.Struct3 7 | 8 | object Mixed { 9 | val classes = 10 | Seq( 11 | classOf[Struct1], 12 | classOf[Struct2A], 13 | classOf[Struct2B], 14 | classOf[Struct3], 15 | JustScrooge1.getClass, 16 | JustScrooge2a.getClass, 17 | JustScrooge2b.getClass, 18 | JustScrooge3.getClass 19 | ) 20 | } 21 | -------------------------------------------------------------------------------- /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/a/b/c/d/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_scala//thrift:thrift.bzl", "thrift_library") 2 | load("@io_bazel_rules_scala//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_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/prefix_test/e/f/b/c/d/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_scala//thrift:thrift.bzl", "thrift_library") 2 | load("@io_bazel_rules_scala//twitter_scrooge:twitter_scrooge.bzl", "scrooge_scala_library") 3 | 4 | thrift_library( 5 | name = "b_thrift", 6 | srcs = ["B.thrift"], 7 | absolute_prefixes = [ 8 | "prefix_test/a", 9 | "prefix_test/e/f", 10 | ], 11 | visibility = ["//visibility:public"], 12 | deps = ["//src/main/scala/scalarules/test/twitter_scrooge/prefix_test/a/b/c/d:a_thrift"], 13 | ) 14 | 15 | scrooge_scala_library( 16 | name = "d", 17 | visibility = ["//visibility:public"], 18 | exports = [ 19 | "//src/main/scala/scalarules/test/twitter_scrooge/prefix_test/a/b/c/d", 20 | ], 21 | deps = [ 22 | ":b_thrift", 23 | ], 24 | ) 25 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_scala//thrift:thrift.bzl", "thrift_library") 2 | 3 | thrift_library( 4 | name = "thrift", 5 | srcs = ["Thrift1.thrift"], 6 | visibility = ["//visibility:public"], 7 | deps = [ 8 | "//src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2:thrift2_a", 9 | "//src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2:thrift2_b", 10 | ], 11 | ) 12 | 13 | thrift_library( 14 | name = "thrift_many", 15 | srcs = [ 16 | "ThriftMany1.thrift", 17 | "ThriftMany2.thrift", 18 | ], 19 | visibility = ["//visibility:public"], 20 | ) 21 | -------------------------------------------------------------------------------- /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/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_import") 2 | load("@io_bazel_rules_scala//thrift:thrift.bzl", "thrift_library") 3 | 4 | java_import( 5 | name = "barejar", 6 | jars = ["bare-thrift.jar"], 7 | visibility = ["//visibility:public"], 8 | ) 9 | 10 | thrift_library( 11 | name = "bare_jar_thrifts", 12 | external_jars = [ 13 | ":barejar", 14 | ], 15 | visibility = ["//visibility:public"], 16 | deps = [ 17 | "//src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_1", 18 | "//src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_2", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /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-thrift.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare-thrift.jar -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_1/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_scala//thrift:thrift.bzl", "thrift_library") 2 | 3 | thrift_library( 4 | name = "bare_jar_1", 5 | external_jars = [ 6 | "bare-thrift-1.jar", 7 | ], 8 | visibility = ["//visibility:public"], 9 | ) 10 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_1/bare-thrift-1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_1/bare-thrift-1.jar -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_2/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_scala//thrift:thrift.bzl", "thrift_library") 2 | 3 | thrift_library( 4 | name = "bare_jar_2", 5 | external_jars = [ 6 | "bare-thrift-2.jar", 7 | ], 8 | visibility = ["//visibility:public"], 9 | ) 10 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_2/bare-thrift-2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_2/bare-thrift-2.jar -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_scala//thrift:thrift.bzl", "thrift_library") 2 | 3 | thrift_library( 4 | name = "thrift2_a", 5 | srcs = ["Thrift2_A.thrift"], 6 | visibility = ["//visibility:public"], 7 | deps = ["//src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/thrift3"], 8 | ) 9 | 10 | thrift_library( 11 | name = "thrift2_b", 12 | srcs = ["Thrift2_B.thrift"], 13 | visibility = ["//visibility:public"], 14 | deps = ["//src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/thrift3"], 15 | ) 16 | 17 | thrift_library( 18 | name = "thrift2_b_imp", 19 | srcs = ["Thrift2_B.thrift"], 20 | visibility = ["//visibility:public"], 21 | deps = ["//src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/thrift3:thrift3_import"], 22 | ) 23 | -------------------------------------------------------------------------------- /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/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_scala//thrift:thrift.bzl", "thrift_library") 2 | load("@io_bazel_rules_scala//twitter_scrooge:twitter_scrooge.bzl", "scrooge_scala_import") 3 | 4 | thrift_library( 5 | name = "thrift3", 6 | srcs = ["Thrift3.thrift"], 7 | visibility = ["//visibility:public"], 8 | ) 9 | 10 | scrooge_scala_import( 11 | name = "thrift3_import", 12 | scala_jars = ["thrift3_scrooge.jar"], 13 | thrift_jars = ["libthrift3.jar"], 14 | visibility = ["//visibility:public"], 15 | ) 16 | -------------------------------------------------------------------------------- /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/thrift3/thrift3_scrooge.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/thrift3/thrift3_scrooge.jar -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/thrift4/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_scala//thrift:thrift.bzl", "thrift_library") 2 | 3 | thrift_library( 4 | name = "thrift4", 5 | srcs = ["Thrift4.thrift"], 6 | visibility = ["//visibility:public"], 7 | deps = [ 8 | "//src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2:thrift2_a", 9 | ], 10 | ) 11 | 12 | thrift_library( 13 | name = "thrift4a", 14 | srcs = ["Thrift4a.thrift"], 15 | visibility = ["//visibility:public"], 16 | deps = [ 17 | ":thrift4", 18 | "//src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2:thrift2_a", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/tut/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_scala//tut_rule:tut.bzl", "scala_tut_doc") 2 | load("@io_bazel_rules_scala//scala:scala.bzl", "scala_library") 3 | 4 | scala_library( 5 | name = "test_dep", 6 | srcs = ["TestDep.scala"], 7 | ) 8 | 9 | #TODO - uncomment once tut repo flakiness is resolved 10 | #scala_tut_doc( 11 | # name = "some_example", 12 | # src = "SomeExample.md", 13 | # deps = [":test_dep"], 14 | #) 15 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/tut/SomeExample.md: -------------------------------------------------------------------------------- 1 | # This is markdown 2 | 3 | ``` 4 | With some stuff 5 | ``` 6 | 7 | ```tut 8 | List(1, 2, 3).sum 9 | 10 | import foo.Bar 11 | Bar.values 12 | ``` 13 | -------------------------------------------------------------------------------- /test_version/version_specific_tests_dir/tut/TestDep.scala: -------------------------------------------------------------------------------- 1 | package foo 2 | 3 | object Bar { 4 | def values: List[Int] = List(2, 3, 5, 7) 5 | } 6 | -------------------------------------------------------------------------------- /third_party/README.md: -------------------------------------------------------------------------------- 1 | This file lists license and version information of all code we did not author 2 | 3 | # dependency_analyzer 4 | dependency_analyzer scala compiler plugin is based on [classpath-shrinker](https://github.com/scalacenter/classpath-shrinker) plugin. 5 | License: 3-clause revised BSD -------------------------------------------------------------------------------- /third_party/bazel/src/main/protobuf/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_proto_library") 2 | load("@rules_proto//proto:defs.bzl", "proto_library") 3 | 4 | licenses(["notice"]) 5 | 6 | package(default_visibility = ["//visibility:public"]) 7 | 8 | FILES = [ 9 | "worker_protocol", 10 | ] 11 | 12 | [proto_library( 13 | name = s + "_proto", 14 | srcs = [s + ".proto"], 15 | ) for s in FILES] 16 | 17 | [java_proto_library( 18 | name = s + "_java_proto", 19 | deps = [":" + s + "_proto"], 20 | ) for s in FILES] 21 | -------------------------------------------------------------------------------- /third_party/dependency_analyzer/src/main/resources/scalac-plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | dependency-analyzer 3 | third_party.dependency_analyzer.src.main.io.bazel.rulesscala.dependencyanalyzer.DependencyAnalyzer 4 | -------------------------------------------------------------------------------- /third_party/test/new_local_repo/resource.txt: -------------------------------------------------------------------------------- 1 | A resource 2 | -------------------------------------------------------------------------------- /third_party/test/strip_resource_external_workspace/WORKSPACE: -------------------------------------------------------------------------------- 1 | workspace(name = "strip_resource_external_workspace") 2 | -------------------------------------------------------------------------------- /third_party/test/strip_resource_external_workspace/strip/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_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/strip_resource_external_workspace/strip/nosrc_jar_resource.txt: -------------------------------------------------------------------------------- 1 | I am a text resource! 2 | -------------------------------------------------------------------------------- /third_party/utils/src/test/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) # 3-clause BSD 2 | 3 | load("//scala:scala.bzl", "scala_library") 4 | 5 | scala_library( 6 | name = "test_util", 7 | srcs = [ 8 | "io/bazel/rulesscala/utils/JavaCompileUtil.scala", 9 | "io/bazel/rulesscala/utils/TestUtil.scala", 10 | ], 11 | visibility = ["//visibility:public"], 12 | deps = [ 13 | "//external:io_bazel_rules_scala/dependency/scala/scala_compiler", 14 | "//external:io_bazel_rules_scala/dependency/scala/scala_reflect", 15 | "//third_party/dependency_analyzer/src/main:dependency_analyzer", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /thrift/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/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/BUILD: -------------------------------------------------------------------------------- 1 | load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier") 2 | 3 | [ 4 | buildifier( 5 | name = "buildifier@%s" % mode, 6 | mode = mode, 7 | ) 8 | for mode in [ 9 | "check", 10 | "diff", 11 | "fix", 12 | "print_if_changed", 13 | ] 14 | ] 15 | -------------------------------------------------------------------------------- /tools/bazel.rc.buildkite: -------------------------------------------------------------------------------- 1 | build --strategy=Scalac=worker --strategy=ScroogeRule=worker --worker_max_instances=3 2 | -------------------------------------------------------------------------------- /tut_rule/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/tut_rule/BUILD -------------------------------------------------------------------------------- /twitter_scrooge/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teslamotors/rules_scala/634ea5a68080778c4f88c80f47afa653f0e9f181/twitter_scrooge/BUILD --------------------------------------------------------------------------------