Move DefaultAddAllOwnersToAttentionSet to owners-api module

The DefaultAddAllOwnersToAttentionSet implementation is supposed to
be overridden by other plugins. However, having the default
implementation outside the libModule resulted into a DynamicItem<>
binding exception as Gerrit won't allow plugins to override other
plugin's provided items.

Having the default implementation in the libModule allows the
DynamicItem<> to be overridden by plugins.

Bug: Issue 433327537
Change-Id: Ie0e55cc2407ad3cc6facc8035050bfe33179815f
diff --git a/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/DefaultAddAllOwnersToAttentionSet.java b/owners-api/src/main/java/com/googlesource/gerrit/owners/api/DefaultAddAllOwnersToAttentionSet.java
similarity index 89%
rename from owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/DefaultAddAllOwnersToAttentionSet.java
rename to owners-api/src/main/java/com/googlesource/gerrit/owners/api/DefaultAddAllOwnersToAttentionSet.java
index d53a239..fdbfbdb 100644
--- a/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/DefaultAddAllOwnersToAttentionSet.java
+++ b/owners-api/src/main/java/com/googlesource/gerrit/owners/api/DefaultAddAllOwnersToAttentionSet.java
@@ -13,11 +13,11 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package com.googlesource.gerrit.owners.common;
+package com.googlesource.gerrit.owners.api;
 
 import com.google.gerrit.entities.Account.Id;
 import com.google.gerrit.extensions.common.ChangeInfo;
-import com.googlesource.gerrit.owners.api.OwnersAttentionSet;
+
 import java.util.Collection;
 
 class DefaultAddAllOwnersToAttentionSet implements OwnersAttentionSet {
diff --git a/owners-api/src/main/java/com/googlesource/gerrit/owners/api/OwnersApiModule.java b/owners-api/src/main/java/com/googlesource/gerrit/owners/api/OwnersApiModule.java
index 54ee51d..f87ad7f 100644
--- a/owners-api/src/main/java/com/googlesource/gerrit/owners/api/OwnersApiModule.java
+++ b/owners-api/src/main/java/com/googlesource/gerrit/owners/api/OwnersApiModule.java
@@ -17,11 +17,15 @@
 
 import com.google.gerrit.extensions.registration.DynamicItem;
 import com.google.inject.AbstractModule;
+import com.google.inject.Scopes;
 
 public class OwnersApiModule extends AbstractModule {
 
   @Override
   protected void configure() {
     DynamicItem.itemOf(binder(), OwnersAttentionSet.class);
+    DynamicItem.bind(binder(), OwnersAttentionSet.class)
+        .to(DefaultAddAllOwnersToAttentionSet.class)
+        .in(Scopes.SINGLETON);
   }
 }
diff --git a/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/AutoassignModule.java b/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/AutoassignModule.java
index 5e6ad99..a54522b 100644
--- a/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/AutoassignModule.java
+++ b/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/AutoassignModule.java
@@ -32,12 +32,12 @@
 
   @VisibleForTesting
   AutoassignModule() {
-    this(DefaultAddAllOwnersToAttentionSet.class, new AutoAssignConfig());
+    this(new AutoAssignConfig());
   }
 
   @Inject
   AutoassignModule(AutoAssignConfig config) {
-    this(DefaultAddAllOwnersToAttentionSet.class, config);
+    this(null, config);
   }
 
   @VisibleForTesting
@@ -53,9 +53,11 @@
     bind(ReviewerManager.class)
         .to(config.isAsyncReviewers() ? AsyncReviewerManager.class : SyncReviewerManager.class);
     DynamicSet.bind(binder(), GitReferenceUpdatedListener.class).to(GitRefListener.class);
-    DynamicItem.bind(binder(), OwnersAttentionSet.class)
-        .to(ownersAttentionSetImpl)
-        .in(Scopes.SINGLETON);
+    if (ownersAttentionSetImpl != null) {
+      DynamicItem.bind(binder(), OwnersAttentionSet.class)
+          .to(ownersAttentionSetImpl)
+          .in(Scopes.SINGLETON);
+    }
     install(new AutoassignConfigModule());
   }
 }