Isolate blame cache classes in cache directory
Change-Id: I2b7439e800b8ce9b3df7aba4fb39f447e5649b11
diff --git a/java/com/google/gitiles/BUILD b/java/com/google/gitiles/BUILD
index fc8d6ec..67e6151 100644
--- a/java/com/google/gitiles/BUILD
+++ b/java/com/google/gitiles/BUILD
@@ -1,38 +1,4 @@
-# TODO(davido): Move sources that depend on the rest of gitiles
-# out of the blame directory and move this rule into its own BUILD
-# file in blame directory.
-BLAME_CACHE_SRCS = ["blame/" + n for n in [
- "BlameCache.java",
- "BlameCacheImpl.java",
- "Region.java",
-]]
-
-java_library(
- name = "blame-cache",
- srcs = BLAME_CACHE_SRCS,
- visibility = ["//visibility:public"],
- deps = [
- "//lib:guava",
- "//lib/jgit",
- ],
-)
-
-load("@com_googlesource_gerrit_bazlets//tools:javadoc.bzl", "java_doc")
-
-java_doc(
- name = "blame-cache-javadoc",
- libs = [
- ":blame-cache",
- "//lib:guava",
- "//lib/jgit:jgit",
- ],
- pkgs = ["com.google.gitiles.blame"],
- title = "Blame Cache API Documentation",
- visibility = ["//visibility:public"],
-)
-
DEPS = [
- ":blame-cache",
"//lib:autolink",
"//lib:commons-lang3",
"//lib:gson",
@@ -49,6 +15,7 @@
"//lib/jgit:jgit-servlet",
"//lib/slf4j:slf4j-api",
"//lib/soy:soy",
+ "//java/com/google/gitiles/blame/cache",
]
DEPS_ALL = DEPS + [
@@ -64,10 +31,7 @@
java_library(
name = "servlet",
- srcs = glob(
- ["**/*.java"],
- exclude = BLAME_CACHE_SRCS,
- ),
+ srcs = glob(["**/*.java"]),
resource_strip_prefix = "resources",
resources = ["//resources/com/google/gitiles"],
visibility = ["//visibility:public"],
diff --git a/java/com/google/gitiles/GitilesFilter.java b/java/com/google/gitiles/GitilesFilter.java
index b815f12..59e8acd 100644
--- a/java/com/google/gitiles/GitilesFilter.java
+++ b/java/com/google/gitiles/GitilesFilter.java
@@ -26,9 +26,9 @@
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Maps;
-import com.google.gitiles.blame.BlameCache;
-import com.google.gitiles.blame.BlameCacheImpl;
import com.google.gitiles.blame.BlameServlet;
+import com.google.gitiles.blame.cache.BlameCache;
+import com.google.gitiles.blame.cache.BlameCacheImpl;
import com.google.gitiles.doc.DocServlet;
import java.io.File;
import java.io.IOException;
diff --git a/java/com/google/gitiles/GitilesServlet.java b/java/com/google/gitiles/GitilesServlet.java
index 3cf4fd2..56f4c61 100644
--- a/java/com/google/gitiles/GitilesServlet.java
+++ b/java/com/google/gitiles/GitilesServlet.java
@@ -14,7 +14,7 @@
package com.google.gitiles;
-import com.google.gitiles.blame.BlameCache;
+import com.google.gitiles.blame.cache.BlameCache;
import java.util.Enumeration;
import javax.annotation.Nullable;
import javax.servlet.Filter;
diff --git a/java/com/google/gitiles/blame/BlameServlet.java b/java/com/google/gitiles/blame/BlameServlet.java
index bff70c2..9eedf0c 100644
--- a/java/com/google/gitiles/blame/BlameServlet.java
+++ b/java/com/google/gitiles/blame/BlameServlet.java
@@ -26,6 +26,8 @@
import com.google.gitiles.CommitSoyData;
import com.google.gitiles.DateFormatter;
import com.google.gitiles.DateFormatter.Format;
+import com.google.gitiles.blame.cache.BlameCache;
+import com.google.gitiles.blame.cache.Region;
import com.google.gitiles.GitilesAccess;
import com.google.gitiles.GitilesView;
import com.google.gitiles.Renderer;
diff --git a/java/com/google/gitiles/blame/RegionAdapter.java b/java/com/google/gitiles/blame/RegionAdapter.java
index f2f1855..07104ef 100644
--- a/java/com/google/gitiles/blame/RegionAdapter.java
+++ b/java/com/google/gitiles/blame/RegionAdapter.java
@@ -17,6 +17,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.gitiles.DateFormatter;
+import com.google.gitiles.blame.cache.Region;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
diff --git a/java/com/google/gitiles/blame/cache/BUILD b/java/com/google/gitiles/blame/cache/BUILD
new file mode 100644
index 0000000..3f3e39b
--- /dev/null
+++ b/java/com/google/gitiles/blame/cache/BUILD
@@ -0,0 +1,23 @@
+java_library(
+ name = "cache",
+ srcs = glob(["**/*.java"]),
+ visibility = ["//visibility:public"],
+ deps = [
+ "//lib:guava",
+ "//lib/jgit",
+ ],
+)
+
+load("@com_googlesource_gerrit_bazlets//tools:javadoc.bzl", "java_doc")
+
+java_doc(
+ name = "cache-javadoc",
+ libs = [
+ ":cache",
+ "//lib:guava",
+ "//lib/jgit:jgit",
+ ],
+ pkgs = ["com.google.gitiles.blame.cache"],
+ title = "Blame Cache API Documentation",
+ visibility = ["//visibility:public"],
+)
diff --git a/java/com/google/gitiles/blame/BlameCache.java b/java/com/google/gitiles/blame/cache/BlameCache.java
similarity index 96%
rename from java/com/google/gitiles/blame/BlameCache.java
rename to java/com/google/gitiles/blame/cache/BlameCache.java
index 9ea4023..e7f9fca 100644
--- a/java/com/google/gitiles/blame/BlameCache.java
+++ b/java/com/google/gitiles/blame/cache/BlameCache.java
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gitiles.blame;
+package com.google.gitiles.blame.cache;
import java.io.IOException;
import java.util.List;
diff --git a/java/com/google/gitiles/blame/BlameCacheImpl.java b/java/com/google/gitiles/blame/cache/BlameCacheImpl.java
similarity index 99%
rename from java/com/google/gitiles/blame/BlameCacheImpl.java
rename to java/com/google/gitiles/blame/cache/BlameCacheImpl.java
index f960518..320bf49 100644
--- a/java/com/google/gitiles/blame/BlameCacheImpl.java
+++ b/java/com/google/gitiles/blame/cache/BlameCacheImpl.java
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gitiles.blame;
+package com.google.gitiles.blame.cache;
import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.hash;
diff --git a/java/com/google/gitiles/blame/Region.java b/java/com/google/gitiles/blame/cache/Region.java
similarity index 95%
rename from java/com/google/gitiles/blame/Region.java
rename to java/com/google/gitiles/blame/cache/Region.java
index 10ec0e3..17d280f 100644
--- a/java/com/google/gitiles/blame/Region.java
+++ b/java/com/google/gitiles/blame/cache/Region.java
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gitiles.blame;
+package com.google.gitiles.blame.cache;
import static com.google.common.base.Preconditions.checkArgument;
@@ -45,11 +45,11 @@
this.count = end - start;
}
- void setStart(int start) {
+ public void setStart(int start) {
this.start = start;
}
- int getStart() {
+ public int getStart() {
return start;
}
diff --git a/tools/maven/BUILD b/tools/maven/BUILD
index b2d424a..e6612cb 100644
--- a/tools/maven/BUILD
+++ b/tools/maven/BUILD
@@ -3,16 +3,16 @@
maven_package(
src = {
- "blame-cache": "//java/com/google/gitiles:libblame-cache-src.jar",
+ "blame-cache": "//java/com/google/gitiles/blame/cache:libcache-src.jar",
"gitiles-servlet": "//java/com/google/gitiles:libservlet-src.jar",
},
doc = {
- "blame-cache": "//java/com/google/gitiles:blame-cache-javadoc",
+ "blame-cache": "//java/com/google/gitiles/blame/cache:cache-javadoc",
"gitiles-servlet": "//java/com/google/gitiles:servlet-javadoc",
},
group = "com.google.gitiles",
jar = {
- "blame-cache": "//java/com/google/gitiles:blame-cache",
+ "blame-cache": "//java/com/google/gitiles/blame/cache",
"gitiles-servlet": "//java/com/google/gitiles:servlet",
},
repository = "gerrit-maven-repository",