1
1
load (
2
- "@bazel_tools//tools/build_defs/repo:jvm .bzl" ,
3
- "jvm_maven_import_external " ,
2
+ "@bazel_tools//tools/build_defs/repo:http .bzl" ,
3
+ "http_jar " ,
4
4
)
5
5
6
6
def _jar_jar_impl (ctx ):
@@ -16,12 +16,18 @@ def _jar_jar_impl(ctx):
16
16
content = "\n " .join (ctx .attr .inline_rules )
17
17
)
18
18
19
+ args = ctx .actions .args ()
20
+ args .add ("process" )
21
+ args .add (rule_file )
22
+ args .add (ctx .file .input_jar )
23
+ args .add (ctx .outputs .jar )
24
+
19
25
ctx .actions .run (
20
26
inputs = [rule_file , ctx .file .input_jar ],
21
27
outputs = [ctx .outputs .jar ],
22
28
executable = ctx .executable ._jarjar_runner ,
23
29
progress_message = "jarjar %s" % ctx .label ,
24
- arguments = ["process" , rule_file . path , ctx . file . input_jar . path , ctx . outputs . jar . path ],
30
+ arguments = [args ],
25
31
)
26
32
27
33
return [
@@ -38,41 +44,31 @@ jar_jar = rule(
38
44
"input_jar" : attr .label (allow_single_file = True ),
39
45
"rules" : attr .label (allow_single_file = True ),
40
46
"inline_rules" : attr .string_list (),
41
- "_jarjar_runner" : attr .label (executable = True , cfg = "host " , default = Label ( "@com_github_johnynek_bazel_jar_jar //src/main/java/com/github/johnynek/jarjar:app") ),
47
+ "_jarjar_runner" : attr .label (executable = True , cfg = "exec " , default = " //src/main/java/com/github/johnynek/jarjar:app" ),
42
48
},
43
49
outputs = {
44
50
"jar" : "%{name}.jar" ,
45
51
},
46
52
provides = [JavaInfo ],
47
53
)
48
54
49
- def _mvn_name (coord ):
50
- nocolon = "_" .join (coord .split (":" ))
51
- nodot = "_" .join (nocolon .split ("." ))
52
- nodash = "_" .join (nodot .split ("-" ))
53
- return nodash
54
-
55
- def _mvn_jar (coord , sha , bname , servers ):
56
- nm = "jar_jar_" + _mvn_name (coord )
57
- jvm_maven_import_external (
58
- name = nm ,
59
- artifact = coord ,
60
- server_urls = servers ,
61
- artifact_sha256 = sha ,
62
- licenses = [],
55
+ def _http_jar_with_servers (name , path , sha256 , servers ):
56
+ http_jar (
57
+ name = name ,
58
+ urls = [server + path for server in servers ],
59
+ sha256 = sha256 ,
63
60
)
64
- native .bind (name = ("com_github_johnynek_bazel_jar_jar/%s" % bname ), actual = "@%s//jar" % nm )
65
61
66
- def jar_jar_repositories (servers = ["https://repo1.maven.org/maven2" ]):
67
- _mvn_jar (
68
- "org.ow2.asm:asm:7.0 " ,
69
- "b88ef66468b3c978ad0c97fd6e90979e56155b4ac69089ba7a44e9aa7ffe9acf " ,
70
- "asm " ,
71
- servers ,
62
+ def jar_jar_repositories (servers = ["https://repo1.maven.org/maven2" ]):
63
+ _http_jar_with_servers (
64
+ name = "bazel_jar_jar_asm " ,
65
+ path = "/org/ow2/asm/asm/7.0/asm-7.0.jar " ,
66
+ sha256 = "b88ef66468b3c978ad0c97fd6e90979e56155b4ac69089ba7a44e9aa7ffe9acf " ,
67
+ servers = servers ,
72
68
)
73
- _mvn_jar (
74
- "org.ow2.asm:asm-commons:7.0 " ,
75
- "fed348ef05958e3e846a3ac074a12af5f7936ef3d21ce44a62c4fa08a771927d " ,
76
- "asm_commons " ,
77
- servers ,
69
+ _http_jar_with_servers (
70
+ name = "bazel_jar_jar_asm_commons " ,
71
+ path = "/org/ow2/asm/asm-commons/7.0/asm-commons-7.0.jar " ,
72
+ sha256 = "fed348ef05958e3e846a3ac074a12af5f7936ef3d21ce44a62c4fa08a771927d " ,
73
+ servers = servers ,
78
74
)
0 commit comments