Split up the modules into commands and schemes

This segmentation allows gerrit-review to partially install the plugin,
using only the DownloadCommandsModule. Since the server has exactly one
URL the SchemeModule is not required and adds unnecessary complexity.

Change-Id: I1e64902ee2b2d0dd2be3233c5ebb16427841d2ae
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/Module.java b/src/main/java/com/googlesource/gerrit/plugins/download/Module.java
index 3f6da18..14ff781 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/download/Module.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/download/Module.java
@@ -14,45 +14,15 @@
 
 package com.googlesource.gerrit.plugins.download;
 
-import com.google.gerrit.extensions.annotations.Exports;
-import com.google.gerrit.extensions.config.DownloadCommand;
-import com.google.gerrit.extensions.config.DownloadScheme;
 import com.google.inject.AbstractModule;
 
-import com.googlesource.gerrit.plugins.download.command.CheckoutCommand;
-import com.googlesource.gerrit.plugins.download.command.CherryPickCommand;
-import com.googlesource.gerrit.plugins.download.command.FormatPatchCommand;
-import com.googlesource.gerrit.plugins.download.command.PullCommand;
-import com.googlesource.gerrit.plugins.download.command.RepoCommand;
-import com.googlesource.gerrit.plugins.download.scheme.AnonymousHttpScheme;
-import com.googlesource.gerrit.plugins.download.scheme.GitScheme;
-import com.googlesource.gerrit.plugins.download.scheme.HttpScheme;
-import com.googlesource.gerrit.plugins.download.scheme.RepoScheme;
-import com.googlesource.gerrit.plugins.download.scheme.SshScheme;
+import com.googlesource.gerrit.plugins.download.command.DownloadCommandsModule;
+import com.googlesource.gerrit.plugins.download.scheme.SchemeModule;
 
 class Module extends AbstractModule {
   @Override
   protected void configure() {
-    bind(DownloadScheme.class).annotatedWith(Exports.named("anonymous http"))
-        .to(AnonymousHttpScheme.class);
-    bind(DownloadScheme.class).annotatedWith(Exports.named("git"))
-        .to(GitScheme.class);
-    bind(DownloadScheme.class).annotatedWith(Exports.named("http"))
-        .to(HttpScheme.class);
-    bind(DownloadScheme.class).annotatedWith(Exports.named("repo"))
-        .to(RepoScheme.class);
-    bind(DownloadScheme.class).annotatedWith(Exports.named("ssh"))
-        .to(SshScheme.class);
-
-    bind(DownloadCommand.class).annotatedWith(Exports.named("Checkout"))
-        .to(CheckoutCommand.class);
-    bind(DownloadCommand.class).annotatedWith(Exports.named("Cherry-Pick"))
-        .to(CherryPickCommand.class);
-    bind(DownloadCommand.class).annotatedWith(Exports.named("Format-Patch"))
-        .to(FormatPatchCommand.class);
-    bind(DownloadCommand.class).annotatedWith(Exports.named("Pull"))
-        .to(PullCommand.class);
-    bind(DownloadCommand.class).annotatedWith(Exports.named("Repo-Download"))
-        .to(RepoCommand.class);
+    install(new DownloadCommandsModule());
+    install(new SchemeModule());
   }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/command/DownloadCommandsModule.java b/src/main/java/com/googlesource/gerrit/plugins/download/command/DownloadCommandsModule.java
new file mode 100644
index 0000000..f6dea28
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/download/command/DownloadCommandsModule.java
@@ -0,0 +1,44 @@
+// Copyright (C) 2013 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.download.command;
+
+import com.google.gerrit.extensions.annotations.Exports;
+import com.google.gerrit.extensions.config.DownloadCommand;
+import com.google.inject.AbstractModule;
+
+public class DownloadCommandsModule extends AbstractModule {
+  @Override
+  protected void configure() {
+    bind(DownloadCommand.class)
+      .annotatedWith(Exports.named("Checkout"))
+      .to(CheckoutCommand.class);
+
+    bind(DownloadCommand.class)
+      .annotatedWith(Exports.named("Cherry-Pick"))
+      .to(CherryPickCommand.class);
+
+    bind(DownloadCommand.class)
+      .annotatedWith(Exports.named("Format-Patch"))
+      .to(FormatPatchCommand.class);
+
+    bind(DownloadCommand.class)
+      .annotatedWith(Exports.named("Pull"))
+      .to(PullCommand.class);
+
+    bind(DownloadCommand.class)
+      .annotatedWith(Exports.named("Repo-Download"))
+      .to(RepoCommand.class);
+  }
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/scheme/SchemeModule.java b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/SchemeModule.java
new file mode 100644
index 0000000..9a42fcc
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/SchemeModule.java
@@ -0,0 +1,44 @@
+// Copyright (C) 2013 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.download.scheme;
+
+import com.google.gerrit.extensions.annotations.Exports;
+import com.google.gerrit.extensions.config.DownloadScheme;
+import com.google.inject.AbstractModule;
+
+public class SchemeModule extends AbstractModule {
+  @Override
+  protected void configure() {
+    bind(DownloadScheme.class)
+      .annotatedWith(Exports.named("anonymous http"))
+      .to(AnonymousHttpScheme.class);
+
+    bind(DownloadScheme.class)
+      .annotatedWith(Exports.named("git"))
+      .to(GitScheme.class);
+
+    bind(DownloadScheme.class)
+      .annotatedWith(Exports.named("http"))
+      .to(HttpScheme.class);
+
+    bind(DownloadScheme.class)
+      .annotatedWith(Exports.named("repo"))
+      .to(RepoScheme.class);
+
+    bind(DownloadScheme.class)
+      .annotatedWith(Exports.named("ssh"))
+      .to(SshScheme.class);
+  }
+}