-
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.
add plus one deps transitive mode for compilation (#698)
* add plus one deps transitive mode for compilation tries to balance between sterness of strict-deps off and strict-deps on cache issues and false positives * Update .travis.yml * move plusone provider and aspect to separate file * try 17 again after moving out provider * move configuration from `define` to attribute on toolchain * added documentation for the plusone provider * remove trailing 9
- Loading branch information
Showing
24 changed files
with
240 additions
and
37 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
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,17 @@ | ||
""" | ||
Keeps direct compile dependencies of targets. | ||
This enables targets to pass the to compiler the plus one dependencies in addition to the direct ones. | ||
For motivation of plus one see the e2e tests | ||
""" | ||
PlusOneDeps = provider( | ||
fields = { | ||
'direct_deps' : 'list of direct compile dependencies of a target', | ||
} | ||
) | ||
|
||
def _collect_plus_one_deps_aspect_impl(target, ctx): | ||
return [PlusOneDeps(direct_deps = getattr(ctx.rule.attr,'deps',[]))] | ||
|
||
collect_plus_one_deps_aspect = aspect(implementation = _collect_plus_one_deps_aspect_impl, | ||
attr_aspects = ['deps'], | ||
) |
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
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
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,25 @@ | ||
load("//scala:scala_toolchain.bzl", "scala_toolchain") | ||
scala_toolchain( | ||
name = "plus_one_deps_impl", | ||
plus_one_deps_mode = "on", | ||
visibility = ["//visibility:public"], | ||
) | ||
toolchain( | ||
name = "plus_one_deps", | ||
toolchain = "plus_one_deps_impl", | ||
toolchain_type = "@io_bazel_rules_scala//scala:toolchain_type", | ||
visibility = ["//visibility:public"], | ||
) | ||
scala_toolchain( | ||
name = "plus_one_deps_with_unused_error_impl", | ||
unused_dependency_checker_mode = "error", | ||
plus_one_deps_mode = "on", | ||
visibility = ["//visibility:public"], | ||
) | ||
toolchain( | ||
name = "plus_one_deps_with_unused_error", | ||
toolchain = "plus_one_deps_with_unused_error_impl", | ||
toolchain_type = "@io_bazel_rules_scala//scala:toolchain_type", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
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,5 @@ | ||
package scalarules.test_expect_failure.plus_one_deps.internal_deps | ||
|
||
class A { | ||
println(new B().hi) | ||
} |
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,5 @@ | ||
package scalarules.test_expect_failure.plus_one_deps.internal_deps | ||
|
||
class B extends C { | ||
def hi: String = "hi" | ||
} |
21 changes: 21 additions & 0 deletions
21
test_expect_failure/plus_one_deps/exports_deps/BUILD.bazel
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,21 @@ | ||
load("//scala:scala.bzl", "scala_library") | ||
scala_library( | ||
name = "a", | ||
srcs = ["A.scala"], | ||
deps = [":b"], | ||
) | ||
scala_library( | ||
name = "b", | ||
srcs = ["B.scala"], | ||
deps = [":c"], | ||
) | ||
scala_library( | ||
name = "c", | ||
srcs = ["C.scala"], | ||
deps = [":d"], | ||
exports = ["d"], | ||
) | ||
scala_library( | ||
name = "d", | ||
srcs = ["D.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,3 @@ | ||
package scalarules.test_expect_failure.plus_one_deps.internal_deps | ||
|
||
class C extends D |
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,5 @@ | ||
package scalarules.test_expect_failure.plus_one_deps.internal_deps | ||
|
||
class D { | ||
|
||
} |
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,6 @@ | ||
package scalarules.test_expect_failure.plus_one_deps.external_deps | ||
import org.springframework.dao.DataAccessException | ||
|
||
class A { | ||
println(classOf[DataAccessException]) | ||
} |
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 @@ | ||
load("//scala:scala.bzl", "scala_library") | ||
scala_library( | ||
name = "a", | ||
srcs = ["A.scala"], | ||
deps = ["@org_springframework_spring_tx"] | ||
|
||
) |
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,5 @@ | ||
package scalarules.test_expect_failure.plus_one_deps.internal_deps | ||
|
||
class A { | ||
println(new B().hi) | ||
} |
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,5 @@ | ||
package scalarules.test_expect_failure.plus_one_deps.internal_deps | ||
|
||
class B extends C { | ||
def hi: String = "hi" | ||
} |
15 changes: 15 additions & 0 deletions
15
test_expect_failure/plus_one_deps/internal_deps/BUILD.bazel
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,15 @@ | ||
load("//scala:scala.bzl", "scala_library") | ||
scala_library( | ||
name = "a", | ||
srcs = ["A.scala"], | ||
deps = [":b"], | ||
) | ||
scala_library( | ||
name = "b", | ||
srcs = ["B.scala"], | ||
deps = [":c"], | ||
) | ||
scala_library( | ||
name = "c", | ||
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,3 @@ | ||
package scalarules.test_expect_failure.plus_one_deps.internal_deps | ||
|
||
class C |
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,5 @@ | ||
package scalarules.test_expect_failure.plus_one_deps.with_unused_deps | ||
|
||
class A { | ||
println(new B().hi) | ||
} |
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 scalarules.test_expect_failure.plus_one_deps.with_unused_deps | ||
|
||
class B { | ||
def hi: String = { | ||
println(classOf[C]) | ||
"hi" | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
test_expect_failure/plus_one_deps/with_unused_deps/BUILD.bazel
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,15 @@ | ||
load("//scala:scala.bzl", "scala_library") | ||
scala_library( | ||
name = "a", | ||
srcs = ["A.scala"], | ||
deps = [":b",":c"], | ||
) | ||
scala_library( | ||
name = "b", | ||
srcs = ["B.scala"], | ||
deps = [":c"], | ||
) | ||
scala_library( | ||
name = "c", | ||
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,3 @@ | ||
package scalarules.test_expect_failure.plus_one_deps.with_unused_deps | ||
|
||
class C |
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
Oops, something went wrong.