Merge pull request #3 from ugodiggi/master

Update gerrit-owners* plugins for gerrit 2.8
diff --git a/BUCK b/BUCK
new file mode 100644
index 0000000..da2e37a
--- /dev/null
+++ b/BUCK
@@ -0,0 +1,4 @@
+# Look in the subdirectories' BUCK files for gerrit_plugin targets.
+#
+# I would like to have all the gerrit_plugin targets defined here, but there can only
+# be a single gerrit_plugin target in each BUCK file.
diff --git a/common.defs b/common.defs
new file mode 100644
index 0000000..17f4c86
--- /dev/null
+++ b/common.defs
@@ -0,0 +1,51 @@
+include_defs('//lib/maven.defs')
+include_defs('//lib/prolog/prolog.defs')
+
+JACKSON_REV = '2.1.1'
+maven_jar(
+  name = 'jackson-core',
+  id = 'com.fasterxml.jackson.core:jackson-core:%s' % JACKSON_REV,
+  license = 'Apache2.0',
+)
+
+maven_jar(
+  name = 'jackson-databind',
+  id = 'com.fasterxml.jackson.core:jackson-databind:%s' % JACKSON_REV,
+  license = 'Apache2.0',
+)
+
+maven_jar(
+  name = 'jackson-annotations',
+  id = 'com.fasterxml.jackson.core:jackson-annotations:%s' % JACKSON_REV,
+  license = 'Apache2.0',
+)
+
+maven_jar(
+  name = 'jackson-dataformat-yaml',
+  id = 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:%s' % JACKSON_REV,
+  license = 'Apache2.0',
+)
+
+maven_jar(
+  name = 'gitective-core',
+  id = 'org.gitective:gitective-core:0.9.9',
+  license = 'Apache2.0',
+)
+
+EXTERNAL_DEPS = [
+  ':gitective-core',
+  ':jackson-core',
+  ':jackson-databind',
+  ':jackson-annotations',
+  ':jackson-dataformat-yaml',
+]
+
+# These are dependencies that must be made available to the plugins' libraries at compilation
+# time, but should not be included in the plugins' jar files since they will be provided
+# by the gerrit server jar.
+# For this reason all the intermediate java libraries that we build are java_library2 targets
+# rather than java_library.
+COMPILE_DEPS = [
+  '//:plugin-lib',
+  '//lib/prolog:prolog-cafe',
+]
diff --git a/gerrit-owners-autoassign/BUCK b/gerrit-owners-autoassign/BUCK
new file mode 100644
index 0000000..18d0393
--- /dev/null
+++ b/gerrit-owners-autoassign/BUCK
@@ -0,0 +1,16 @@
+include_defs('//plugins/gerrit-owners/common.defs')
+
+gerrit_plugin(
+  name = 'owners-autoassign',
+  srcs = glob([
+    'src/main/java/**/*.java',
+  ]),
+  manifest_entries = [
+    'Implementation-Title: Gerrit OWNERS autoassign plugin',
+    'Implementation-URL: https://github.com/vadims/gerrit-owners',
+    'Gerrit-PluginName: owners-autoassign',
+  ],
+  deps = [
+    '//plugins/gerrit-owners/gerrit-owners-common:common',
+  ] + EXTERNAL_DEPS,
+)
diff --git a/gerrit-owners-autoassign/pom.xml b/gerrit-owners-autoassign/pom.xml
deleted file mode 100644
index 13bfa28..0000000
--- a/gerrit-owners-autoassign/pom.xml
+++ /dev/null
@@ -1,93 +0,0 @@
-<!--
-Copyright (c) 2013 VMware, Inc. All Rights Reserved.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>com.github.vadims</groupId>
-    <artifactId>gerrit-owners-parent</artifactId>
-    <version>1.2-SNAPSHOT</version>
-  </parent>
-
-  <artifactId>gerrit-owners-autoassign</artifactId>
-  <packaging>jar</packaging>
-  <name>gerrit-owners-autoassign</name>
-  <description>Gerrit Plugin for using OWNERS files for automatically assigning code reviewers.</description>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-jar-plugin</artifactId>
-        <version>2.4</version>
-      </plugin>
-
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <version>2.3.2</version>
-        <configuration>
-          <source>1.6</source>
-          <target>1.6</target>
-          <encoding>UTF-8</encoding>
-        </configuration>
-      </plugin>
-
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-shade-plugin</artifactId>
-        <configuration>
-          <createDependencyReducedPom>false</createDependencyReducedPom>
-          <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
-          <artifactSet>
-            <excludes>
-              <exclude>com.gerritforge:*</exclude>
-              <exclude>com.google.gerrit:*</exclude>
-              <exclude>org.bouncycastle:*</exclude>
-              <exclude>org.slf4j:*</exclude>
-              <exclude>com.google.guava:*</exclude>
-              <exclude>org.eclipse.jgit:*</exclude>
-              <exclude>wsdl4j:wsdl4j:*</exclude>
-            </excludes>
-          </artifactSet>
-          <transformers>
-            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
-              <manifestEntries>
-                <Implementation-Vendor>VMware, Inc.</Implementation-Vendor>
-                <Implementation-URL>http://github.com/vadims/gerrit-owners</Implementation-URL>
-                <Implementation-Title>${Gerrit-ApiType} ${project.artifactId}</Implementation-Title>
-                <Implementation-Version>${project.version}</Implementation-Version>
-                <Gerrit-ApiType>${Gerrit-ApiType}</Gerrit-ApiType>
-                <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
-              </manifestEntries>
-            </transformer>
-          </transformers>
-        </configuration>
-        <executions>
-          <execution>
-            <phase>package</phase>
-            <goals>
-              <goal>shade</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-
-    </plugins>
-  </build>
-
-  <dependencies>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>gerrit-owners-common</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-
-    <dependency>
-      <groupId>com.google.gerrit</groupId>
-      <artifactId>gerrit-${Gerrit-ApiType}-api</artifactId>
-      <scope>provided</scope>
-    </dependency>
-  </dependencies>
-</project>
diff --git a/gerrit-owners-autoassign/src/main/java/com/vmware/gerrit/owners/common/GitRefListener.java b/gerrit-owners-autoassign/src/main/java/com/vmware/gerrit/owners/common/GitRefListener.java
index 39f07eb..d94b788 100644
--- a/gerrit-owners-autoassign/src/main/java/com/vmware/gerrit/owners/common/GitRefListener.java
+++ b/gerrit-owners-autoassign/src/main/java/com/vmware/gerrit/owners/common/GitRefListener.java
@@ -63,7 +63,7 @@
     try {
       repository = repositoryManager.openRepository(Project.NameKey.parse(projectName));
       try {
-        processUpdates(repository, event.getUpdates());
+        processEvent(repository, event);
       } finally {
         repository.close();
       }
@@ -72,30 +72,28 @@
     }
   }
 
-  private void processUpdates(Repository repository, List<Update> updates) {
-    for (Update update : updates) {
-      if (update.getRefName().startsWith(CHANGES_REF)) {
-        Change.Id id = Change.Id.fromRef(update.getRefName());
-        try {
-          Change change = db.get().changes().get(id);
-          PatchList patchList = getPatchList(update, change);
-          if (patchList != null) {
-            PathOwners owners = new PathOwners(accountResolver, repository, patchList);
-            reviewerManager.addReviewers(change, owners.get().values());
-          }
-        } catch (OrmException e) {
-          logger.warn("Could not open change: {}", id, e);
-        } catch (ReviewerManagerException e) {
-          logger.warn("Could not add reviewers for change: {}", id, e);
+  private void processEvent(Repository repository, Event event) {
+    if (event.getRefName().startsWith(CHANGES_REF)) {
+      Change.Id id = Change.Id.fromRef(event.getRefName());
+      try {
+        Change change = db.get().changes().get(id);
+        PatchList patchList = getPatchList(event, change);
+        if (patchList != null) {
+          PathOwners owners = new PathOwners(accountResolver, repository, patchList);
+          reviewerManager.addReviewers(change, owners.get().values());
         }
+      } catch (OrmException e) {
+        logger.warn("Could not open change: {}", id, e);
+      } catch (ReviewerManagerException e) {
+        logger.warn("Could not add reviewers for change: {}", id, e);
       }
     }
   }
 
-  private PatchList getPatchList(Update update, Change change) {
+  private PatchList getPatchList(Event event, Change change) {
     ObjectId newId = null;
-    if (update.getNewObjectId() != null) {
-      newId = ObjectId.fromString(update.getNewObjectId());
+    if (event.getNewObjectId() != null) {
+      newId = ObjectId.fromString(event.getNewObjectId());
     }
 
     PatchListKey plKey = new PatchListKey(change.getProject(), null, newId, IGNORE_NONE);
diff --git a/gerrit-owners-autoassign/src/main/java/com/vmware/gerrit/owners/common/ReviewerManager.java b/gerrit-owners-autoassign/src/main/java/com/vmware/gerrit/owners/common/ReviewerManager.java
index 571d0b4..d7ba7a3 100644
--- a/gerrit-owners-autoassign/src/main/java/com/vmware/gerrit/owners/common/ReviewerManager.java
+++ b/gerrit-owners-autoassign/src/main/java/com/vmware/gerrit/owners/common/ReviewerManager.java
@@ -17,6 +17,7 @@
 import javax.inject.Inject;
 import javax.inject.Provider;
 import javax.inject.Singleton;
+import java.io.IOException;
 import java.util.Collection;
 
 @Singleton
@@ -58,6 +59,8 @@
       throw new ReviewerManagerException(e);
     } catch (OrmException e) {
       throw new ReviewerManagerException(e);
+    } catch (IOException e) {
+      throw new ReviewerManagerException(e);
     }
   }
 }
diff --git a/gerrit-owners-common/BUCK b/gerrit-owners-common/BUCK
new file mode 100644
index 0000000..ea5fb6a
--- /dev/null
+++ b/gerrit-owners-common/BUCK
@@ -0,0 +1,14 @@
+include_defs('//plugins/gerrit-owners/common.defs')
+
+# see common.defs on why this is a java_library2 rather than java_library
+java_library2(
+  name = 'common',
+  srcs = glob([
+    'src/main/java/**/*.java',
+  ]),
+  deps = [],
+  # Notice that we put EXTERNAL_DEPS as compile_deps to prevent double inclusion in the owners
+  # plugin.
+  compile_deps = COMPILE_DEPS + EXTERNAL_DEPS,
+  visibility = ['PUBLIC'],
+)
diff --git a/gerrit-owners-common/pom.xml b/gerrit-owners-common/pom.xml
deleted file mode 100644
index 6f8dac6..0000000
--- a/gerrit-owners-common/pom.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<!--
-Copyright (c) 2013 VMware, Inc. All Rights Reserved.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>com.github.vadims</groupId>
-    <artifactId>gerrit-owners-parent</artifactId>
-    <version>1.2-SNAPSHOT</version>
-  </parent>
-
-  <artifactId>gerrit-owners-common</artifactId>
-  <packaging>jar</packaging>
-  <name>gerrit-owners-common</name>
-  <description>Gerrit OWNERS and Auto-Assign plugin common utilities.</description>
-
-  <properties>
-    <jacksonVersion>2.2.0</jacksonVersion>
-  </properties>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-jar-plugin</artifactId>
-        <version>2.4</version>
-      </plugin>
-
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <version>2.3.2</version>
-        <configuration>
-          <source>1.6</source>
-          <target>1.6</target>
-          <encoding>UTF-8</encoding>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-
-  <dependencies>
-    <dependency>
-      <groupId>com.google.gerrit</groupId>
-      <artifactId>gerrit-${Gerrit-ApiType}-api</artifactId>
-      <scope>provided</scope>
-    </dependency>
-
-    <dependency>
-      <groupId>org.gitective</groupId>
-      <artifactId>gitective-core</artifactId>
-      <version>0.9.9</version>
-    </dependency>
-
-    <dependency>
-      <groupId>com.fasterxml.jackson.core</groupId>
-      <artifactId>jackson-core</artifactId>
-      <version>${jacksonVersion}</version>
-    </dependency>
-
-    <dependency>
-      <groupId>com.fasterxml.jackson.core</groupId>
-      <artifactId>jackson-databind</artifactId>
-      <version>${jacksonVersion}</version>
-    </dependency>
-
-    <dependency>
-      <groupId>com.fasterxml.jackson.dataformat</groupId>
-      <artifactId>jackson-dataformat-yaml</artifactId>
-      <version>${jacksonVersion}</version>
-    </dependency>
-  </dependencies>
-</project>
diff --git a/gerrit-owners/BUCK b/gerrit-owners/BUCK
new file mode 100644
index 0000000..0ef0040
--- /dev/null
+++ b/gerrit-owners/BUCK
@@ -0,0 +1,42 @@
+include_defs('//plugins/gerrit-owners/common.defs')
+
+# buck is unhappy to build a gerrit_plugin with no source files.
+# On the other side, gerrit-owners-prolog-rules needs to be built after all the java files have been
+# compiled. For this reason we have a stub class that has no content and just makes buck happy.
+COMPILE_STUB = ['src/main/java/com/vmware/gerrit/owners/CompileStub.java']
+
+java_library2(
+  name = 'gerrit-owners-lib',
+  srcs = glob([
+    'src/main/java/**/*.java',
+  ], excludes=COMPILE_STUB),
+  deps = [
+    '//plugins/gerrit-owners/gerrit-owners-common:common',
+  ],
+  # Notice that we put EXTERNAL_DEPS as compile_deps to prevent double inclusion in the owners
+  # plugin.
+  compile_deps = COMPILE_DEPS + EXTERNAL_DEPS,
+)
+
+prolog_cafe_library(
+  name = 'gerrit-owners-prolog-rules',
+  srcs = glob(['src/main/prolog/*.pl']),
+  deps = [
+    ':gerrit-owners-lib',
+    '//gerrit-server/src/main/prolog:common',
+  ],
+)
+
+gerrit_plugin(
+  name = 'owners',
+  srcs = COMPILE_STUB,
+  manifest_entries = [
+    'Implementation-Title: Gerrit OWNERS plugin',
+    'Implementation-URL: https://github.com/vadims/gerrit-owners',
+    'Gerrit-PluginName: owners',
+  ],
+  deps = [
+    ':gerrit-owners-lib',
+    ':gerrit-owners-prolog-rules',
+  ] + EXTERNAL_DEPS,
+)
diff --git a/gerrit-owners/pom.xml b/gerrit-owners/pom.xml
deleted file mode 100644
index 4b545e0..0000000
--- a/gerrit-owners/pom.xml
+++ /dev/null
@@ -1,146 +0,0 @@
-<!--
-Copyright (c) 2013 VMware, Inc. All Rights Reserved.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>com.github.vadims</groupId>
-    <artifactId>gerrit-owners-parent</artifactId>
-    <version>1.2-SNAPSHOT</version>
-  </parent>
-
-  <artifactId>gerrit-owners</artifactId>
-  <packaging>jar</packaging>
-  <name>gerrit-owners</name>
-  <description>
-    Gerrit Plugin that provides a Prolog predicate for enabling per directory code review requirements.
-  </description>
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-jar-plugin</artifactId>
-      </plugin>
-
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-      </plugin>
-
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-antrun-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>prolog-to-java</id>
-            <phase>generate-sources</phase>
-            <goals>
-              <goal>run</goal>
-            </goals>
-            <configuration>
-              <target>
-                <property name="gensrc" location="${project.build.directory}/generated-sources" />
-
-                <java classname="com.googlecode.prolog_cafe.compiler.Compiler" fork="true" failonerror="true" classpathref="maven.compile.classpath">
-                  <arg value="--show-stack-trace" />
-                  <arg value="-O" />
-                  <arg value="-am" /><arg value="${gensrc}/prolog-am" />
-                  <arg value="-s" /><arg value="${gensrc}/prolog-java" />
-                  <arg value="src/main/prolog/gerrit_owners.pl" />
-                </java>
-              </target>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-
-      <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>build-helper-maven-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>add-source</id>
-            <phase>generate-sources</phase>
-            <goals>
-              <goal>add-source</goal>
-            </goals>
-            <configuration>
-              <sources>
-                <source>${project.build.directory}/generated-sources/prolog-java</source>
-              </sources>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-shade-plugin</artifactId>
-        <configuration>
-          <createDependencyReducedPom>false</createDependencyReducedPom>
-          <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
-          <artifactSet>
-            <excludes>
-              <exclude>com.gerritforge:*</exclude>
-              <exclude>com.google.gerrit:*</exclude>
-              <exclude>org.bouncycastle:*</exclude>
-              <exclude>org.slf4j:*</exclude>
-              <exclude>com.google.guava:*</exclude>
-              <exclude>org.eclipse.jgit:*</exclude>
-              <exclude>wsdl4j:wsdl4j:*</exclude>
-            </excludes>
-          </artifactSet>
-          <transformers>
-            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
-              <manifestEntries>
-                <Implementation-Vendor>VMware, Inc.</Implementation-Vendor>
-                <Implementation-URL>http://github.com/vadims/gerrit-owners</Implementation-URL>
-                <Implementation-Title>${Gerrit-ApiType} ${project.artifactId}</Implementation-Title>
-                <Implementation-Version>${project.version}</Implementation-Version>
-                <Gerrit-ApiType>${Gerrit-ApiType}</Gerrit-ApiType>
-                <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
-              </manifestEntries>
-            </transformer>
-          </transformers>
-        </configuration>
-        <executions>
-          <execution>
-            <phase>package</phase>
-            <goals>
-              <goal>shade</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-
-    </plugins>
-  </build>
-
-  <dependencies>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>gerrit-owners-common</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-
-    <dependency>
-      <groupId>com.google.gerrit</groupId>
-      <artifactId>gerrit-${Gerrit-ApiType}-api</artifactId>
-      <scope>provided</scope>
-    </dependency>
-
-    <dependency>
-      <groupId>com.google.gerrit</groupId>
-      <artifactId>gerrit-server</artifactId>
-      <scope>provided</scope>
-    </dependency>
-
-    <dependency>
-      <groupId>com.googlecode.prolog-cafe</groupId>
-      <artifactId>PrologCafe</artifactId>
-      <version>1.3</version>
-      <scope>provided</scope>
-    </dependency>
-  </dependencies>
-</project>
diff --git a/gerrit-owners/src/main/java/com/vmware/gerrit/owners/CompileStub.java b/gerrit-owners/src/main/java/com/vmware/gerrit/owners/CompileStub.java
new file mode 100644
index 0000000..c378ff0
--- /dev/null
+++ b/gerrit-owners/src/main/java/com/vmware/gerrit/owners/CompileStub.java
@@ -0,0 +1,7 @@
+package com.vmware.gerrit.owners;
+
+/**
+ * A stub class only used for pleasing BUCK.
+ */
+public class CompileStub {
+}
diff --git a/gerrit-owners/src/main/java/com/vmware/gerrit/owners/OwnerPredicateProvider.java b/gerrit-owners/src/main/java/com/vmware/gerrit/owners/OwnerPredicateProvider.java
index 73d5b0f..3809269 100644
--- a/gerrit-owners/src/main/java/com/vmware/gerrit/owners/OwnerPredicateProvider.java
+++ b/gerrit-owners/src/main/java/com/vmware/gerrit/owners/OwnerPredicateProvider.java
@@ -4,15 +4,22 @@
 package com.vmware.gerrit.owners;
 
 
+import com.google.inject.Inject;
 import com.google.common.collect.ImmutableSet;
 import com.google.gerrit.extensions.annotations.Listen;
 import com.google.gerrit.rules.PredicateProvider;
+import com.google.gerrit.server.account.AccountResolver;
 
 /**
  * Gerrit OWNERS Prolog Predicate Provider.
  */
 @Listen
 public class OwnerPredicateProvider implements PredicateProvider {
+  @Inject
+  public OwnerPredicateProvider(AccountResolver resolver) {
+    OwnersStoredValues.initialize(resolver);
+  }
+
   @Override
   public ImmutableSet<String> getPackages() {
     return ImmutableSet.of("gerrit_owners");
diff --git a/gerrit-owners/src/main/java/com/vmware/gerrit/owners/OwnersStoredValues.java b/gerrit-owners/src/main/java/com/vmware/gerrit/owners/OwnersStoredValues.java
index e355bfc..66c3154 100644
--- a/gerrit-owners/src/main/java/com/vmware/gerrit/owners/OwnersStoredValues.java
+++ b/gerrit-owners/src/main/java/com/vmware/gerrit/owners/OwnersStoredValues.java
@@ -14,28 +14,40 @@
 import com.googlecode.prolog_cafe.lang.Prolog;
 import com.googlecode.prolog_cafe.lang.SystemException;
 import org.eclipse.jgit.lib.Repository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 
 /**
  * StoredValues for the Gerrit OWNERS plugin.
  */
 public class OwnersStoredValues {
+  private static final Logger log = LoggerFactory.getLogger(OwnersStoredValues.class);
 
-  public static StoredValue<PathOwners> PATH_OWNERS = new StoredValue<PathOwners>() {
-    @Override
-    protected PathOwners createValue(Prolog engine) {
-      PatchList patchList = StoredValues.PATCH_LIST.get(engine);
-      Repository repository = StoredValues.REPOSITORY.get(engine);
+  public static StoredValue<PathOwners> PATH_OWNERS;
 
-      PrologEnvironment env = (PrologEnvironment) engine.control;
-      AccountResolver resolver = env.getInjector().getInstance(AccountResolver.class);
-
-      try {
-        return new PathOwners(resolver, repository, patchList);
-      } catch (OrmException e) {
-        throw new SystemException(e.getMessage());
-      }
+  synchronized
+  public static void initialize(final AccountResolver resolver) {
+    if (PATH_OWNERS != null) {
+      return;
     }
-  };
+    log.error("Initializing OwnerStoredValues");
+    PATH_OWNERS = new StoredValue<PathOwners>() {
+      @Override
+      protected PathOwners createValue(Prolog engine) {
+        PatchList patchList = StoredValues.PATCH_LIST.get(engine);
+        Repository repository = StoredValues.REPOSITORY.get(engine);
+
+        PrologEnvironment env = (PrologEnvironment) engine.control;
+
+        try {
+          return new PathOwners(resolver, repository, patchList);
+        } catch (OrmException e) {
+          throw new SystemException(e.getMessage());
+        }
+      }
+    };
+  }
 
   private OwnersStoredValues() {
   }
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 0a217e0..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,164 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright (c) 2013 VMware, Inc. All Rights Reserved.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>org.sonatype.oss</groupId>
-    <artifactId>oss-parent</artifactId>
-    <version>7</version>
-  </parent>
-
-  <groupId>com.github.vadims</groupId>
-  <artifactId>gerrit-owners-parent</artifactId>
-  <packaging>pom</packaging>
-  <version>1.2-SNAPSHOT</version>
-
-  <name>gerrit-owners-parent</name>
-  <description>Parent project of gerrit-owners and gerrit-owners-autoassign.</description>
-  <url>http://github.com/vadims/gerrit-owners</url>
-
-  <developers>
-    <developer>
-      <name>Vadim Spivak</name>
-      <email>vadim@spivak.net</email>
-      <organization>VMware, Inc.</organization>
-    </developer>
-  </developers>
-
-  <licenses>
-    <license>
-      <name>The Apache Software License, Version 2.0</name>
-      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
-    </license>
-  </licenses>
-
-  <scm>
-    <connection>scm:git:git@github.com:vadims/gerrit-owners.git</connection>
-    <url>scm:git:git@github.com:vadims/gerrit-owners.git</url>
-    <developerConnection>scm:git:git@github.com:vadims/gerrit-owners.git</developerConnection>
-    <tag>HEAD</tag>
-  </scm>
-
-  <properties>
-    <Gerrit-ApiType>plugin</Gerrit-ApiType>
-    <Gerrit-ApiVersion>2.6-rc1</Gerrit-ApiVersion>
-
-    <project.build.sourceEncoding>
-      UTF-8
-    </project.build.sourceEncoding>
-    <project.reporting.outputEncoding>
-      UTF-8
-    </project.reporting.outputEncoding>
-  </properties>
-
-  <modules>
-    <module>gerrit-owners</module>
-    <module>gerrit-owners-autoassign</module>
-    <module>gerrit-owners-common</module>
-  </modules>
-
-  <build>
-    <pluginManagement>
-      <plugins>
-        <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-jar-plugin</artifactId>
-          <version>2.4</version>
-        </plugin>
-
-        <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-compiler-plugin</artifactId>
-          <version>2.3.2</version>
-        </plugin>
-
-        <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-shade-plugin</artifactId>
-          <version>1.6</version>
-        </plugin>
-
-        <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-antrun-plugin</artifactId>
-          <version>1.7</version>
-        </plugin>
-
-        <plugin>
-          <groupId>org.codehaus.mojo</groupId>
-          <artifactId>build-helper-maven-plugin</artifactId>
-          <version>1.8</version>
-        </plugin>
-      </plugins>
-    </pluginManagement>
-
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <configuration>
-          <source>1.6</source>
-          <target>1.6</target>
-          <encoding>UTF-8</encoding>
-        </configuration>
-      </plugin>
-
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-release-plugin</artifactId>
-        <version>2.4.1</version>
-        <configuration>
-          <pushChanges>false</pushChanges>
-          <tagNameFormat>v@{project.version}</tagNameFormat>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-
-  <dependencies>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <scope>test</scope>
-    </dependency>
-
-    <dependency>
-      <groupId>org.easymock</groupId>
-      <artifactId>easymock</artifactId>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
-
-  <dependencyManagement>
-    <dependencies>
-      <dependency>
-        <groupId>com.google.gerrit</groupId>
-        <artifactId>gerrit-${Gerrit-ApiType}-api</artifactId>
-        <version>${Gerrit-ApiVersion}</version>
-        <scope>provided</scope>
-      </dependency>
-
-      <dependency>
-        <groupId>com.google.gerrit</groupId>
-        <artifactId>gerrit-server</artifactId>
-        <version>${Gerrit-ApiVersion}</version>
-        <scope>provided</scope>
-      </dependency>
-
-      <dependency>
-        <groupId>junit</groupId>
-        <artifactId>junit</artifactId>
-        <version>4.11</version>
-      </dependency>
-
-      <dependency>
-        <groupId>org.easymock</groupId>
-        <artifactId>easymock</artifactId>
-        <version>3.0</version>
-      </dependency>
-    </dependencies>
-  </dependencyManagement>
-</project>