2010-01-03 19:29:48 -05:00
<?xml version="1.0" encoding="UTF-8"?>
<!--
2011-04-09 06:20:17 -04:00
Copyright (C) 2011 Cloud Conscious, LLC. <info @ c l o u d c o n s c i o u s . c o m >
2010-01-03 19:29:48 -05:00
====================================================================
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 name= "shrinkblob" default= "shrinkblob" basedir= "." xmlns:artifact= "urn:maven-artifact-ant" >
<!-- maven must be available before we use it -->
2010-08-31 17:22:35 -04:00
<get src= "http://opensource.become.com/apache//maven/binaries/maven-ant-tasks-2.1.1.jar" dest= "maven-ant-tasks.jar" />
2010-01-03 19:29:48 -05:00
<!-- initialize maven tasks -->
2010-08-31 17:22:35 -04:00
<path id= "maven-ant-tasks.classpath" path= "maven-ant-tasks.jar" />
2010-01-03 19:29:48 -05:00
<typedef resource= "org/apache/maven/artifact/ant/antlib.xml" uri= "urn:maven-artifact-ant"
classpathref="maven-ant-tasks.classpath" />
<artifact:localRepository id= "local.repository" path= "${user.home}/.m2/repository" />
2010-08-27 20:26:49 -04:00
<artifact:remoteRepository id= "jclouds-snapshot.repository" url= "https://oss.sonatype.org/content/repositories/snapshots" />
2010-08-31 17:22:35 -04:00
<artifact:remoteRepository id= "shrinkwrap.repository" url= "https://repository.jboss.org/nexus/content/groups/public" />
2010-01-03 19:29:48 -05:00
<!-- Setup maven so that we can get latest version of jclouds, shrinkwrap, and jruby -->
<artifact:dependencies pathId= "shrinkwrap.classpath" >
2010-08-31 17:22:35 -04:00
<dependency groupId= "org.jboss.shrinkwrap" artifactId= "shrinkwrap-impl-base" version= "1.0.0-alpha-11" />
<dependency groupId= "org.jruby" artifactId= "jruby" version= "1.5.2" />
<dependency groupId= "org.jclouds" artifactId= "jclouds-allblobstore" version= "1.0-SNAPSHOT" />
2010-01-15 18:13:35 -05:00
<remoteRepository refid= "shrinkwrap.repository" />
2010-01-03 19:29:48 -05:00
<remoteRepository refid= "jclouds-snapshot.repository" />
<localRepository refid= "local.repository" />
</artifact:dependencies>
<input
message="What is the directory you'd like to upload?"
addproperty="dir"
/>
<input
message="What is the name of the zip you'd like ${dir} stored to?"
addproperty="zip"
/>
<input
message="What is the container you wish to store ${zip} in?"
addproperty="container"
/>
<input
2011-02-15 07:17:40 -05:00
message="Which provider would you like to use (transient,googlestorage,cloudonestorage,synaptic-storage,azureblob,cloudfiles-us,cloudfiles-uk,aws-s3,eucalyptus-partnercloud-s3,scaleup-storage)?"
validargs="transient,googlestorage,cloudonestorage,synaptic-storage,azureblob,cloudfiles-us,cloudfiles-uk,aws-s3,eucalyptus-partnercloud-s3,scaleup-storage"
2010-08-31 17:22:35 -04:00
addproperty="provider"
2010-01-03 19:29:48 -05:00
/>
<input
2010-08-31 17:22:35 -04:00
message="What is your identity on ${provider}?"
addproperty="identity"
2010-01-03 19:29:48 -05:00
/>
<input
2010-08-31 17:22:35 -04:00
message="What is the credential for ${identity}?"
addproperty="credential"
2010-01-03 19:29:48 -05:00
/>
2010-01-15 18:13:35 -05:00
<property name= "location" value= "default" />
2010-08-31 17:22:35 -04:00
<target name= "shrinkblob" >
2010-01-03 19:29:48 -05:00
<script language= "jruby" classpathref= "shrinkwrap.classpath" > < ![CDATA[
require 'java'
require 'jruby/core_ext'
include_class 'org.apache.tools.ant.Task'
include_class 'org.jclouds.blobstore.BlobStoreContextFactory'
2010-08-31 17:22:35 -04:00
include_class 'org.jboss.shrinkwrap.api.ShrinkWrap'
2010-01-03 19:29:48 -05:00
include_class 'org.jboss.shrinkwrap.api.exporter.ZipExporter'
include_class 'org.jboss.shrinkwrap.api.importer.ExplodedImporter'
include_class 'org.jboss.shrinkwrap.impl.base.ServiceExtensionLoader'
2010-01-03 19:44:15 -05:00
# correct the ant classloader so that extensions can be found
2010-01-03 19:29:48 -05:00
java.lang.Thread.currentThread().setContextClassLoader(ServiceExtensionLoader.new().getClass().getClassLoader())
2010-01-03 19:44:15 -05:00
2010-08-31 17:22:35 -04:00
print "creating the archive from ",$dir,"\n"
zipStream = ShrinkWrap.create(ExplodedImporter.java_class, $zip).importDirectory($dir).as(ZipExporter.java_class).exportZip()
2010-01-03 19:44:15 -05:00
2010-08-31 17:22:35 -04:00
print "connecting to provider ",$provider,"/",$container,"\n"
2010-01-03 19:44:15 -05:00
2010-08-31 17:22:35 -04:00
context = BlobStoreContextFactory.new().createContext($provider, $identity, $credential)
context.getBlobStore().createContainerInLocation(nil, $container)
2010-01-03 19:44:15 -05:00
2010-08-31 17:22:35 -04:00
print "uploading to ",$provider,"/",$container,"/",$zip,"\n"
context.createInputStreamMap($container).put($zip,zipStream);
2010-01-03 19:44:15 -05:00
2010-01-03 19:29:48 -05:00
context.close();
2010-08-31 17:22:35 -04:00
]]></script>
2010-01-03 19:29:48 -05:00
</target>
</project>