Add example implementation of ExternalIncludedIn extension point Change-Id: Ied5517cf9da58c748ad60bdf96444828a6051df3 Signed-off-by: Edwin Kempin <ekempin@google.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/DeployedOnIncludedInExtension.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/DeployedOnIncludedInExtension.java new file mode 100644 index 0000000..2b0520f --- /dev/null +++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/DeployedOnIncludedInExtension.java
@@ -0,0 +1,39 @@ +// 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.googlesource.gerrit.plugins.cookbook; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; +import com.google.gerrit.extensions.config.ExternalIncludedIn; + +import java.util.Collection; + +public class DeployedOnIncludedInExtension implements ExternalIncludedIn { + private static final String PROD = "Production"; + private static final String STAGING = "Staging"; + + @Override + public Multimap<String, String> getIncludedIn(String project, String commit, + Collection<String> tags, Collection<String> branches) { + Multimap<String, String> m = ArrayListMultimap.create(); + m.put(PROD, "A"); + m.put(PROD, "B"); + m.put(PROD, "C"); + m.put(STAGING, "X"); + m.put(STAGING, "Y"); + m.put(STAGING, "Z"); + return m; + } +}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/Module.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/Module.java index f6181ce..297e1e8 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/Module.java +++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/Module.java
@@ -21,6 +21,7 @@ import com.google.gerrit.extensions.annotations.Exports; import com.google.gerrit.extensions.api.projects.ProjectConfigEntryType; import com.google.gerrit.extensions.client.InheritableBoolean; +import com.google.gerrit.extensions.config.ExternalIncludedIn; import com.google.gerrit.extensions.events.LifecycleListener; import com.google.gerrit.extensions.events.NewProjectCreatedListener; import com.google.gerrit.extensions.events.UsageDataPublishedListener; @@ -78,6 +79,8 @@ DynamicSet.bind(binder(), NewProjectCreatedListener.class) .to(ProjectCreatedListener.class); configurePluginParameters(); + DynamicSet.bind(binder(), ExternalIncludedIn.class) + .to(DeployedOnIncludedInExtension.class); bind(ChangeOperatorFactory.class) .annotatedWith(Exports.named("sample"))