jclouds/demos/antjruby/build.xml

111 lines
4.2 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="UTF-8"?>
<!--
2010-08-31 17:22:35 -04:00
Copyright (C) 2010 Cloud Conscious, LLC. <infocloudconscious.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.
====================================================================
-->
2010-08-12 19:04:26 -04:00
<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"/>
<!-- initialize maven tasks -->
2010-08-31 17:22:35 -04:00
<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" />
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" />
<!-- 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" />
<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
2010-08-31 17:22:35 -04:00
message="Which provider would you like to use (transient,atmos,azureblob,cloudfiles,s3)?"
validargs="transient,atmos,azureblob,cloudfiles,s3"
addproperty="provider"
/>
<input
2010-08-31 17:22:35 -04:00
message="What is your identity on ${provider}?"
addproperty="identity"
/>
<input
2010-08-31 17:22:35 -04:00
message="What is the credential for ${identity}?"
addproperty="credential"
/>
<property name="location" value="default" />
2010-08-31 17:22:35 -04:00
<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'
2010-08-31 17:22:35 -04:00
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())
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-08-31 17:22:35 -04:00
print "connecting to provider ",$provider,"/",$container,"\n"
2010-08-31 17:22:35 -04:00
context = BlobStoreContextFactory.new().createContext($provider, $identity, $credential)
context.getBlobStore().createContainerInLocation(nil, $container)
2010-08-31 17:22:35 -04:00
print "uploading to ",$provider,"/",$container,"/",$zip,"\n"
context.createInputStreamMap($container).put($zip,zipStream);
context.close();
2010-08-31 17:22:35 -04:00
]]></script>
</target>
</project>