-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a scala compiler plugin to throw errors on missing direct-deps (#243
) First step (experimental) in the introduction of strict scala deps feature (see issue #235). Currently this feature is turned off (due to noticeable impact on performance) switching ‘dependency_analyzer_mode_soon_to_be_removed’ to “on” means that ANY API change in a target’s transitive dependencies will trigger a recompilation of that target, on the other hand any internal change (i.e. on code that ijar omits) WON’T trigger recompilation by transitive dependencies A few implementation details: A new scalac plugin informs the user on every target that has missing transitive dependencies that should be added as direct dependencies. For convenience a buildozer command is provided to make the change in the BUILD file easily. before the compilation, transitive compile time jars are collected along with a mapping to the originating target label.
- Loading branch information
Showing
37 changed files
with
1,089 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ bazel-* | |
*.idea | ||
hash1 | ||
hash2 | ||
.DS_store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,5 @@ Laurent Le Brun <[email protected]> | |
Nathan Harmata <[email protected]> | ||
Oscar Boykin <[email protected]> | ||
Justine Alexandra Roberts Tunney <[email protected]> | ||
Natan Silnitsky <[email protected]> | ||
Nadav Wexler <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
test/src/main/scala/scala/test/strict_deps/no_recompilation/A.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package scala.test.strict_deps.no_recompilation; | ||
|
||
object A { | ||
def foo = { | ||
B.foo | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
test/src/main/scala/scala/test/strict_deps/no_recompilation/B.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package scala.test.strict_deps.no_recompilation; | ||
|
||
object B { | ||
def foo = { | ||
C.foo | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
test/src/main/scala/scala/test/strict_deps/no_recompilation/BUILD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
load("//scala:scala.bzl", "scala_library", "scala_test", "scala_binary") | ||
|
||
scala_library( | ||
name="transitive_dependency_user", | ||
srcs=[ | ||
"A.scala", | ||
], | ||
deps = ["direct_dependency"], | ||
dependency_analyzer_mode_soon_to_be_removed="error", | ||
) | ||
|
||
scala_library( | ||
name="direct_dependency", | ||
srcs=[ | ||
"B.scala", | ||
], | ||
deps = ["transitive_dependency"], | ||
dependency_analyzer_mode_soon_to_be_removed="error", | ||
) | ||
|
||
scala_library( | ||
name="transitive_dependency", | ||
srcs=[ | ||
"C.scala", | ||
], | ||
dependency_analyzer_mode_soon_to_be_removed="error", | ||
) |
7 changes: 7 additions & 0 deletions
7
test/src/main/scala/scala/test/strict_deps/no_recompilation/C.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package scala.test.strict_deps.no_recompilation; | ||
|
||
object C { | ||
def foo = { | ||
println("orig") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package test_expect_failure.dep_analyzer_modes | ||
|
||
object A { | ||
def foo = { | ||
B.foo | ||
C.foo | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package test_expect_failure.dep_analyzer_modes | ||
|
||
object B { | ||
def foo = { | ||
C.foo | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
load("//scala:scala.bzl", "scala_library", "scala_binary", "scala_test") | ||
|
||
scala_library( | ||
name="error_mode", | ||
dependency_analyzer_mode_soon_to_be_removed="error", | ||
srcs=[ | ||
"A.scala", | ||
], | ||
deps = ["direct_dependency"], | ||
) | ||
|
||
scala_library( | ||
name="warn_mode", | ||
dependency_analyzer_mode_soon_to_be_removed="warn", | ||
srcs=[ | ||
"A.scala", | ||
], | ||
deps = ["direct_dependency"], | ||
) | ||
|
||
scala_library( | ||
name="weird_mode", | ||
dependency_analyzer_mode_soon_to_be_removed="kuki_buki", | ||
srcs=[ | ||
"A.scala", | ||
], | ||
deps = ["direct_dependency"], | ||
) | ||
|
||
scala_library( | ||
name="off_mode", | ||
dependency_analyzer_mode_soon_to_be_removed="off", | ||
srcs=[ | ||
"A.scala", | ||
], | ||
deps = ["direct_dependency"], | ||
) | ||
|
||
|
||
scala_library( | ||
name="direct_dependency", | ||
dependency_analyzer_mode_soon_to_be_removed="error", | ||
srcs=[ | ||
"B.scala", | ||
], | ||
deps = ["transitive_dependency"], | ||
) | ||
|
||
scala_library( | ||
name="transitive_dependency", | ||
dependency_analyzer_mode_soon_to_be_removed="error", | ||
srcs=[ | ||
"C.scala", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package test_expect_failure.dep_analyzer_modes | ||
|
||
object C { | ||
def foo = { | ||
println("in C") | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
test_expect_failure/missing_direct_deps/external_deps/A.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package test_expect_failure.missing_direct_deps.external_deps | ||
|
||
object A { | ||
def foo = { | ||
B.foo | ||
com.google.common.base.Strings.commonPrefix("abc", "abcd") | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
test_expect_failure/missing_direct_deps/external_deps/B.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package test_expect_failure.missing_direct_deps.external_deps | ||
|
||
object B { | ||
def foo = { | ||
println("in B") | ||
com.google.common.base.Strings.commonPrefix("abc", "abcd") | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
test_expect_failure/missing_direct_deps/external_deps/BUILD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
load("//scala:scala.bzl", "scala_library", "scala_test") | ||
|
||
scala_library( | ||
name="transitive_external_dependency_user", | ||
srcs=[ | ||
"A.scala", | ||
], | ||
deps = ["external_dependency_user"], | ||
dependency_analyzer_mode_soon_to_be_removed="error", | ||
) | ||
|
||
scala_library( | ||
name="external_dependency_user", | ||
srcs=[ | ||
"B.scala", | ||
], | ||
deps = ["@com_google_guava_guava_21_0//jar"], | ||
dependency_analyzer_mode_soon_to_be_removed="error", | ||
) |
8 changes: 8 additions & 0 deletions
8
test_expect_failure/missing_direct_deps/external_deps_file_group/A.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package test_expect_failure.missing_direct_deps.external_deps_file_group | ||
|
||
object A { | ||
def foo = { | ||
B.foo | ||
com.google.common.base.Strings.commonPrefix("abc", "abcd") | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
test_expect_failure/missing_direct_deps/external_deps_file_group/B.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package test_expect_failure.missing_direct_deps.external_deps_file_group | ||
|
||
object B { | ||
def foo = { | ||
println("in B") | ||
com.google.common.base.Strings.commonPrefix("abc", "abcd") | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
test_expect_failure/missing_direct_deps/external_deps_file_group/BUILD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
load("//scala:scala.bzl", "scala_library", "scala_test") | ||
|
||
scala_library( | ||
name="transitive_external_dependency_user", | ||
srcs=[ | ||
"A.scala", | ||
], | ||
deps = ["external_dependency_user"], | ||
dependency_analyzer_mode_soon_to_be_removed="error", | ||
) | ||
|
||
scala_library( | ||
name="external_dependency_user", | ||
srcs=[ | ||
"B.scala", | ||
], | ||
deps = ["@com_google_guava_guava_21_0//jar:file"], | ||
dependency_analyzer_mode_soon_to_be_removed="error", | ||
) |
10 changes: 10 additions & 0 deletions
10
test_expect_failure/missing_direct_deps/internal_deps/A.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package test_expect_failure.missing_direct_deps.internal_deps; | ||
|
||
object A { | ||
def foo = { | ||
B.foo | ||
C.foo | ||
} | ||
|
||
def main = foo | ||
} |
7 changes: 7 additions & 0 deletions
7
test_expect_failure/missing_direct_deps/internal_deps/B.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package test_expect_failure.missing_direct_deps.internal_deps; | ||
|
||
object B { | ||
def foo = { | ||
C.foo | ||
} | ||
} |
Oops, something went wrong.