-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't allow transitive scala_library dependencies onto the classpath
Without this patch, scala and java "deps of deps" end up on the classpath. This isn't the way java_library rules work: A rule X can access the code in Y if there exists a dependency path between them that begins with a deps edge followed by zero or more exports edges. I verified my understanding of this behavior with a small test repo, copying one of the tests from this repo and changing 'scala_' to 'java_': https://gist.github.com/colinmarc/c683652ef9a7d817c5e7ce9ca1236a6d This patch fixes that, and all the tests that were incorrectly depending on the behavior. It also adds some negative tests for the behavior, under `test_transitive_deps`. Unfortunately, this is going to be majorly backwards incompatible with existing scala repositories.
- Loading branch information
Showing
23 changed files
with
189 additions
and
67 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 |
---|---|---|
|
@@ -4,4 +4,4 @@ object A { | |
def main(args: Array[String]) { | ||
println("4 8 15 16 23 42") | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -4,4 +4,4 @@ object D { | |
def main(args: Array[String]) { | ||
A.main(args) | ||
} | ||
} | ||
} |
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
5 changes: 0 additions & 5 deletions
5
test/src/main/scala/scala/test/disappearing_class/ClassProvider.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 |
---|---|---|
@@ -1,8 +1,3 @@ | ||
package scala.test | ||
|
||
object ClassProvider { | ||
def dissappearingClassMethod: String = "testContents" | ||
} | ||
|
||
|
||
object BackgroundNoise{} |
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
File renamed without changes.
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 scala.test | ||
|
||
object ClassProvider { | ||
def dissappearingClassMethod: String = "testContents" | ||
} | ||
|
||
|
||
object BackgroundNoise{} |
File renamed without changes.
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 example | ||
|
||
object A { | ||
def foo { | ||
println("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,24 @@ | ||
load("//scala:scala.bzl", "scala_library", "scala_export_to_java") | ||
|
||
scala_library( | ||
name = "a", | ||
srcs = ["A.scala"] | ||
) | ||
|
||
scala_export_to_java( | ||
name = "b", | ||
exports = [":a"], | ||
runtime_deps = [] | ||
) | ||
|
||
java_library( | ||
name = "c", | ||
srcs = ["C.java"], | ||
deps = [":b"], | ||
) | ||
|
||
java_library( | ||
name = "d", | ||
srcs = ["D.java"], | ||
deps = [":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,3 @@ | ||
package example; | ||
|
||
public 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,7 @@ | ||
package example; | ||
|
||
public class D { | ||
public static void main(String[] args) { | ||
A.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 example; | ||
|
||
public class A { | ||
public static void foo() { | ||
System.out.println("yeah?"); | ||
} | ||
} |
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,22 @@ | ||
load("//scala:scala.bzl", "scala_library") | ||
|
||
java_library( | ||
name = "a", | ||
srcs = ["A.java"] | ||
) | ||
|
||
scala_library( | ||
name = "b", | ||
exports = [":a"], | ||
) | ||
|
||
scala_library( | ||
name = "c", | ||
deps = [":b"], | ||
) | ||
|
||
scala_library( | ||
name = "d", | ||
deps = [":c"], | ||
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,7 @@ | ||
package example | ||
|
||
object D { | ||
def main(args: Array[String]) { | ||
A.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 example | ||
|
||
object A { | ||
def foo { | ||
println("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,22 @@ | ||
load("//scala:scala.bzl", "scala_library") | ||
|
||
scala_library( | ||
name = "a", | ||
srcs = ["A.scala"] | ||
) | ||
|
||
scala_library( | ||
name = "b", | ||
exports = [":a"], | ||
) | ||
|
||
scala_library( | ||
name = "c", | ||
deps = [":b"], | ||
) | ||
|
||
scala_library( | ||
name = "d", | ||
deps = [":c"], | ||
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,7 @@ | ||
package example | ||
|
||
object D { | ||
def main(args: Array[String]) { | ||
A.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
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