 (defn protoc
   "Create .java and .class files from the provided .proto files."
   ([project protos]
-     (protoc project protos (io/file (:target-dir project) "protosrc")))
+     (protoc project protos (io/file (target project) "protosrc")))
   ([project protos dest]
-     (let [target (:target-dir project)
+     (let [target (target project)
+           dest (.getAbsoluteFile dest)
            dest-path (.getPath dest)
-           proto-path (or (:proto-path project) "proto")]
+           proto-path (.getAbsoluteFile (io/file (or (:proto-path project) "proto")))]
        (when (or (> (modtime proto-path) (modtime dest))
                  (> (modtime proto-path) (modtime "classes")))
          (.mkdirs dest)
-         (.mkdir (io/file target "proto"))
+         (.mkdirs proto-path)
          (doseq [proto protos]
            (extract-dependencies (io/file proto-path proto) target)
-           (let [args ["protoc" proto (str "--java_out=" dest-path) "-I." (str "-I" target proto-path)]]
+           (let [args ["protoc" proto (str "--java_out=" dest-path) "-I."
+                       (str "-I" proto-path)]]
              (println " > " (join " " args))
              (let [protoc-result (apply sh/proc (concat args [:dir proto-path]))]
                (if (not (= (sh/exit-code protoc-result) 0))

  (when (installed?)
    (let [password (read-pass)
          proc (sh/proc "sudo" "-S" "make" "uninstall"
                        :dir (io/file (:target-dir project) srcdir))]
      (sh/feed-from-string proc (str password "\n"))
      (sh/stream-to-out proc :out))))


  [project]
  (when-not (installed?)
    (fetch project)
    (let [source (io/file (target project) srcdir)]
      (when-not (.exists (io/file source "src" "protoc"))
        (fs/chmod "+x" (io/file source "configure"))
        (fs/chmod "+x" (io/file source "install-sh"))
