Skip to content

Commit ae3ed99

Browse files
keithhsudhof
authored andcommitted
GitHub PR#287 Add support for bzlmod
-- 791cd96 by Keith Smiley <[email protected]>: remove bazel patch -- 3b13331 by Keith Smiley <[email protected]>: Reduce bazel patch -- a8ce72b by Keith Smiley <[email protected]>: Remove unused dep -- 85c2c14 by Keith Smiley <[email protected]>: improve patch -- 0b2166e by Keith Smiley <[email protected]>: Use bazel patch instead since it's outside of bzlmod -- 81188ed by Keith Smiley <[email protected]>: Remove lockfiles -- 42504f5 by Keith Smiley <[email protected]>: Share more config between bzlmod -- cbb00ee by Keith Smiley <[email protected]>: Make non-bzlmod work -- 89a3217 by Keith Smiley <[email protected]>: Add maven generated files -- 84258db by Keith Smiley <[email protected]>: Add MODULE.bazel -- ccadbf8 by Keith Smiley <[email protected]>: Reference buildifier_prebuilt for binaries for now -- 230a66b by Keith Smiley <[email protected]>: Ignore MODULE.bazel.lock -- aab919d by Keith Smiley <[email protected]>: Update labels for new maven repo name Closes #287 GitOrigin-RevId: b68df11 Change-Id: I63f939978a3d6fe537b34dcfae8f3144a8995ffb
1 parent d691934 commit ae3ed99

File tree

15 files changed

+272
-66
lines changed

15 files changed

+272
-66
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ bazel-*
44
*.pyc
55
.ijwb
66
/.bazelrc.user
7+
MODULE.bazel.lock

MODULE.bazel

+191
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
module(
2+
name = "copybara",
3+
version = "0",
4+
compatibility_level = 0,
5+
)
6+
7+
bazel_dep(name = "bazel_skylib", version = "1.5.0")
8+
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0")
9+
bazel_dep(name = "platforms", version = "0.0.8")
10+
bazel_dep(name = "rules_java", version = "7.5.0")
11+
bazel_dep(name = "rules_jvm_external", version = "6.0")
12+
bazel_dep(name = "rules_license", version = "0.0.8")
13+
bazel_dep(name = "rules_pkg", version = "0.10.1")
14+
bazel_dep(name = "rules_python", version = "0.31.0")
15+
16+
non_module_deps = use_extension("//:repositories.bzl", "non_module_deps")
17+
use_repo(non_module_deps, "JCommander", "io_bazel")
18+
19+
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
20+
maven.install(
21+
name = "copybara_maven",
22+
artifacts = [
23+
"org.jcommander:jcommander:2.0",
24+
"com.github.stephenc.jcip:jcip-annotations:1.0-1",
25+
"com.google.auto.service:auto-service-annotations:1.1.1",
26+
"com.google.auto.service:auto-service:1.1.1",
27+
"com.google.auto.value:auto-value-annotations:1.10.2",
28+
"com.google.auto.value:auto-value:1.10.2",
29+
"com.google.auto:auto-common:1.2.2",
30+
"com.google.code.findbugs:jsr305:3.0.2",
31+
"com.google.code.gson:gson:2.10.1",
32+
"com.google.errorprone:error_prone_type_annotations:2.20.0",
33+
"com.google.flogger:flogger-system-backend:0.7.4",
34+
"com.google.flogger:flogger:0.7.4",
35+
"com.google.flogger:google-extensions:0.7.4",
36+
"com.google.guava:failureaccess:1.0.1",
37+
"com.google.guava:guava-testlib:33.0.0-jre",
38+
"com.google.guava:guava:33.0.0-jre",
39+
"com.google.http-client:google-http-client-gson:1.43.3",
40+
"com.google.http-client:google-http-client-test:1.43.3",
41+
"com.google.http-client:google-http-client:1.43.3",
42+
"com.google.jimfs:jimfs:1.2",
43+
"com.google.re2j:re2j:1.7",
44+
"com.google.testparameterinjector:test-parameter-injector:1.8",
45+
"com.google.truth.extensions:truth-java8-extension:1.3.0",
46+
"com.google.truth:truth:1.3.0",
47+
"com.googlecode.java-diff-utils:diffutils:1.3.0",
48+
"com.ryanharter.auto.value:auto-value-gson-extension:1.3.1",
49+
"com.ryanharter.auto.value:auto-value-gson-factory:1.3.1",
50+
"com.ryanharter.auto.value:auto-value-gson-runtime:1.3.1",
51+
"com.sun.mail:javax.mail:1.5.6",
52+
"commons-codec:commons-codec:1.16.0",
53+
"junit:junit:4.13.2",
54+
"net.bytebuddy:byte-buddy-agent:1.14.5",
55+
"net.bytebuddy:byte-buddy:1.14.5",
56+
"org.apache.commons:commons-compress:1.25.0",
57+
"org.apache.tomcat:tomcat-annotations-api:8.0.5",
58+
"org.apache.velocity:velocity:1.7",
59+
"org.jsoup:jsoup:1.16.1",
60+
"org.mockito:mockito-core:4.5.1",
61+
"org.objenesis:objenesis:1.0",
62+
"org.tomlj:tomlj:1.1.1",
63+
],
64+
fail_if_repin_required = True,
65+
repositories = [
66+
"https://repo1.maven.org/maven2",
67+
"https://maven.google.com",
68+
],
69+
)
70+
use_repo(maven, "copybara_maven")
71+
72+
# Copied from bazelbuild/bazel/MODULE.bazel, has to be kept in sync
73+
# TODO(hsudhof): Vendor bazel's starlark package instead
74+
maven.install(
75+
artifacts = [
76+
"org.jcommander:jcommander:2.0",
77+
"com.github.ben-manes.caffeine:caffeine:3.0.5",
78+
"com.github.kevinstern:software-and-algorithms:1.0",
79+
"com.github.stephenc.jcip:jcip-annotations:1.0-1",
80+
"com.google.api-client:google-api-client-gson:1.35.2",
81+
"com.google.api-client:google-api-client:1.35.2",
82+
"com.google.auth:google-auth-library-credentials:1.6.0",
83+
"com.google.auth:google-auth-library-oauth2-http:1.6.0",
84+
"com.google.auto.service:auto-service-annotations:1.0.1",
85+
"com.google.auto.service:auto-service:1.0",
86+
"com.google.auto.value:auto-value-annotations:1.9",
87+
"com.google.auto.value:auto-value:1.8.2",
88+
"com.google.auto:auto-common:1.2.1",
89+
"com.google.code.findbugs:jsr305:3.0.2",
90+
"com.google.code.gson:gson:2.9.0",
91+
"com.google.code.java-allocation-instrumenter:java-allocation-instrumenter:3.3.0",
92+
"com.google.errorprone:error_prone_annotation:2.23.0",
93+
"com.google.errorprone:error_prone_annotations:2.23.0",
94+
"com.google.errorprone:error_prone_check_api:2.23.0",
95+
"com.google.errorprone:error_prone_core:2.23.0",
96+
"com.google.errorprone:error_prone_type_annotations:2.23.0",
97+
"com.google.flogger:flogger-system-backend:0.5.1",
98+
"com.google.flogger:flogger:0.5.1",
99+
"com.google.flogger:google-extensions:0.5.1",
100+
"com.google.guava:failureaccess:1.0.1",
101+
"com.google.guava:guava:33.0.0-jre",
102+
"com.google.http-client:google-http-client-gson:1.42.0",
103+
"com.google.http-client:google-http-client:1.42.0",
104+
"com.google.j2objc:j2objc-annotations:1.3",
105+
"com.google.turbine:turbine:0.5.0",
106+
"com.ryanharter.auto.value:auto-value-gson-extension:1.3.1",
107+
"com.ryanharter.auto.value:auto-value-gson-runtime:1.3.1",
108+
"com.ryanharter.auto.value:auto-value-gson-factory:1.3.1",
109+
"com.squareup:javapoet:1.12.0",
110+
"commons-collections:commons-collections:3.2.2",
111+
"commons-lang:commons-lang:2.6",
112+
"io.github.java-diff-utils:java-diff-utils:4.12",
113+
"io.grpc:grpc-api:1.48.1",
114+
"io.grpc:grpc-auth:1.48.1",
115+
"io.grpc:grpc-context:1.48.1",
116+
"io.grpc:grpc-core:1.48.1",
117+
"io.grpc:grpc-netty:1.48.1",
118+
"io.grpc:grpc-protobuf-lite:1.48.1",
119+
"io.grpc:grpc-protobuf:1.48.1",
120+
"io.grpc:grpc-stub:1.48.1",
121+
"io.netty:netty-buffer:4.1.93.Final",
122+
"io.netty:netty-codec-http2:4.1.93.Final",
123+
"io.netty:netty-codec-http:4.1.93.Final",
124+
"io.netty:netty-codec:4.1.93.Final",
125+
"io.netty:netty-common:4.1.93.Final",
126+
"io.netty:netty-handler-proxy:4.1.93.Final",
127+
"io.netty:netty-handler:4.1.93.Final",
128+
"io.netty:netty-resolver-dns:4.1.93.Final",
129+
"io.netty:netty-resolver:4.1.93.Final",
130+
"io.netty:netty-tcnative-boringssl-static:jar:linux-aarch_64:2.0.56.Final",
131+
"io.netty:netty-tcnative-boringssl-static:jar:linux-x86_64:2.0.56.Final",
132+
"io.netty:netty-tcnative-boringssl-static:jar:osx-aarch_64:2.0.56.Final",
133+
"io.netty:netty-tcnative-boringssl-static:jar:osx-x86_64:2.0.56.Final",
134+
"io.netty:netty-tcnative-boringssl-static:jar:windows-x86_64:2.0.56.Final",
135+
"io.netty:netty-tcnative-classes:2.0.56.Final",
136+
"io.netty:netty-transport-classes-epoll:4.1.93.Final",
137+
"io.netty:netty-transport-classes-kqueue:4.1.93.Final",
138+
"io.netty:netty-transport-native-epoll:jar:linux-aarch_64:4.1.93.Final",
139+
"io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.93.Final",
140+
"io.netty:netty-transport-native-kqueue:jar:osx-aarch_64:4.1.93.Final",
141+
"io.netty:netty-transport-native-kqueue:jar:osx-x86_64:4.1.93.Final",
142+
"io.netty:netty-transport-native-unix-common:4.1.93.Final",
143+
"io.netty:netty-transport-native-unix-common:jar:linux-aarch_64:4.1.93.Final",
144+
"io.netty:netty-transport-native-unix-common:jar:linux-x86_64:4.1.93.Final",
145+
"io.netty:netty-transport-native-unix-common:jar:osx-aarch_64:4.1.93.Final",
146+
"io.netty:netty-transport-native-unix-common:jar:osx-x86_64:4.1.93.Final",
147+
"io.netty:netty-transport:4.1.93.Final",
148+
"io.reactivex.rxjava3:rxjava:3.1.2",
149+
"it.unimi.dsi:fastutil:7.2.1",
150+
"javax.activation:javax.activation-api:1.2.0",
151+
"javax.annotation:javax.annotation-api:1.3.2",
152+
"javax.inject:javax.inject:1",
153+
"net.bytebuddy:byte-buddy-agent:1.14.5",
154+
"net.bytebuddy:byte-buddy:1.14.5",
155+
"org.apache.commons:commons-compress:1.20",
156+
"org.apache.commons:commons-pool2:2.8.0",
157+
"org.apache.tomcat:tomcat-annotations-api:8.0.5",
158+
"org.apache.velocity:velocity:1.7",
159+
"org.checkerframework:checker-qual:3.19.0",
160+
"org.ow2.asm:asm-analysis:9.2",
161+
"org.ow2.asm:asm-commons:9.2",
162+
"org.ow2.asm:asm-tree:9.2",
163+
"org.ow2.asm:asm-util:9.2",
164+
"org.ow2.asm:asm:9.2",
165+
"org.pcollections:pcollections:3.1.4",
166+
"org.threeten:threeten-extra:1.5.0",
167+
"org.tukaani:xz:1.9",
168+
"org.yaml:snakeyaml:1.28",
169+
"tools.profiler:async-profiler:3.0",
170+
# The following jars are for testing.
171+
# junit is not test only due to //src/java_tools/junitrunner/java/com/google/testing/junit/junit4:runner,
172+
# and hamcrest is a dependency of junit.
173+
"junit:junit:4.13.2",
174+
"org.hamcrest:hamcrest-core:1.3",
175+
],
176+
excluded_artifacts = [
177+
# org.apache.httpcomponents and org.eclipse.jgit:org.eclipse.jgit
178+
# require java.security.jgss module to be embedded in the Bazel binary.
179+
"org.apache.httpcomponents:httpclient",
180+
"org.apache.httpcomponents:httpcore",
181+
"org.eclipse.jgit:org.eclipse.jgit",
182+
# We build protobuf Java library from source, exclude protobuf jars to be safe.
183+
"com.google.protobuf:protobuf-java",
184+
"com.google.protobuf:protobuf-javalite",
185+
],
186+
repositories = [
187+
"https://repo1.maven.org/maven2",
188+
],
189+
strict_visibility = True,
190+
)
191+
use_repo(maven, "maven")

WORKSPACE

+8
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,11 @@ copybara_maven_repositories()
2525
load("//:repositories.go.bzl", "copybara_go_repositories")
2626

2727
copybara_go_repositories()
28+
29+
load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps")
30+
31+
buildifier_prebuilt_deps()
32+
33+
load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains")
34+
35+
buildifier_prebuilt_register_toolchains()

WORKSPACE.bzlmod

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# When bzlmod is enabled this makes sure nothing from the legacy WORKSPACE is loaded

java/com/google/copybara/buildozer/testing/BUILD

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ licenses(["notice"])
2121
genrule(
2222
name = "normalised_buildozer",
2323
testonly = 1,
24-
srcs = ["@buildtools//buildozer"],
24+
srcs = ["@buildifier_prebuilt//:buildozer"],
2525
outs = ["buildozer"],
2626
cmd = "cp $(SRCS) $@",
2727
)
2828

2929
genrule(
3030
name = "normalised_buildifier",
3131
testonly = 1,
32-
srcs = ["@buildtools//buildifier"],
32+
srcs = ["@buildifier_prebuilt//:buildifier"],
3333
outs = ["buildifier"],
3434
cmd = "cp $(SRCS) $@",
3535
)

javatests/com/google/copybara/format/BUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ licenses(["notice"])
2121
genrule(
2222
name = "normalised_buildifier",
2323
testonly = 1,
24-
srcs = ["@buildtools//buildifier"],
24+
srcs = ["@buildifier_prebuilt//:buildifier"],
2525
outs = ["buildifier"],
2626
cmd = "cp $(SRCS) $@",
2727
)

javatests/com/google/copybara/onboard/BUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ licenses(["notice"])
2323
genrule(
2424
name = "normalised_buildifier",
2525
testonly = 1,
26-
srcs = ["@buildtools//buildifier"],
26+
srcs = ["@buildifier_prebuilt//:buildifier"],
2727
outs = ["buildifier"],
2828
cmd = "cp $(SRCS) $@",
2929
)

repositories.bzl

+24-22
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
1616
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
1717
load("//third_party:bazel.bzl", "bazel_sha256", "bazel_version")
18-
load("//third_party:bazel_buildtools.bzl", "buildtools_sha256", "buildtools_version")
1918
load("//third_party:bazel_skylib.bzl", "skylib_sha256", "skylib_version")
2019

2120
def copybara_repositories():
@@ -39,27 +38,6 @@ def copybara_repositories():
3938
sha256 = RULES_JVM_EXTERNAL_SHA,
4039
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
4140
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
42-
patches = ["@io_bazel//third_party:rules_jvm_external_6.0.patch"],
43-
patch_args = ["-p1"],
44-
)
45-
46-
# LICENSE: The Apache Software License, Version 2.0
47-
maybe(
48-
http_archive,
49-
name = "io_bazel",
50-
sha256 = bazel_sha256,
51-
strip_prefix = "bazel-" + bazel_version,
52-
url = "https://github.com/bazelbuild/bazel/archive/" + bazel_version + ".zip",
53-
)
54-
55-
# LICENSE: The Apache Software License, Version 2.0
56-
# Buildifier and friends:
57-
maybe(
58-
http_archive,
59-
name = "buildtools",
60-
sha256 = buildtools_sha256,
61-
strip_prefix = "buildtools-" + buildtools_version,
62-
url = "https://github.com/bazelbuild/buildtools/archive/" + buildtools_version + ".zip",
6341
)
6442

6543
# LICENSE: The Apache Software License, Version 2.0
@@ -173,3 +151,27 @@ def copybara_repositories():
173151
],
174152
)
175153

154+
# LICENSE: MIT
155+
maybe(
156+
http_archive,
157+
name = "buildifier_prebuilt",
158+
sha256 = "8ada9d88e51ebf5a1fdff37d75ed41d51f5e677cdbeafb0a22dda54747d6e07e",
159+
strip_prefix = "buildifier-prebuilt-6.4.0",
160+
urls = [
161+
"http://github.com/keith/buildifier-prebuilt/archive/6.4.0.tar.gz",
162+
],
163+
)
164+
165+
_non_module_deps(None)
166+
167+
def _non_module_deps(_):
168+
# LICENSE: The Apache Software License, Version 2.0
169+
maybe(
170+
http_archive,
171+
name = "io_bazel",
172+
sha256 = bazel_sha256,
173+
strip_prefix = "bazel-" + bazel_version,
174+
url = "https://github.com/bazelbuild/bazel/archive/" + bazel_version + ".zip",
175+
)
176+
177+
non_module_deps = module_extension(implementation = _non_module_deps)

repositories.go.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
1516
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
1617
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
17-
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
1818

1919
def copybara_go_repositories():
2020
go_rules_dependencies()

repositories.maven.bzl

+9-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
load("@rules_jvm_external//:defs.bzl", "DEFAULT_REPOSITORY_NAME", "maven_install")
16-
load("@rules_jvm_external//:specs.bzl", "maven")
1715
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
16+
load("@rules_jvm_external//:defs.bzl", "maven_install")
17+
load("@rules_jvm_external//:specs.bzl", "maven")
1818

1919
COPYBARA_MAVEN_ARTIFACTS = [
2020
maven.artifact("com.github.stephenc.jcip", "jcip-annotations", "1.0-1"),
@@ -66,7 +66,13 @@ COPYBARA_MAVEN_ARTIFACT_ADDITIONAL_REPOSITORIES = [
6666
def copybara_maven_repositories():
6767
maybe(
6868
maven_install,
69-
name = DEFAULT_REPOSITORY_NAME,
69+
name = "copybara_maven",
70+
artifacts = COPYBARA_MAVEN_ARTIFACTS,
71+
repositories = COPYBARA_MAVEN_ARTIFACT_ADDITIONAL_REPOSITORIES + ["https://repo1.maven.org/maven2"],
72+
)
73+
maybe(
74+
maven_install,
75+
name = "maven",
7076
artifacts = COPYBARA_MAVEN_ARTIFACTS,
7177
repositories = COPYBARA_MAVEN_ARTIFACT_ADDITIONAL_REPOSITORIES + ["https://repo1.maven.org/maven2"],
7278
)

0 commit comments

Comments
 (0)