Use "resemblejs" dep

This fixes it so it uses the resemblejs dependency from gerrit core.

This is because resemblejs was not being injected into the plugin thus failed to load.

I tested this by doing:

bazel build plugins/image-diff

Then deploying (and uploaded a png file to test)

Bug: Issue 9911
Change-Id: I239d93a4352429ae3b09eb132cbf159c67f0913e
diff --git a/BUILD b/BUILD
index f84f778..edd94b3 100644
--- a/BUILD
+++ b/BUILD
@@ -1,8 +1,45 @@
-load("//tools/bzl:js.bzl", "polygerrit_plugin")
+load("//tools/bzl:genrule2.bzl", "genrule2")
+load("//tools/bzl:js.bzl", "bundle_assets", "polygerrit_plugin")
+load("//tools/bzl:plugin.bzl", "gerrit_plugin")
+
+gerrit_plugin(
+    name = "image-diff",
+    srcs = ["java/com/googlesource/gerrit/plugins/imagediff/ImageDiffModule.java"],
+    manifest_entries = [
+        "Gerrit-PluginName: image-diff",
+        "Gerrit-Module: com.googlesource.gerrit.plugins.codemirror.ImageDiffModule",
+        "Implementation-Title: Image Diff plugin",
+    ],
+    resource_jars = [":image-diff-static"],
+)
+
+genrule2(
+    name = "image-diff-static",
+    srcs = [":image_diff"],
+    outs = ["image-diff-static.jar"],
+    cmd = " && ".join([
+        "mkdir $$TMP/static",
+        "cp -r $(locations :image_diff) $$TMP/static",
+        "cd $$TMP",
+        "zip -Drq $$ROOT/$@ -g .",
+    ]),
+)
+
+bundle_assets(
+    name = "image-diff-assets",
+    srcs = glob(["gr-resemble-diff-mode/resemblejs-assets.html"]),
+    app = "gr-resemble-diff-mode/resemblejs-assets.html",
+    split = False,
+    deps = [
+        "//lib/js:resemblejs"
+    ],
+)
 
 polygerrit_plugin(
-    name = "image-diff",
+    name = "image_diff",
     srcs = glob(["**/*.html", "**/*.js"]),
     app = "plugin.html",
-    deps = ["//lib/js:resemblejs"],
-)
\ No newline at end of file
+    assets = [
+        ":image-diff-assets"
+    ],
+)
diff --git a/gr-resemble-diff-mode/gr-resemble-diff-mode.html b/gr-resemble-diff-mode/gr-resemble-diff-mode.html
index edc6a93..b074f78 100644
--- a/gr-resemble-diff-mode/gr-resemble-diff-mode.html
+++ b/gr-resemble-diff-mode/gr-resemble-diff-mode.html
@@ -14,7 +14,8 @@
 limitations under the License.
 -->
 
-<script src="../node_modules/resemblejs/resemble.js"></script>
+<link rel="import" href="../image-diff-assets.html">
+
 <dom-module id="gr-resemble-diff-mode">
   <template>
     <style>
diff --git a/gr-resemble-diff-mode/resemblejs-assets.html b/gr-resemble-diff-mode/resemblejs-assets.html
new file mode 100644
index 0000000..8e17b02
--- /dev/null
+++ b/gr-resemble-diff-mode/resemblejs-assets.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<!--
+@license
+Copyright (C) 2018 The Android Open Source Project
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<script src="../bower_components/resemblejs/resemble.js"></script>
diff --git a/java/com/googlesource/gerrit/plugins/imagediff/ImageDiffModule.java b/java/com/googlesource/gerrit/plugins/imagediff/ImageDiffModule.java
new file mode 100644
index 0000000..ffb1b1a
--- /dev/null
+++ b/java/com/googlesource/gerrit/plugins/imagediff/ImageDiffModule.java
@@ -0,0 +1,28 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.googlesource.gerrit.plugins.imagediff;
+
+import com.google.gerrit.extensions.registration.DynamicSet;
+import com.google.gerrit.extensions.restapi.RestApiModule;
+import com.google.gerrit.extensions.webui.JavaScriptPlugin;
+import com.google.gerrit.extensions.webui.WebUiPlugin;
+
+public class ImageDiffModule extends RestApiModule {
+  @Override
+  protected void configure() {
+    DynamicSet.bind(binder(), WebUiPlugin.class)
+        .toInstance(new JavaScriptPlugin("image_diff.html"));
+  }
+}