mirror of https://github.com/apache/jclouds.git
110 lines
4.4 KiB
XML
110 lines
4.4 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!--
|
|
|
|
|
|
Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
|
|
====================================================================
|
|
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 -->
|
|
<get src="http://opensource.become.com/apache//maven/binaries/maven-ant-tasks-2.1.1.jar" dest="maven-ant-tasks.jar"/>
|
|
|
|
<!-- initialize maven tasks -->
|
|
<path id="maven-ant-tasks.classpath" path="maven-ant-tasks.jar" />
|
|
<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" />
|
|
<artifact:remoteRepository id="jclouds-snapshot.repository" url="https://oss.sonatype.org/content/repositories/snapshots" />
|
|
<artifact:remoteRepository id="shrinkwrap.repository" url="https://repository.jboss.org/nexus/content/groups/public" />
|
|
|
|
<!-- Setup maven so that we can get latest version of jclouds, shrinkwrap, and jruby -->
|
|
<artifact:dependencies pathId="shrinkwrap.classpath">
|
|
<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" />
|
|
<remoteRepository refid="shrinkwrap.repository" />
|
|
<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
|
|
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"
|
|
addproperty="provider"
|
|
/>
|
|
|
|
<input
|
|
message="What is your identity on ${provider}?"
|
|
addproperty="identity"
|
|
/>
|
|
|
|
<input
|
|
message="What is the credential for ${identity}?"
|
|
addproperty="credential"
|
|
/>
|
|
|
|
<property name="location" value="default" />
|
|
|
|
<target name="shrinkblob">
|
|
<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'
|
|
include_class 'org.jboss.shrinkwrap.api.ShrinkWrap'
|
|
include_class 'org.jboss.shrinkwrap.api.exporter.ZipExporter'
|
|
include_class 'org.jboss.shrinkwrap.api.importer.ExplodedImporter'
|
|
include_class 'org.jboss.shrinkwrap.impl.base.ServiceExtensionLoader'
|
|
|
|
# correct the ant classloader so that extensions can be found
|
|
java.lang.Thread.currentThread().setContextClassLoader(ServiceExtensionLoader.new().getClass().getClassLoader())
|
|
|
|
print "creating the archive from ",$dir,"\n"
|
|
zipStream = ShrinkWrap.create(ExplodedImporter.java_class, $zip).importDirectory($dir).as(ZipExporter.java_class).exportZip()
|
|
|
|
print "connecting to provider ",$provider,"/",$container,"\n"
|
|
|
|
context = BlobStoreContextFactory.new().createContext($provider, $identity, $credential)
|
|
context.getBlobStore().createContainerInLocation(nil, $container)
|
|
|
|
print "uploading to ",$provider,"/",$container,"/",$zip,"\n"
|
|
context.createInputStreamMap($container).put($zip,zipStream);
|
|
|
|
context.close();
|
|
|
|
]]></script>
|
|
</target>
|
|
|
|
</project>
|