1

I'm trying to do with bazel build, this is java maven project, how can I know which external dependencies and include it in workspace file to a bazel build?

there is a migration--tooling: https://github.com/bazelbuild/migration-tooling, what is the maven_project path as following? I tried it as document guidance and can not create generate_workspace.bzl file

bazel run //generate_workspace -- --maven_project=/path/to/maven/project

this is build output:

jias-mbp:migration-tooling me$ bazel run //generate_workspace -- --maven_project=/Users/me/fe/testbazel/guava-master/guava
INFO: Analysed target //generate_workspace:generate_workspace (0 packages loaded).
INFO: Found 1 target...
Target //generate_workspace:generate_workspace up-to-date:
  bazel-bin/generate_workspace/generate_workspace.jar
  bazel-bin/generate_workspace/generate_workspace
INFO: Elapsed time: 0.325s, Critical Path: 0.01s
INFO: Build completed successfully, 1 total action

INFO: Running command line: bazel-bin/generate_workspace/generate_workspace '--maven_project=/Users/me/fe/testbazel/guava-master/guava'
二月 03, 2018 3:02:38 下午 com.google.devtools.build.workspace.maven.DefaultModelResolver getRawModel
警告: Unable to resolve raw Maven model from /Users/me/fe/testbazel/guava-master/guava/pom.xml: 1 problem was encountered while building the effective model for com.google.guava:guava:[unknown-version]
[FATAL] Non-resolvable parent POM for com.google.guava:guava-parent:HEAD-jre-SNAPSHOT: Could not find any repositories that knew how to resolve org.sonatype.oss:oss-parent:9 (checked ) and 'parent.relativePath' points at wrong local POM @ com.google.guava:guava-parent:HEAD-jre-SNAPSHOT, /Users/me/fe/testbazel/guava-master/pom.xml

二月 03, 2018 3:02:38 下午 com.google.devtools.build.workspace.maven.DefaultModelResolver getEffectiveModel
警告: Unable to resolve Maven model from /Users/me/fe/testbazel/guava-master/guava/pom.xml: 1 problem was encountered while building the effective model for com.google.guava:guava:[unknown-version]
[FATAL] Non-resolvable parent POM for com.google.guava:guava-parent:HEAD-jre-SNAPSHOT: Could not find any repositories that knew how to resolve org.sonatype.oss:oss-parent:9 (checked ) and 'parent.relativePath' points at wrong local POM @ com.google.guava:guava-parent:HEAD-jre-SNAPSHOT, /Users/me/fe/testbazel/guava-master/pom.xml

Wrote /private/var/tmp/_bazel_me/e6e7b644943af30a55bb6d7b73aaa3a3/execroot/__main__/bazel-out/darwin-fastbuild/bin/generate_workspace/generate_workspace.runfiles/__main__/generate_workspace.bzl
Jamesjin
  • 371
  • 2
  • 6
  • 15
  • Hi @Oleg, thanks, can you pls specify it, I am reading the doc, https://docs.bazel.build/versions/master/generate-workspace.html, but still not understand how can do it – Jamesjin Feb 02 '18 at 12:23
  • What do you mean by "tried it in my local"? `--maven_project` accepts the path to the folder of your Java project that's built with Maven. – Jin Feb 02 '18 at 19:58
  • Hi @Jin Thanks for your response, currently I am learning bazel and I will try to build with bazel with a maven project, I did step as this guide docs.bazel.build/versions/master/generate-workspace.html, can you help take a look above build output and see what is wrong? thank you – Jamesjin Feb 03 '18 at 07:12
  • @Jin . can you advise how to fix bazel build error , thanks https://stackoverflow.com/questions/48605528/bazel-build-is-not-working-on-from-maven-project – Jamesjin Feb 04 '18 at 07:21

1 Answers1

0

migration-tooling has been deprecated, please instead use rules_jvm_external to manage your Maven dependencies.

Jin
  • 12,748
  • 3
  • 36
  • 41