Split pgm:init rule into init and util

We have a package boundary between these rules, so a rule boundary
also makes sense.

Change-Id: Ie9669b6628552c8b6b5ac2e8bd0841b5fb50d1c9
diff --git a/gerrit-acceptance-tests/BUCK b/gerrit-acceptance-tests/BUCK
index d631bf4..4549c47 100644
--- a/gerrit-acceptance-tests/BUCK
+++ b/gerrit-acceptance-tests/BUCK
@@ -10,6 +10,7 @@
     '//gerrit-httpd:httpd',
     '//gerrit-pgm:init',
     '//gerrit-pgm:pgm',
+    '//gerrit-pgm:util',
     '//gerrit-reviewdb:server',
     '//gerrit-server:server',
     '//gerrit-server:testutil',
diff --git a/gerrit-pgm/BUCK b/gerrit-pgm/BUCK
index e553288..8e40ee1 100644
--- a/gerrit-pgm/BUCK
+++ b/gerrit-pgm/BUCK
@@ -24,20 +24,7 @@
   visibility = ['PUBLIC'],
 )
 
-INIT_SRCS = [SRCS + 'BaseInit.java'] + glob(
-    [SRCS + n for n in [
-      'init/*.java',
-      'util/**/*.java',
-    ]],
-    excludes = [SRCS + n for n in [
-      'init/Browser.java',
-      'util/ErrorLogFile.java',
-      'util/GarbageCollectionLogFile.java',
-      'util/LogFileCompressor.java',
-      'util/RuntimeShutdown.java',
-    ]]
-  )
-
+INIT_SRCS = [SRCS + 'BaseInit.java'] + glob([SRCS + 'init/*.java'])
 INIT_RSRCS = ['src/main/resources/com/google/gerrit/pgm/libraries.config']
 
 java_library(
@@ -46,6 +33,7 @@
   resources = INIT_RSRCS,
   deps = [
     ':init-api',
+    ':util',
     '//gerrit-common:server',
     '//gerrit-extension-api:api',
     '//gerrit-lucene:lucene',
@@ -61,6 +49,7 @@
     '//lib:guava',
     '//lib:gwtjsonrpc',
     '//lib:gwtorm',
+    '//lib:h2',
     '//lib/log:api',
   ],
   provided_deps = ['//gerrit-launcher:launcher'],
@@ -70,11 +59,36 @@
   ],
 )
 
+UTIL_SRCS = glob([SRCS + 'util/*.java'])
+
+java_library(
+  name = 'util',
+  srcs = UTIL_SRCS,
+  deps = [
+    '//gerrit-common:server',
+    '//gerrit-extension-api:api',
+    '//gerrit-server:server',
+    '//gerrit-util-cli:cli',
+    '//lib:args4j',
+    '//lib:guava',
+    '//lib:gwtorm',
+    '//lib/commons:dbcp',
+    '//lib/guice:guice',
+    '//lib/jgit:jgit',
+    '//lib/log:api',
+    '//lib/log:log4j',
+  ],
+  visibility = [
+    '//gerrit-war:',
+    '//gerrit-acceptance-tests/...',
+  ],
+)
+
 java_library(
   name = 'pgm',
   srcs = glob(
     ['src/main/java/**/*.java'],
-    excludes = INIT_API_SRCS + INIT_SRCS
+    excludes = INIT_API_SRCS + INIT_SRCS + UTIL_SRCS
   ),
   resources = glob(
     ['src/main/resources/**/*'],
@@ -82,6 +96,7 @@
   deps = [
     ':init',
     ':init-api',
+    ':util',
     '//gerrit-cache-h2:cache-h2',
     '//gerrit-common:server',
     '//gerrit-extension-api:api',
diff --git a/gerrit-war/BUCK b/gerrit-war/BUCK
index 030366d..2a04402 100644
--- a/gerrit-war/BUCK
+++ b/gerrit-war/BUCK
@@ -11,6 +11,7 @@
     '//gerrit-openid:openid',
     '//gerrit-pgm:init',
     '//gerrit-pgm:init-api',
+    '//gerrit-pgm:util',
     '//gerrit-reviewdb:server',
     '//gerrit-server:server',
     '//gerrit-server/src/main/prolog:common',