Gitiles: Implement Buck driven build

Until extension system is released by Buck team [1], factor out
existing Buck building blocks as Bucklets in standalone git
repository and reuse it as Git submodule to implement Buck driven
build [2].

To build gitiles `gitiles` target is used:

  buck build gitiles

To build servlet, sources and javadoc in addition, `all` target is used:

  buck build all

that produces:

  buck-out/gen/gitiles.war
  buck-out/gen/servlet.jar
  buck-out/gen/src.jar
  buck-out/gen/javadoc.jar

To execute the tests:

  buck test --all

To generate eclipse project:

  bucklets/tools/eclipse.py

To fetch sources for all dependent libraries too:

  bucklets/tools/eclipse.py --src

To install gitiles-servlet into local Maven repository:

  buck build mvn_install

To deploy gitiles-servlet into remote Maven repository:

  buck build mvn_deploy

[1] http://stackoverflow.com/questions/16681527/buck-vs-gradle-pros-and-cons-for-android-build-systems
[2] https://gerrit.googlesource.com/bucklets

Change-Id: Ib824dac6423d69c298f9c30ed7a0c05b4d6447c0
diff --git a/gitiles-war/BUCK b/gitiles-war/BUCK
new file mode 100644
index 0000000..7b5dd36
--- /dev/null
+++ b/gitiles-war/BUCK
@@ -0,0 +1,21 @@
+include_defs('//bucklets/war.bucklet')
+
+war(
+  name = 'gitiles',
+  libs = ['//gitiles-servlet:servlet'],
+  context = [
+    '//gitiles-servlet:static-resources.zip',
+    ':web_xml.zip',
+  ],
+  visibility = ['PUBLIC'],
+)
+
+genrule(
+  name = 'web_xml',
+  cmd = 'mkdir -p $TMP/WEB-INF'
+    + ';cp -r $SRCDIR/src/main/webapp/WEB-INF/web.xml $TMP/WEB-INF'
+    + ';cd $TMP'
+    + ';zip -qr $OUT *',
+  srcs = ['src/main/webapp/WEB-INF/web.xml'],
+  out = 'web_xml.zip',
+)
diff --git a/gitiles-war/pom.xml b/gitiles-war/pom.xml
deleted file mode 100644
index b5369ce..0000000
--- a/gitiles-war/pom.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright 2012 Google Inc. All Rights Reserved.
-
-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.
--->
-<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.google.gitiles</groupId>
-    <artifactId>gitiles-parent</artifactId>
-    <version>1.0-SNAPSHOT</version>
-  </parent>
-
-  <artifactId>gitiles-war</artifactId>
-  <packaging>war</packaging>
-  <name>Gitiles - WAR</name>
-
-  <description>
-    Gitiles packaged as a standard web application archive
-  </description>
-
-  <dependencies>
-    <dependency>
-      <groupId>com.google.gitiles</groupId>
-      <artifactId>gitiles-servlet</artifactId>
-      <version>${project.version}</version>
-      <scope>runtime</scope>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-war-plugin</artifactId>
-        <configuration>
-          <webResources>
-            <resource>
-              <directory>../gitiles-servlet/src/main/resources/com/google/gitiles/static</directory>
-              <targetPath>+static</targetPath>
-            </resource>
-          </webResources>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-</project>