-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exclude omitted deps in generated BUILD and rules.bzl (#13)
* Fixes bug(s) related to the omit attribute. * Drops antiquated local_maven_rules_repository * Include 0.6.1 in travis matrix Fixes #12
- Loading branch information
Showing
10 changed files
with
130 additions
and
89 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
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 was deleted.
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
genquery( | ||
name = "genson_compile_deps", | ||
expression = "deps(@genson//:compile)", | ||
scope = ["@genson//:compile"], | ||
) | ||
|
||
py_test( | ||
name = "test_omit", | ||
srcs = ["test_omit.py"], | ||
size = "small", | ||
data = [":genson_compile_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# | ||
# See https://github.com/pubref/rules_maven/issues/12 | ||
# Scala example by @BlueDragonX | ||
# | ||
|
||
local_repository( | ||
name = "org_pubref_rules_maven", | ||
path = "../../", | ||
) | ||
|
||
load("@org_pubref_rules_maven//maven:rules.bzl", "maven_repositories", "maven_repository") | ||
maven_repositories() | ||
|
||
scala_version = "2.11" | ||
|
||
maven_repository( | ||
name = "genson", | ||
# Omit can take two forms: either the specific name of the | ||
# workspace, or some substring of the artifact maven coodinate. | ||
# Either form should work to exclude the dependency. NOTE: the | ||
# transitive dependency is still printed in the transitive deps | ||
# but has the token 'omit' rather than the sha1 value. | ||
omit = [ | ||
# workspace name variety | ||
'org_scala_lang_scala_library', | ||
# artifact group:name variety | ||
'org.scala-lang:scala-reflect', | ||
], | ||
deps = [ | ||
"com.owlike:genson-scala_%s:1.4" % scala_version, | ||
], | ||
transitive_deps = [ | ||
'8d6f7ee301653b6a221483663cf1c72a52967c8a:com.owlike:genson:1.4', | ||
'6309a5ca43d54eb9cbfe1776909f40c1d4c23503:com.owlike:genson-scala_2.11:1.4', | ||
'omit:org.scala-lang:scala-library:2.11.0', | ||
'omit:org.scala-lang:scala-reflect:2.11.0', | ||
], | ||
) | ||
load("@genson//:rules.bzl", "genson_compile") | ||
genson_compile() |
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 @@ | ||
# test_omit.py: Loop through the text file generated by the genquery | ||
# rule that lists the deps of @genson//:compile. Make sure all | ||
# whitelisted deps are present and all blacklisted deps are absent. | ||
|
||
white = [ | ||
"@com_owlike_genson//jar:jar", | ||
"@com_owlike_genson_scala_2_11//jar:jar", | ||
] | ||
|
||
black = [ | ||
"@org_scala_lang_scala_library//jar:jar", | ||
"@org_scala_lang_scala_reflect//jar:jar", | ||
] | ||
|
||
with open('genson_compile_deps') as f: | ||
lines = [line for line in f.read().splitlines()] | ||
deps = set(lines) | ||
if not set(white).issubset(deps): | ||
raise ValueError("One or more deps were expected to be present but not found in deps list: %s" % white) | ||
if not deps.isdisjoint(set(black)): | ||
raise ValueError("One or more deps were expected to be absent, but *were* present in deps list: %s" % black) | ||
|
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