 (ns leiningen.protobuf
+  (:refer-clojure :exclude [compile])
   (:use [clojure.java.shell :only [sh]]
         [clojure.string :only [join]]
         [leiningen.help :only [help-for]]

               "http://protobuf.googlecode.com/files/protobuf-%s.zip"
               version)))

(defn- unzip [source target-dir] 
  (let [zip (ZipFile. source)
        entries (enumeration-seq (.entries zip))
        target-file #(io/file target-dir (.getName %))]

             :dir "proto"))
       (javac (assoc project :java-source-path dest)))))

(defn compile-google-protobuf
  "Compile com.google.protobuf.*"
  [project]
  (let [proto-files (io/file "proto/google/protobuf")]
    (.mkdirs proto-files)
    (io/copy (io/file (str srcdir "/src/google/protobuf/descriptor.proto"))
             (io/file proto-files "descriptor.proto")))
  (protoc project
          ["google/protobuf/descriptor.proto"]
          (str srcdir "/java/src/main/java")))

(defn compile
  "Compile protocol buffer files located in proto dir."
  ([project] (compile project (proto-files (io/file "proto"))))
  ([project files]
     (install)
     (fetch)
     (when (= "protobuf" (:name project))
       (compile-google-protobuf project))
     (protoc project files)))

(defn ^{:doc "Tasks for installing and uninstalling protobuf libraries."
        :help-arglists '([subtask & args])
