From 0db7612e092b37c6ea04883a5a45f51c6d9ae433 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Thu, 11 Jun 2015 23:42:47 +0200 Subject: [PATCH] Replace vanilla parboiled with grappa library Grappa library was chosen by Gitiles project to implement markdown rendering. Grappa library includes non-relocated parboiled library that is incompatible with vanilla parboiled library. When Grappa driven gitiles-plugin is deployed in Gerrit, there is a class collision. The only way to make them co-exist is to relocate one of them, using JarJar utility. But doing it can be error prone as this issue has shown: [2]. This change takes another approach and replace parboiled library in Gerrit core with Grappa library. This fixed the deployment problem with gitiles-plugin: markdown files rendering work as expected. [1] https://github.com/fge/grappa [2] https://github.com/sirthias/parboiled/issues/80 Change-Id: I793a84013468bf9fd07e62960bc2e789674ff35c --- gerrit-server/BUCK | 5 ++- .../gerrit/server/util/ParboiledTest.java | 14 ++++----- lib/BUCK | 31 +++++++++---------- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/gerrit-server/BUCK b/gerrit-server/BUCK index 3a96c8856a..c43c722a8e 100644 --- a/gerrit-server/BUCK +++ b/gerrit-server/BUCK @@ -34,6 +34,7 @@ java_library( '//gerrit-util-ssl:ssl', '//lib:args4j', '//lib:automaton', + '//lib:grappa', '//lib:gson', '//lib:guava', '//lib:gwtjsonrpc', @@ -41,7 +42,6 @@ java_library( '//lib:jsch', '//lib:juniversalchardet', '//lib:mime-util', - '//lib:parboiled-core', '//lib:pegdown', '//lib:protobuf', '//lib:velocity', @@ -210,6 +210,7 @@ java_test( '//gerrit-reviewdb:server', '//gerrit-server/src/main/prolog:common', '//lib:args4j', + '//lib:grappa', '//lib:gwtorm', '//lib:truth', '//lib/guice:guice', @@ -217,8 +218,6 @@ java_test( '//lib/jgit:jgit', '//lib/jgit:junit', '//lib/joda:joda-time', - '//lib:parboiled-core', - '//lib:parboiled-java', '//lib/prolog:runtime', ], source_under_test = [':server'], diff --git a/gerrit-server/src/test/java/com/google/gerrit/server/util/ParboiledTest.java b/gerrit-server/src/test/java/com/google/gerrit/server/util/ParboiledTest.java index f406de1d1d..6efc881448 100644 --- a/gerrit-server/src/test/java/com/google/gerrit/server/util/ParboiledTest.java +++ b/gerrit-server/src/test/java/com/google/gerrit/server/util/ParboiledTest.java @@ -35,8 +35,8 @@ public class ParboiledTest { " [Number] '42'\n" + " [0..9] '4'\n" + " [0..9] '2'\n" + - " [ZeroOrMore]\n" + - " [ZeroOrMore]\n"; + " [zeroOrMore]\n" + + " [zeroOrMore]\n"; private CalculatorParser parser; @@ -49,7 +49,7 @@ public class ParboiledTest { public void test() { ParsingResult result = new ReportingParseRunner(parser.Expression()).run("42"); - assertThat(result.hasErrors()).isFalse(); + assertThat(result.isSuccess()).isTrue(); // next test is optional; we could stop here. assertThat(ParseTreeUtils.printNodeTree(result)).isEqualTo(EXPECTED); } @@ -57,19 +57,19 @@ public class ParboiledTest { @BuildParseTree static class CalculatorParser extends BaseParser { Rule Expression() { - return Sequence(Term(), ZeroOrMore(AnyOf("+-"), Term())); + return sequence(Term(), zeroOrMore(anyOf("+-"), Term())); } Rule Term() { - return Sequence(Factor(), ZeroOrMore(AnyOf("*/"), Factor())); + return sequence(Factor(), zeroOrMore(anyOf("*/"), Factor())); } Rule Factor() { - return FirstOf(Number(), Sequence('(', Expression(), ')')); + return firstOf(Number(), sequence('(', Expression(), ')')); } Rule Number() { - return OneOrMore(CharRange('0', '9')); + return oneOrMore(charRange('0', '9')); } } } diff --git a/lib/BUCK b/lib/BUCK index 43e09f3dee..d2f71e1f1f 100644 --- a/lib/BUCK +++ b/lib/BUCK @@ -120,30 +120,29 @@ maven_jar( id = 'org.pegdown:pegdown:1.4.2', sha1 = 'd96db502ed832df867ff5d918f05b51ba3879ea7', license = 'Apache2.0', - deps = [':parboiled-java'], + deps = [':grappa'], ) maven_jar( - name = 'parboiled-core', - id = 'org.parboiled:parboiled-core:1.1.7', - sha1 = 'a60ff9a54cbeb30ec44c89e16ac4c35913cbad5a', - license = 'Apache2.0', - attach_source = False, -) - -maven_jar( - name = 'parboiled-java', - id = 'org.parboiled:parboiled-java:1.1.7', - sha1 = '2298c64ce8ee8e2fb37e97e16d7be52f0c7cf61f', + name = 'grappa', + id = 'com.github.parboiled1:grappa:1.0.4', + sha1 = 'ad4b44b9c305dad7aa1e680d4b5c8eec9c4fd6f5', license = 'Apache2.0', deps = [ - ':parboiled-core', - '//lib/ow2:ow2-asm-tree', + ':jitescript', + '//lib/ow2:ow2-asm', '//lib/ow2:ow2-asm-analysis', + '//lib/ow2:ow2-asm-tree', '//lib/ow2:ow2-asm-util', ], - attach_source = False, - visibility = ['//gerrit-server:server_tests'], +) + +maven_jar( + name = 'jitescript', + id = 'me.qmx.jitescript:jitescript:0.4.0', + sha1 = '2e35862b0435c1b027a21f3d6eecbe50e6e08d54', + license = 'Apache2.0', + visibility = ['//lib:grappa'], ) maven_jar(