我正在尝试将我的Maven集成测试迁移至Bazel。在运行时,我遇到了一些问题。为了调试这些问题,我想比较Maven的"dependency:tree"和Bazel的依赖树,以避免任何额外的依赖项,或者检测是否缺少某些依赖项。
如何比较这些依赖项(Maven vs Bazel)?是否有一种获取Bazel目标依赖关系树的方法?
如何比较这些依赖项(Maven vs Bazel)?是否有一种获取Bazel目标依赖关系树的方法?
bazel query 'deps(//my:target)' --nohost_deps --noimplicit_deps
$ bazel query 'deps(//:java-maven)' --nohost_deps --noimplicit_deps
//:java-maven
//:java-maven-lib
@maven//:com_google_guava_guava
@maven//:v1/http/uk.maven.org/maven2/com/google/guava/guava/28.0-jre/guava-28.0-jre.jar
@maven//:v1/http/uk.maven.org/maven2/com/google/guava/guava/28.0-jre/guava-28.0-jre-sources.jar
@maven//:org_codehaus_mojo_animal_sniffer_annotations
@maven//:v1/http/uk.maven.org/maven2/org/codehaus/mojo/animal-sniffer-annotations/1.17/animal-sniffer-annotations-1.17.jar
@maven//:v1/http/uk.maven.org/maven2/org/codehaus/mojo/animal-sniffer-annotations/1.17/animal-sniffer-annotations-1.17-sources.jar
@maven//:org_checkerframework_checker_qual
@maven//:v1/http/uk.maven.org/maven2/org/checkerframework/checker-qual/2.8.1/checker-qual-2.8.1.jar
@maven//:v1/http/uk.maven.org/maven2/org/checkerframework/checker-qual/2.8.1/checker-qual-2.8.1-sources.jar
@maven//:com_google_j2objc_j2objc_annotations
@maven//:v1/http/uk.maven.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar
@maven//:v1/http/uk.maven.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3-sources.jar
@maven//:com_google_guava_listenablefuture
@maven//:v1/http/uk.maven.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar
@maven//:com_google_guava_failureaccess
@maven//:v1/http/uk.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar
@maven//:v1/http/uk.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1-sources.jar
@maven//:com_google_errorprone_error_prone_annotations
@maven//:v1/http/uk.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.3.2/error_prone_annotations-2.3.2.jar
@maven//:v1/http/uk.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.3.2/error_prone_annotations-2.3.2-sources.jar
@maven//:com_google_code_findbugs_jsr305
@maven//:v1/http/uk.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar
@maven//:v1/http/uk.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2-sources.jar
//:src/main/java/com/example/myproject/App.java
bazel query 'deps(//:java-maven)' --nohost_deps --noimplicit_deps --output=graph | dot -Tpng > graph.png
或者,查看 BUILD 文件的表示方式:
$ bazel query 'deps(//:java-maven)' --nohost_deps --noimplicit_deps --output=build
# /Users/jingwen/code/examples/java-maven/BUILD:9:1
java_binary(
name = "java-maven",
runtime_deps = ["//:java-maven-lib"],
main_class = "com.example.myproject.App",
)
# /Users/jingwen/code/examples/java-maven/BUILD:3:1
java_library(
name = "java-maven-lib",
deps = ["@maven//:com_google_guava_guava"],
srcs = ["//:src/main/java/com/example/myproject/App.java"],
)
# /private/var/tmp/_bazel_jingwen/877cb1057c2ab3530b2162a72552b72b/external/maven/BUILD:44:1
jvm_import(
name = "com_google_guava_guava",
tags = ["maven_coordinates=com.google.guava:guava:28.0-jre"],
jars = ["@maven//:v1/http/uk.maven.org/maven2/com/google/guava/guava/28.0-jre/guava-28.0-jre.jar"],
srcjar = "@maven//:v1/http/uk.maven.org/maven2/com/google/guava/guava/28.0-jre/guava-28.0-jre-sources.jar",
deps = ["@maven//:com_google_guava_listenablefuture", "@maven//:com_google_j2objc_j2objc_annotations", "@maven//:com_google_code_findbugs_jsr305", "@maven//:org_checkerframework_checker_qual", "@maven//:org_codehaus_mojo_animal_sniffer_annotations", "@maven//:com_google_guava_failureaccess", "@maven//:com_google_errorprone_error_prone_annotations"],
)
# /private/var/tmp/_bazel_jingwen/877cb1057c2ab3530b2162a72552b72b/external/maven/BUILD:111:1
jvm_import(
name = "org_codehaus_mojo_animal_sniffer_annotations",
tags = ["maven_coordinates=org.codehaus.mojo:animal-sniffer-annotations:1.17"],
jars = ["@maven//:v1/http/uk.maven.org/maven2/org/codehaus/mojo/animal-sniffer-annotations/1.17/animal-sniffer-annotations-1.17.jar"],
srcjar = "@maven//:v1/http/uk.maven.org/maven2/org/codehaus/mojo/animal-sniffer-annotations/1.17/animal-sniffer-annotations-1.17-sources.jar",
deps = [],
)
# /private/var/tmp/_bazel_jingwen/877cb1057c2ab3530b2162a72552b72b/external/maven/BUILD:99:1
jvm_import(
name = "org_checkerframework_checker_qual",
tags = ["maven_coordinates=org.checkerframework:checker-qual:2.8.1"],
jars = ["@maven//:v1/http/uk.maven.org/maven2/org/checkerframework/checker-qual/2.8.1/checker-qual-2.8.1.jar"],
srcjar = "@maven//:v1/http/uk.maven.org/maven2/org/checkerframework/checker-qual/2.8.1/checker-qual-2.8.1-sources.jar",
deps = [],
)
# /private/var/tmp/_bazel_jingwen/877cb1057c2ab3530b2162a72552b72b/external/maven/BUILD:74:1
jvm_import(
name = "com_google_j2objc_j2objc_annotations",
tags = ["maven_coordinates=com.google.j2objc:j2objc-annotations:1.3"],
jars = ["@maven//:v1/http/uk.maven.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar"],
srcjar = "@maven//:v1/http/uk.maven.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3-sources.jar",
deps = [],
)
# /private/var/tmp/_bazel_jingwen/877cb1057c2ab3530b2162a72552b72b/external/maven/BUILD:63:1
jvm_import(
name = "com_google_guava_listenablefuture",
tags = ["maven_coordinates=com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava"],
jars = ["@maven//:v1/http/uk.maven.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar"],
deps = [],
)
# /private/var/tmp/_bazel_jingwen/877cb1057c2ab3530b2162a72552b72b/external/maven/BUILD:32:1
jvm_import(
name = "com_google_guava_failureaccess",
tags = ["maven_coordinates=com.google.guava:failureaccess:1.0.1"],
jars = ["@maven//:v1/http/uk.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar"],
srcjar = "@maven//:v1/http/uk.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1-sources.jar",
deps = [],
)
# /private/var/tmp/_bazel_jingwen/877cb1057c2ab3530b2162a72552b72b/external/maven/BUILD:20:1
jvm_import(
name = "com_google_errorprone_error_prone_annotations",
tags = ["maven_coordinates=com.google.errorprone:error_prone_annotations:2.3.2"],
jars = ["@maven//:v1/http/uk.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.3.2/error_prone_annotations-2.3.2.jar"],
srcjar = "@maven//:v1/http/uk.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.3.2/error_prone_annotations-2.3.2-sources.jar",
deps = [],
)
# /private/var/tmp/_bazel_jingwen/877cb1057c2ab3530b2162a72552b72b/external/maven/BUILD:8:1
jvm_import(
name = "com_google_code_findbugs_jsr305",
tags = ["maven_coordinates=com.google.code.findbugs:jsr305:3.0.2"],
jars = ["@maven//:v1/http/uk.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar"],
srcjar = "@maven//:v1/http/uk.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2-sources.jar",
deps = [],
)
想要了解更多,请查看Bazel查询指南页面。