Some plugins, most notably owners-plugin, depend on prolog:common rule.
Given that this rule transitively depends on gerrit-server:server rule,
and this rule depends on virtually whole gerrit build graph, the final
plugin artifact contains effectively the whole gerrit war file content.
To fix that we expose prolog:common in plugin API. Moreover, adjust
prolog_cafe_library to not transitively depend on prolog runtime
library. We can do it, because gerrit-server already depends on it, so
that it's included in gerrit war anyway.
This change allows the owners-plugin to de-duplicate its size from 45 MB
to 1.5 MB only.
Change-Id: I8d7198a911c2da444c1822509988eda7d369af77
genrule2 exposes root and temp directpries, but these are not used in
this rule, so that we can just use native genrule.
Change-Id: Id1e56ba47bf04a73559ff84a7c8f69745a6b3129
FileInputStream and FileOutputStream rely on finalize() method to ensure
resources are closed. This implies they are added to the finalizer queue
which causes additional work for the JVM GC process.
This is an open bug on the OpenJDK [1] and the recommended workaround is
to use the Files.newInputStream and Files.newOutputStream static methods
instead.
[1] https://bugs.openjdk.java.net/browse/JDK-8080225
Change-Id: I3cef6fcf198dde2be7cd15bded8d2fa247177654
Having a standard tool for formatting saves reviewers' valuable time.
google-java-format is Google's standard formatter and is somewhat
inspired by gofmt[1]. This commit formats everything using
google-java-format version 1.2.
The downside of this one-off formatting is breaking blame. This can be
somewhat hacked around with a tool like git-hyper-blame[2], but it's
definitely not optimal until/unless this kind of feature makes its way
to git core.
Not in this change:
* Tool support, e.g. Eclipse. The command must be run manually [3].
* Documentation of best practice, e.g. new 100-column default.
[1] https://talks.golang.org/2015/gofmt-en.slide#3
[2] https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-hyper-blame.html
[3] git ls-files | grep java$ | xargs google-java-format -i
Change-Id: Id5f3c6de95ce0b68b41f0a478b5c99a93675aaa3
Signed-off-by: David Pursehouse <dpursehouse@collab.net>
Reformat the Bazel build files with the buildifier tool [1].
The style is different for Bazel files. Most notably, indentation level
is 4 spaces instead of 2, and " is used instead of '.
[1] https://github.com/bazelbuild/buildifier
Change-Id: I95c0c6f11b6d76572797853b4ebb5cee5ebd3c98
The prolog compiler tries to be transactional by renaming a temp file to
its final destination. This only works if $TMP is on the same file
system as the final output.
Change-Id: I3b3d261d61ace2798fca96d849bce9f2bbd46bcd
To run the tests:
bazel test //...
To build the Gerrit plugin API, run:
bazel build gerrit-plugin-api:plugin-api_deploy.jar
To build the Gerrit extension API, run:
bazel build gerrit-extension-api:extension-api_deploy.jar
TODOs:
Licenses
Reduce visibility (all public for now)
Generate HTML Documentation
Core plugins
gerrit_plugin() rule to build plugins in tree and standalone modes
GWT UI (only gwt_module() skylark rule is provided, no gwt_binary())
PolyGerrit UI
WAR
Publish artifacts to Maven Central
Ask Bazel team to add Gerrit to their CI on ci.bazel.io
Contributed-By: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I9a86e670882a44a5c966579cdeb8ed79b1590de3
Since [1] dependencies to targets used in $(location //path/to:target)
macro are added implicitly.
Similar build rules simplification was applied in I6c8ddb40ef and in
Id98257e111.
[1] https://github.com/facebook/buck/issues/128
Change-Id: Ife9717f37a9cdf55358da61b7e9df26fdf23c501
Reduces the default Trail size from 20,000 to 100 and
changes it to grow exponentially rather than linearly.
This should reduce the amount of garbage created during
rule execution as Trail will better fit the working set.
Change-Id: Ia240ecd0db00aa8a2952f107f8259742575fd700
File.list() can return null, so it's unsafe to use it as an iterator
in a for-loop.
Store the result of File.list() first and only iterate it when it's
not null.
Change-Id: I0ced67e5bb5bc588433cb6a03a6283f9b31cb649
Prolog Cafe is now built with Buck and has a slightly smaller
runtime. Many features not required for Gerrit Code Review were
stripped out of the fork.
Package names were reorganized to make the runtime smaller to
read by pulling exceptions out to their own package. This is
a breaking change for any plugins that contribute a predicate.
Change-Id: Icb50d306dfda146497814c65e2c03fae416ec5e1
In new buck version `$SRCDIR` is not necessary any more. Buck now
always runs genrule relative to the $SRCDIR link forest.
Change-Id: Iee88bb575c7baa62bc087527927be5347a7f8f95
Buck changed export_deps from a boolean to be exported_deps, a list of
dependencies that are to be added to deps and also exported. This
allows libraries to have dependencies for implementation use only, but
not expose them to callers for linkage.
exported_deps aren't transparently transitive anymore. This mostly
impacts the plugin-api:lib rule.
This is the first time Gerrit is using upstream Buck with no patches.
- Java memory settings for Buck can now be supplied in a project
specific file using `.buckjavaargs` in the root directory. The file
replaces the `.buckrc` previously supported by Gerrit's fork.
- Temporary directories for java_application() invoked from genrule()
is now supplied as part of the arguments using $TMP. This removes
one of the patches Gerrit had for Buck.
- Unit tests use the system temporary directory during testing. This
can be faster if the temporary directory is a tmpfs. Unfortunately
not all passing tests clean up after themselves, making it possible
to exhaust system memory and swap with useless tmpfs contents.
Using the system temporary directory for tests removes another patch
Gerrit had on top of Buck.
Change-Id: I3a9fe4aab0a33a8673df727e618122027a742638
The JARs are no longer passed into the prolog to java stage.
$DEPS is not necessary on the command line and .jar handling
inside of the translater is not required.
Change-Id: I1d12ab95376bd5878609bc8635955734e599e3cf
Force relative paths by passing the Prolog compiler only a relative
name from within $SRCDIR. This avoids picking up the user's $HOME
path as part of the generated class file names, and prevents build
failures on filesystems where individual path components are limited
to 256 bytes.
Change-Id: I43f2a93daf857413401f4e1aeb24b9b2a8c741fe
The build system used mixed names for essentially the same things.
Rename all DEFS files to *.defs matching the handful of other files
that are already using this convention.
Change-Id: I3269bd5db5d8d83f5e192ea910f19431c2a4a1cf
Latest version of buck is faster than the prior version used by
Gerrit. No-op updates when loading a debug version of the UI now take
only 1.804s on my laptop (previously 7s) and a draft UI compile is
only 24.659s (previously 39s).
The slow acceptance tests must now be excluded with `--exclude slow`.
Buck changed the meaning of the -e option to be --emulator, which is
unfortunately useful only for Android application developers.
genrule() now needs to use $(exe) to reference the binary to run,
offers $(location) to make it easier to find files in the build tree.
The empty srcs array is no longer required for genrule(). Buck has
determined it is sufficiently powerful with $(location) and deps that
requiring srcs is unnecessary.
Supporting .src.zip files in the srcs array of java_library() means
Gerrit no longer needs to run a separate genrule() to extract files
produced by ANTLR, or call javac inside of the BuckPrologCompiler
support glue.
Change-Id: Ib03042921a081b867a7aad0423bd45523e42917a
Gerrit targets Java 6, not Java 7. If Buck is run under JDK 7
the javac compiler by default will assume -source 7 -target 7
and write incompatible class files.
Ensure the compiler builds for Java 6 language features and
Java 6 class format by passing the correct flags.
Change-Id: Ib2c013a6d1955d94b75cfd5d967d2f45ef4d5486
Try to reduce the size of the top-level BUCK file by moving
anything that has to do with Eclipse project generation and
classpath management into tools/eclipse.
Change-Id: Id779eaff4fe732908b28a8e3441004e364b59e21
Implement a new build system using Buck[1], Facebook's
open source clone of Google's internal build system.
Pros:
- Concise build language
- Test and build output is concise
- Test failures and stack traces show on terminal
- Reliable incrementals; clean is unnecessary
- Extensible with simple blocks of Python
- Fast
buck: clean: 0.452s, full 1m21.083s [*], no-op: 7.145s,
mvn: clean: 4.596s, full 2m53.776s, no-op: 59.108s,
[*] full build includes downloading all dependencies,
time can vary due to remote server performance.
Cons:
- No Windows support
- No native Maven Central support (added by macros)
- No native GWT, Prolog, or WAR support (added by macros)
- Bootstrap of buck requires Ant
Getting started:
git clone https://gerrit.googlesource.com/buck
cd buck
ant
Mac OS X:
PATH="`pwd`/bin:/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands:$PATH"
Linux:
PATH="`pwd`/bin:$PATH"
Importing into Eclipse:
$ time buck build :eclipse
0m48.949s
Import existing project from `pwd`
Import 'gerrit' (do not import other Maven based projects)
Expand 'gerrit'
Right click 'buck-out' > Properties
Under Attributes check 'Derived'
If the code doesn't currently compile but an updated classpath
is needed, refresh the configs and obtain missing JARs:
$ buck build :eclipse_project :download
Running JUnit tests:
$ time buck test --all -e slow # skip slow tests
0m19.320s
$ time buck test --all # includes acceptance tests
5m17.517s
Building WAR:
$ buck build :gerrit
$ java -jar buck-out/gen/gerrit.war
Building release:
$ buck test --all && buck build :api :release
$ java -jar buck-out/gen/release.war
$ ls -lh buck-out/gen/{extension,plugin}-api.jar
Downloading dependencies:
Dependencies are normally downloaded automatically, but Buck can
inspect its graph and download missing dependencies so future
compiles can run without the network:
$ buck build :download
[1] http://facebook.github.io/buck/
Change-Id: I40853b108bd8e153cefa0896a5280a9a5ff81655