Update Buck
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
diff --git a/.buckversion b/.buckversion
index e39bcf8..ff1c137 100644
--- a/.buckversion
+++ b/.buckversion
@@ -1 +1 @@
-274acb17e9b6dc9ee60bc1371c47a7f49640c24c
+2b80cf780ae31bee6609ebc1bbab9ce6fd004dbe
diff --git a/.gitignore b/.gitignore
index 1b4c29c..efff6da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,7 @@
*.sublime-*
/gerrit-package-plugins
/.buckconfig.local
+/.buckjavaargs
/.buckd
/buck-cache
/buck-out
diff --git a/Documentation/BUCK b/Documentation/BUCK
index b2b7d2a..b94d123 100644
--- a/Documentation/BUCK
+++ b/Documentation/BUCK
@@ -63,6 +63,7 @@
name = 'index',
cmd = '$(exe //lib/asciidoctor:doc_indexer) ' +
'-z $OUT ' +
+ '--tmp $TMP ' +
'--prefix "%s/" ' % DOC_DIR +
'--in-ext ".txt" ' +
'--out-ext ".html" ' +
diff --git a/Documentation/asciidoc.defs b/Documentation/asciidoc.defs
index 44313d2..0175431 100644
--- a/Documentation/asciidoc.defs
+++ b/Documentation/asciidoc.defs
@@ -26,6 +26,7 @@
'cd $SRCDIR;',
'$(exe //lib/asciidoctor:asciidoc)',
'-z', '$OUT',
+ '--tmp', '$TMP',
'--in-ext', '".txt%s"' % EXPN,
'--out-ext', '".html"',
]
diff --git a/Documentation/dev-buck.txt b/Documentation/dev-buck.txt
index 0d9eb13..1acff3b 100644
--- a/Documentation/dev-buck.txt
+++ b/Documentation/dev-buck.txt
@@ -412,26 +412,13 @@
Override Buck's settings
~~~~~~~~~~~~~~~~~~~~~~~~
-User-specific configuration can be placed in one of the following files:
-`/etc/buck.conf`, `$HOME/.buck/buck.conf` or `$HOME/.buckrc`.
-
-For example to override Buck's default 1GB heap size:
+Additional JVM args for Buck can be set in `.buckjavaargs` in the
+project root directory. For example to override Buck's default 1GB
+heap size:
----
- cat > $HOME/.buckrc <<EOF
- export BUCK_EXTRA_JAVA_ARGS="\
- -XX:MaxPermSize=512m \
- -Xms8000m \
- -Xmx16000m"
- EOF
-----
-
-Or to debug BUCK, set `BUCK_DEBUG_MODE` to anything non-empty, then connect to
-port 8888:
-
-----
- cat > $HOME/.buckrc <<EOF
- export BUCK_DEBUG_MODE="yes"
+ cat > .buckjavaargs <<EOF
+ -XX:MaxPermSize=512m -Xms8000m -Xmx16000m
EOF
----
diff --git a/gerrit-acceptance-tests/BUCK b/gerrit-acceptance-tests/BUCK
index cb946d6..60c4331 100644
--- a/gerrit-acceptance-tests/BUCK
+++ b/gerrit-acceptance-tests/BUCK
@@ -3,7 +3,7 @@
java_library(
name = 'lib',
srcs = glob(['src/test/java/com/google/gerrit/acceptance/*.java']),
- deps = [
+ exported_deps = [
'//gerrit-common:server',
'//gerrit-extension-api:api',
'//gerrit-launcher:launcher',
@@ -34,7 +34,6 @@
'//lib/jgit:junit',
'//lib/mina:sshd',
],
- export_deps = True,
visibility = [
'//tools/eclipse:classpath',
'//gerrit-acceptance-tests/...',
diff --git a/gerrit-extension-api/BUCK b/gerrit-extension-api/BUCK
index 96df073..cd14854 100644
--- a/gerrit-extension-api/BUCK
+++ b/gerrit-extension-api/BUCK
@@ -16,13 +16,12 @@
java_library(
name = 'lib',
- deps = [
+ exported_deps = [
':api',
'//lib/guice:guice',
'//lib/guice:guice-servlet',
'//lib:servlet-api-3_0',
],
- export_deps = True,
visibility = ['PUBLIC'],
)
diff --git a/gerrit-plugin-api/BUCK b/gerrit-plugin-api/BUCK
index bc1ddd5..6693546 100644
--- a/gerrit-plugin-api/BUCK
+++ b/gerrit-plugin-api/BUCK
@@ -1,14 +1,14 @@
SRCS = [
'gerrit-server/src/main/java/',
'gerrit-httpd/src/main/java/',
- 'gerrit-sshd/src/main/java/'
+ 'gerrit-sshd/src/main/java/',
]
PLUGIN_API = [
- '//gerrit-server:server',
- '//gerrit-pgm:init-api',
- '//gerrit-sshd:sshd',
'//gerrit-httpd:httpd',
+ '//gerrit-pgm:init-api',
+ '//gerrit-server:server',
+ '//gerrit-sshd:sshd',
]
java_binary(
@@ -19,8 +19,22 @@
java_library(
name = 'lib',
- deps = PLUGIN_API + ['//lib:servlet-api-3_0'],
- export_deps = True,
+ exported_deps = PLUGIN_API + [
+ '//gerrit-common:server',
+ '//gerrit-extension-api:api',
+ '//gerrit-reviewdb:server',
+ '//lib:args4j',
+ '//lib:guava',
+ '//lib:gwtorm',
+ '//lib:jsch',
+ '//lib:servlet-api-3_0',
+ '//lib/guice:guice',
+ '//lib/guice:guice-assistedinject',
+ '//lib/guice:guice-servlet',
+ '//lib/jgit:jgit',
+ '//lib/log:api',
+ '//lib/mina:sshd',
+ ],
visibility = ['PUBLIC'],
)
diff --git a/gerrit-server/BUCK b/gerrit-server/BUCK
index d88867f..c049cca 100644
--- a/gerrit-server/BUCK
+++ b/gerrit-server/BUCK
@@ -118,7 +118,6 @@
'//lib/guice:guice',
'//lib/prolog:prolog-cafe',
],
- export_deps = True,
)
java_test(
@@ -127,7 +126,14 @@
resources = glob(['src/test/resources/com/google/gerrit/rules/**/*']),
deps = [
':prolog_test_case',
+ ':server',
+ '//gerrit-common:server',
+ '//gerrit-reviewdb:server',
'//gerrit-server/src/main/prolog:common',
+ '//lib:gwtorm',
+ '//lib:junit',
+ '//lib/guice:guice',
+ '//lib/prolog:prolog-cafe',
],
)
diff --git a/lib/asciidoctor/java/AsciiDoctor.java b/lib/asciidoctor/java/AsciiDoctor.java
index 0613ff4..933b929 100644
--- a/lib/asciidoctor/java/AsciiDoctor.java
+++ b/lib/asciidoctor/java/AsciiDoctor.java
@@ -12,6 +12,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+import com.google.common.io.ByteStreams;
+
+import org.asciidoctor.Asciidoctor;
+import org.asciidoctor.AttributesBuilder;
+import org.asciidoctor.Options;
+import org.asciidoctor.OptionsBuilder;
+import org.asciidoctor.SafeMode;
+import org.asciidoctor.internal.JRubyAsciidoctor;
+import org.kohsuke.args4j.Argument;
+import org.kohsuke.args4j.CmdLineException;
+import org.kohsuke.args4j.CmdLineParser;
+import org.kohsuke.args4j.Option;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -23,20 +36,6 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
-import com.google.common.io.ByteStreams;
-
-import org.asciidoctor.Asciidoctor;
-import org.asciidoctor.AttributesBuilder;
-import org.asciidoctor.Options;
-import org.asciidoctor.OptionsBuilder;
-import org.asciidoctor.SafeMode;
-import org.asciidoctor.internal.JRubyAsciidoctor;
-
-import org.kohsuke.args4j.Argument;
-import org.kohsuke.args4j.CmdLineException;
-import org.kohsuke.args4j.CmdLineParser;
-import org.kohsuke.args4j.Option;
-
public class AsciiDoctor {
private static final String DOCTYPE = "article";
@@ -54,6 +53,9 @@
@Option(name = "--out-ext", usage = "extension for output files")
private String outExt = ".html";
+ @Option(name = "--tmp", usage = "temporary output path")
+ private File tmpdir;
+
@Option(name = "-a", usage =
"a list of attributes, in the form key or key=value pair")
private List<String> attributes = new ArrayList<String>();
@@ -135,31 +137,17 @@
// have to add css files into the SRCS.
continue;
}
- String outName = mapInFileToOutFile(inputFile, inExt, outExt);
- File out = new File(outName);
- Options options = createOptions(out);
- renderInput(options, inputFile);
+ String outName = mapInFileToOutFile(inputFile, inExt, outExt);
+ File out = new File(tmpdir, outName);
+ out.getParentFile().mkdirs();
+ Options options = createOptions(out);
+ renderInput(options, new File(inputFile));
zipFile(out, outName, zip);
}
zip.close();
}
- public static void zipDir(File dir, String prefix, ZipOutputStream zip)
- throws IOException {
- for (File file : dir.listFiles()) {
- String name = file.getName();
- if (!prefix.isEmpty()) {
- name = prefix + "/" + name;
- }
- if (file.isDirectory()) {
- zipDir(file, name, zip);
- } else {
- zipFile(file, name, zip);
- }
- }
- }
-
public static void zipFile(File file, String name, ZipOutputStream zip)
throws IOException {
zip.putNextEntry(new ZipEntry(name));
@@ -169,9 +157,9 @@
zip.closeEntry();
}
- private void renderInput(Options options, String inputFile) {
+ private void renderInput(Options options, File inputFile) {
Asciidoctor asciidoctor = JRubyAsciidoctor.create();
- asciidoctor.renderFile(new File(inputFile), options);
+ asciidoctor.renderFile(inputFile, options);
}
public static void main(String[] args) {
diff --git a/lib/asciidoctor/java/DocIndexer.java b/lib/asciidoctor/java/DocIndexer.java
index 96b1449..3c94e86 100644
--- a/lib/asciidoctor/java/DocIndexer.java
+++ b/lib/asciidoctor/java/DocIndexer.java
@@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-import com.google.common.io.Files;
import com.google.gerrit.server.documentation.Constants;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
@@ -48,6 +47,9 @@
@Option(name = "-z", usage = "output zip file")
private String zipFile;
+ @Option(name = "--tmp", usage = "temporary output path")
+ private File tmpdir;
+
@Option(name = "--prefix", usage = "prefix for the html filepath")
private String prefix = "";
@@ -74,8 +76,7 @@
return;
}
- File tmp = Files.createTempDir();
- NIOFSDirectory directory = new NIOFSDirectory(tmp);
+ NIOFSDirectory directory = new NIOFSDirectory(tmpdir);
IndexWriterConfig config = new IndexWriterConfig(
LUCENE_VERSION,
new StandardAnalyzer(LUCENE_VERSION, CharArraySet.EMPTY_SET));
@@ -108,10 +109,25 @@
iwriter.close();
ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(zipFile));
- AsciiDoctor.zipDir(tmp, "", zip);
+ zipDir(tmpdir, "", zip);
zip.close();
}
+ private static void zipDir(File dir, String prefix, ZipOutputStream zip)
+ throws IOException {
+ for (File file : dir.listFiles()) {
+ String name = file.getName();
+ if (!prefix.isEmpty()) {
+ name = prefix + "/" + name;
+ }
+ if (file.isDirectory()) {
+ zipDir(file, name, zip);
+ } else {
+ AsciiDoctor.zipFile(file, name, zip);
+ }
+ }
+ }
+
public static void main(String[] args) {
try {
new DocIndexer().invoke(args);
diff --git a/lib/guice/BUCK b/lib/guice/BUCK
index 70e750a..946bf9d 100644
--- a/lib/guice/BUCK
+++ b/lib/guice/BUCK
@@ -9,11 +9,10 @@
java_library(
name = 'guice',
- deps = [
+ exported_deps = [
':guice_library',
':javax-inject',
],
- export_deps = True,
visibility = ['PUBLIC'],
)
@@ -23,40 +22,10 @@
sha1 = 'a82be989679df08b66d48b42659a3ca2daaf1d5b',
license = 'Apache2.0',
deps = [':aopalliance'],
+ exclude_java_sources = True,
exclude = EXCLUDE + [
'META-INF/maven/com.google.guava/guava/pom.properties',
'META-INF/maven/com.google.guava/guava/pom.xml',
- 'javax/annotation/CheckForNull.java',
- 'javax/annotation/CheckForSigned.java',
- 'javax/annotation/CheckReturnValue.java',
- 'javax/annotation/concurrent/GuardedBy.java',
- 'javax/annotation/concurrent/Immutable.java',
- 'javax/annotation/concurrent/NotThreadSafe.java',
- 'javax/annotation/concurrent/ThreadSafe.java',
- 'javax/annotation/Detainted.java',
- 'javax/annotation/MatchesPattern.java',
- 'javax/annotation/meta/Exclusive.java',
- 'javax/annotation/meta/Exhaustive.java',
- 'javax/annotation/meta/TypeQualifier.java',
- 'javax/annotation/meta/TypeQualifierDefault.java',
- 'javax/annotation/meta/TypeQualifierNickname.java',
- 'javax/annotation/meta/TypeQualifierValidator.java',
- 'javax/annotation/meta/When.java',
- 'javax/annotation/Nonnegative.java',
- 'javax/annotation/Nonnull.java',
- 'javax/annotation/Nullable.java',
- 'javax/annotation/OverridingMethodsMustInvokeSuper.java',
- 'javax/annotation/ParametersAreNonnullByDefault.java',
- 'javax/annotation/ParametersAreNullableByDefault.java',
- 'javax/annotation/PropertyKey.java',
- 'javax/annotation/RegEx.java',
- 'javax/annotation/Signed.java',
- 'javax/annotation/Syntax.java',
- 'javax/annotation/Tainted.java',
- 'javax/annotation/Untainted.java',
- 'javax/annotation/WillClose.java',
- 'javax/annotation/WillCloseWhenClosed.java',
- 'javax/annotation/WillNotClose.java',
],
visibility = ['PUBLIC'],
)
diff --git a/lib/jetty/BUCK b/lib/jetty/BUCK
index 6314f99..e31ab43 100644
--- a/lib/jetty/BUCK
+++ b/lib/jetty/BUCK
@@ -30,11 +30,10 @@
id = 'org.eclipse.jetty:jetty-server:' + VERSION,
sha1 = 'd89016c2bcd380f548530fa049295e62601dc564',
license = 'Apache2.0',
- deps = [
+ exported_deps = [
':continuation',
':http',
],
- export_deps = True,
exclude = EXCLUDE,
)
@@ -51,7 +50,7 @@
id = 'org.eclipse.jetty:jetty-http:' + VERSION,
sha1 = 'b3a2302717ac1889b4a17ed03e2555f8291121b9',
license = 'Apache2.0',
- deps = [':io'],
+ exported_deps = [':io'],
exclude = EXCLUDE,
)
@@ -60,7 +59,7 @@
id = 'org.eclipse.jetty:jetty-io:' + VERSION,
sha1 = 'f3a66e0507d963c51e280243f0472a5b2eadc8b1',
license = 'Apache2.0',
- deps = [':util'],
+ exported_deps = [':util'],
exclude = EXCLUDE,
visibility = [],
)
diff --git a/lib/maven.defs b/lib/maven.defs
index 54840e8..58ddbe6 100644
--- a/lib/maven.defs
+++ b/lib/maven.defs
@@ -35,10 +35,10 @@
exclude_java_sources = False,
unsign = False,
deps = [],
+ exported_deps = [],
sha1 = '', bin_sha1 = '', src_sha1 = '',
repository = MAVEN_CENTRAL,
attach_source = True,
- export_deps = False,
visibility = ['PUBLIC']):
from os import path
@@ -109,7 +109,7 @@
out = '__' + name + '__no_src',
)
- if export_deps:
+ if exported_deps:
prebuilt_jar(
name = name + '__jar',
deps = deps + license + [':' + name + '__download_bin'],
@@ -118,8 +118,7 @@
)
java_library(
name = name,
- deps = [':' + name + '__jar'],
- export_deps = True,
+ exported_deps = exported_deps + [':' + name + '__jar'],
visibility = visibility,
)
else:
diff --git a/lib/prolog/java/BuckPrologCompiler.java b/lib/prolog/java/BuckPrologCompiler.java
index 0db6763..17d2d76 100644
--- a/lib/prolog/java/BuckPrologCompiler.java
+++ b/lib/prolog/java/BuckPrologCompiler.java
@@ -23,18 +23,21 @@
import java.util.jar.JarOutputStream;
public class BuckPrologCompiler {
+ private static File tmpdir;
+
public static void main(String[] argv) throws IOException, CompileException {
- File out = new File(argv[argv.length - 1]);
+ int i = 0;
+ tmpdir = new File(argv[i++]);
+ File out = new File(argv[i++]);
File java = tmpdir("java");
- for (int i = 0; i < argv.length - 1; i++) {
- File src = new File(argv[i]);
- new Compiler().prologToJavaSource(src.getPath(), java.getPath());
+ for (; i < argv.length; i++) {
+ new Compiler().prologToJavaSource(argv[i], java.getPath());
}
jar(out, java);
}
private static File tmpdir(String name) throws IOException {
- File d = File.createTempFile(name + "_", "");
+ File d = File.createTempFile(name + "_", "", tmpdir);
if (!d.delete() || !d.mkdir()) {
throw new IOException("Cannot mkdir " + d);
}
@@ -42,7 +45,7 @@
}
private static void jar(File jar, File classes) throws IOException {
- File tmp = File.createTempFile("prolog", ".jar", jar.getParentFile());
+ File tmp = File.createTempFile("prolog", ".jar", tmpdir);
try {
JarOutputStream out = new JarOutputStream(new FileOutputStream(tmp));
try {
diff --git a/lib/prolog/prolog.defs b/lib/prolog/prolog.defs
index d8df8f7..b91e2de 100644
--- a/lib/prolog/prolog.defs
+++ b/lib/prolog/prolog.defs
@@ -19,9 +19,9 @@
visibility = []):
genrule(
name = name + '__pl2j',
- cmd = 'cd $SRCDIR;$(exe //lib/prolog:compiler) ' +
- ' '.join(srcs) +
- ' $OUT',
+ cmd = 'cd $SRCDIR;$(exe //lib/prolog:compiler)' +
+ ' $TMP $OUT ' +
+ ' '.join(srcs),
srcs = srcs,
deps = ['//lib/prolog:compiler'],
out = name + '.src.zip',
diff --git a/tools/buck.defs b/tools/buck.defs
index ce4ac55..8bcacc3 100644
--- a/tools/buck.defs
+++ b/tools/buck.defs
@@ -17,22 +17,22 @@
name,
srcs=[],
resources=[],
- export_deps=False,
source='7',
target='7',
proguard_config=None,
deps=[],
+ exported_deps=[],
visibility=[],
):
original_java_library(
name=name,
srcs=srcs,
resources=resources,
- export_deps=export_deps,
source=source,
target=target,
proguard_config=proguard_config,
deps=deps,
+ exported_deps=exported_deps,
visibility=visibility,
)