Permalink
Browse files

Initial commit.

  • Loading branch information...
0 parents commit 3921d0421366974510b8d216c4e3065e81236d2e @technomancy technomancy committed Dec 14, 2011
Showing with 61 additions and 0 deletions.
  1. +8 −0 .gitignore
  2. +13 −0 README.md
  3. +9 −0 project.clj
  4. +11 −0 res/META-INF/plexus/components.xml
  5. +20 −0 src/s3_wagon/private.clj
@@ -0,0 +1,8 @@
+/pom.xml
+*jar
+/lib
+/classes
+/native
+/.lein-failures
+/checkouts
+/.lein-deps-sum
@@ -0,0 +1,13 @@
+# s3-wagon-private
+
+FIXME: write description
+
+## Usage
+
+FIXME: write
+
+## License
+
+Copyright (C) 2011 FIXME
+
+Distributed under the Eclipse Public License, the same as Clojure.
@@ -0,0 +1,9 @@
+(defproject s3-wagon-private "1.0.0-SNAPSHOT"
+ :description "Deploy artifacts to private S3 URLs."
+ :dependencies [[org.springframework.build.aws/org.springframework.build.aws.maven
+ "3.0.0.RELEASE"]
+ [org.apache.maven.wagon/wagon-provider-api "1.0"]]
+ :resources-path "res"
+ :aot [s3-wagon.private]
+ ;; plexus will freak out otherwise
+ :disable-implicit-clean true)
@@ -0,0 +1,11 @@
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.wagon.Wagon</role>
+ <role-hint>s3p</role-hint>
+ <implementation>s3.wagon.private.PrivateWagon</implementation>
+ <!-- <implementation>org.springframework.aws.maven.SimpleStorageServiceWagon</implementation> -->
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ </component>
+ </components>
+</component-set>
@@ -0,0 +1,20 @@
+(ns s3-wagon.private
+ (:import (org.jets3t.service.model S3Object)
+ (org.jets3t.service.acl AccessControlList)))
+
+(gen-class :name s3.wagon.private.PrivateWagon
+ :extends org.springframework.aws.maven.SimpleStorageServiceWagon)
+
+(defn get-field [this field]
+ (-> org.springframework.aws.maven.SimpleStorageServiceWagon
+ (.getDeclaredField field)
+ (doto (.setAccessible true))
+ (.get this)))
+
+(defn -putResource [this source destination progress]
+ (let [object (doto (S3Object. (str (get-field this "basedir") destination))
+ (.setAcl AccessControlList/REST_CANNED_PRIVATE)
+ (.setDataInputFile source)
+ (.setContentLength (.length source)))]
+ (-> (get-field this "service")
+ (.putObject (get-field this "bucket") object))))

0 comments on commit 3921d04

Please sign in to comment.