Hi,
In the context of testing the unreleased-but-merged fix in JGit for Issue 9612, I wanted to build Gerrit with it to confirm it's fixed, but I failed.
Here's what I did:
- Check out Gerrit source tree 'master', recursively. Currently on v2.15.3-4920-g8d052edb22.
- Clone JGit in another directory outside Gerrit's tree.
- Check out 'stable-5.0' branch in JGit - this should be only a few changes compared to the 5.0.2 released version as Maven dependency configured.
- As per developer documentation about Bazel and Gerrit I set LOCAL_JGIT_REPO in lib/jgit/jgit.bzl to point to my local checkout.
- Run 'bazel build gerrit' and getting different dependency errors everytime:
- $ bazel build gerrit
ERROR: /home/gert/.cache/bazel/_bazel_gert/657d7487a554575c9d983baaafc6bd5d/external/jgit/lib/BUILD:119:1: no such package '@jzlib//jar': The repository could not be resolved and referenced by '@jgit//lib:jzlib'
ERROR: Analysis of target '//:gerrit' failed; build aborted: Analysis failed
- Variations:
* ERROR: /home/gert/.cache/bazel/_bazel_gert/657d7487a554575c9d983baaafc6bd5d/external/jgit/lib/BUILD:10:1: no such package '@commons_compress//jar': The repository could not be resolved and referenced by '@jgit//lib:commons-compress'
* ERROR: /home/gert/.cache/bazel/_bazel_gert/657d7487a554575c9d983baaafc6bd5d/external/jgit/lib/BUILD:153:1: no such package '@log_api//jar': The repository could not be resolved and referenced by '@jgit//lib:slf4j-api'
This doesn't sound familiar. Seems to be a new dependency in JGit and theselines must be temporarily copied in Gerrit's own WORKSPASE file: [1], and the
documentation should be updated.
This is because we harmonized the names of external repositories in Gerrit
in this change: [2], but missed to do the same in JGit project, that why we have
this discrepancy. To rectify, you could adjust build in JGit and harmonize the
names or, alternatively, copy all transitive dependencies with old names from
JGit's WORKSPACE file in Gerrit's WORKSPACE file, e.g.: JGit: [3], Gerrit: [4].
Thanks a lot for explaining this, David! Got it to work now, I think.
On Wednesday, 29 August 2018 13:10:42 UTC+2, Gert van Dijk wrote:Thanks a lot for explaining this, David! Got it to work now, I think.While building works, it fails at runtime now.This happens when initializing a new site (regardless of version checked out in local JGit repository):Exception in thread "main" java.lang.NoSuchMethodError: java.nio.ByteBuffer.mark()Ljava/nio/ByteBuffer;
at org.eclipse.jgit.util.RawParseUtils.decodeNoFallback(RawParseUtils.java:1121)
Which java version are you using to build/run? Sound like a Java 9 (+) issue. A quick google brought up this issue:
https://jira.mongodb.org/browse/JAVA-2559
Cheers,
Markus
--
--
To unsubscribe, email
repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en
---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Can it be that you are building with Java 9 or higher and running with Java 8?
You can check the target java version by "looking" into the byte code:
$ javap -v -cp <classpath> org.eclipse.jgit.util.RawParseUtils | grep "major version"
Yes, that's correct. That's strange indeed. I cannot reproduce that problem,though. I tried on Gerrit and JGit masters with your patch: [1] applied, withJava 8 and set LOCAL_JGIT_REPO = "/home/davido/projects/jgit" and run:$ bazel build :gerritBazel version 0.17.1rc1 produced a valid gerrit.war. I was able to initializea vanilla site and run Gerrit without any issue.
Just to confirm, if you build Gerrit from master, without building JGit fromdevelopment tree, can you run Gerrit without any issue?
Except that JGit distribution was built with Maven and not with Bazel.I think it would worth to open an issue on Bazel issue tracker.
On Wednesday, 29 August 2018 20:56:10 UTC+2, David Ostrovsky wrote:Yes, that's correct. That's strange indeed. I cannot reproduce that problem,though. I tried on Gerrit and JGit masters with your patch: [1] applied, withJava 8 and set LOCAL_JGIT_REPO = "/home/davido/projects/jgit" and run:$ bazel build :gerritBazel version 0.17.1rc1 produced a valid gerrit.war. I was able to initializea vanilla site and run Gerrit without any issue.I tried Bazel 0.17-rc1 and it works now...! whoah. :)
Turned out, we are running in a known major Bazel bug: [2], that was only fixedon upcoming 0.17 release, that causes Bazel to link against JDK9. Some fewmethods added co-variants and they cannot be run on Java 9 any more. Thishas nothing to do with a way we build JGit at all. The gerrit itself is only notaffected because those problematic methods are not used in gerrit code.Now I feel better, that we understand the bug *and* the fix ;-)
--