Enable plugins.allowRemoteAdmin in developer mode
The default value of plugins.allowRemoteAdmin is false, which is
a sensible default, but is annoying to have to manually enable for
every test site.
Make it less annoying by enabling it by default in developer mode.
Introduce a new init step that is run when developer mode is
enabled, i.e. when --dev is given and the site is initialized for
the first time.
It may seem like overkill to have a dedidated init step only to
set plugins.allowRemoteAdmin, but this will also allow us to set
any other developer mode specific settings in future.
Change-Id: Ia22b24570d696111d10006203c1bdacc4db31022
diff --git a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/InitDev.java b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/InitDev.java
new file mode 100644
index 0000000..5500da8
--- /dev/null
+++ b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/InitDev.java
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 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.google.gerrit.pgm.init;
+
+import com.google.gerrit.pgm.init.api.InitFlags;
+import com.google.gerrit.pgm.init.api.InitStep;
+import com.google.gerrit.pgm.init.api.Section;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+@Singleton
+public class InitDev implements InitStep {
+ private final InitFlags flags;
+ private final Section plugins;
+
+ @Inject
+ InitDev(InitFlags flags,
+ Section.Factory sections) {
+ this.flags = flags;
+ this.plugins = sections.get("plugins", null);
+ }
+
+ @Override
+ public void run() throws Exception {
+ if (!flags.dev) {
+ return;
+ }
+ plugins.set("allowRemoteAdmin", "true");
+ }
+}
diff --git a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/InitModule.java b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/InitModule.java
index b5aa625..a442f29 100644
--- a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/InitModule.java
+++ b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/InitModule.java
@@ -64,6 +64,7 @@
step().to(InitHttpd.class);
step().to(InitCache.class);
step().to(InitPlugins.class);
+ step().to(InitDev.class);
}
protected LinkedBindingBuilder<InitStep> step() {