Permalink
Browse files

Adding a ZIP file artifact and restructuring phar file. Addresses #47.

  • Loading branch information...
1 parent 6f554ec commit 1f6c8e56d6f1e5cf0ec823cef8ef1687f2bde490 @mtdowling mtdowling committed May 1, 2013
Showing with 119 additions and 34 deletions.
  1. +81 −19 build.xml
  2. +35 −0 build/aws-autoloader.php
  3. +2 −14 build/phar-stub.php
  4. +1 −1 composer.json
View
100 build.xml
@@ -43,30 +43,92 @@
</if>
</target>
- <target name="phar" description="Create a phar with an autoloader">
- <phingcall target="test-init" />
- <pharpackage destfile="build/aws.phar" stub="build/phar-stub.php" basedir=".">
- <fileset dir=".">
- <!-- Add AWS classes -->
- <include name="src/**/*.php" />
- <include name="src/**/*.json" />
- <include name="src/**/*.xml" />
- <!-- Include the Symfony2 class loader component -->
- <include name="vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php" />
- <!-- Install Guzzle and its dependencies -->
- <include name="vendor/guzzle/guzzle/src/**/*.php" />
- <include name="vendor/guzzle/guzzle/src/**/*.pem" />
- <include name="vendor/guzzle/guzzle/src/**/.md5" />
- <include name="vendor/symfony/event-dispatcher/**/*.php" />
- <include name="vendor/doctrine/common/lib/Doctrine/Common/Cache/*.php" />
- <include name="vendor/psr/log/**/*.php" />
- <include name="vendor/monolog/monolog/src/**/*.php" />
+ <target name="create-staging" description="Creates a staging directory for zip and phar creation">
+
+ <delete dir="${dir.output}/staging" failonerror="false" quiet="true"/>
+ <mkdir dir="${dir.output}/staging"/>
+ <mkdir dir="${dir.output}/staging/Aws"/>
+ <mkdir dir="${dir.output}/staging/Guzzle"/>
+ <mkdir dir="${dir.output}/staging/Doctrine/Common/Cache"/>
+ <mkdir dir="${dir.output}/staging/Symfony"/>
+ <mkdir dir="${dir.output}/staging/Monolog"/>
+
+ <patternset id="sdk-files">
+ <include name="**/*.php" />
+ <include name="**/*.pem" />
+ <include name="**/*.md5" />
+ <include name="**/LICENSE*" />
+ </patternset>
+
+ <!-- Copy AWS deps -->
+ <copy file="${project.basedir}/build/aws-autoloader.php" tofile="${dir.output}/staging/aws-autoloader.php"/>
+ <copy todir="${dir.output}/staging">
+ <fileset dir="src">
+ <patternset refid="sdk-files"/>
+ </fileset>
+ </copy>
+ <copy file="${project.basedir}/LICENSE.md" tofile="${dir.output}/staging/Aws/LICENSE.md"/>
+ <copy file="${project.basedir}/NOTICE.md" tofile="${dir.output}/staging/Aws/NOTICE.md"/>
+
+ <!-- Copy Symfony dependencies -->
+ <copy todir="${dir.output}/staging">
+ <fileset dir="vendor/symfony/event-dispatcher">
+ <include name="**/*.php" />
+ </fileset>
+ </copy>
+ <copy todir="${dir.output}/staging">
+ <fileset dir="vendor/symfony/class-loader">
+ <include name="**/*.php" />
+ </fileset>
+ </copy>
+
+ <!-- Copy Guzzle deps -->
+ <copy todir="${dir.output}/staging">
+ <fileset dir="vendor/guzzle/guzzle/src">
+ <patternset refid="sdk-files"/>
+ </fileset>
+ </copy>
+
+ <!-- Copy Monolog deps -->
+ <copy todir="${dir.output}/staging">
+ <fileset dir="vendor/monolog/monolog/src">
+ <patternset refid="sdk-files"/>
+ </fileset>
+ </copy>
+
+ <!-- Copy PSR deps -->
+ <copy todir="${dir.output}/staging">
+ <fileset dir="vendor/psr/log">
+ <include name="**/*.php" />
+ </fileset>
+ </copy>
+
+ <!-- Copy Doctrine deps -->
+ <copy todir="${dir.output}/staging">
+ <fileset dir="vendor/doctrine/cache/lib">
+ <patternset refid="sdk-files"/>
+ </fileset>
+ </copy>
+
+ </target>
+
+ <target name="phar" depends="create-staging" description="Create a phar with an autoloader">
+ <pharpackage destfile="build/aws.phar" stub="build/phar-stub.php" basedir="${dir.output}/staging">
+ <fileset dir="${dir.output}/staging">
+ <include name="**/**"/>
</fileset>
<metadata>
<element name="link" value="${sdk_url}" />
</metadata>
</pharpackage>
- <exec command="php -d aws_phar=aws.phar `which phpunit`" passthru="true" />
+ </target>
+
+ <target name="zip" depends="create-staging" description="Create a ZIP file containing the SDK and its dependencies">
+ <zip destfile="build/aws.zip" basedir="${dir.output}/staging">
+ <fileset dir="${dir.output}/staging">
+ <include name="**/**"/>
+ </fileset>
+ </zip>
</target>
<target name="test-init" description="Initialize test dependencies">
View
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file 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.
+ */
+
+require_once __DIR__ . '/Symfony/Component/ClassLoader/UniversalClassLoader.php';
+
+if (!defined('AWS_FILE_PREFIX')) {
+ define('AWS_FILE_PREFIX', __DIR__);
+}
+
+$classLoader = new Symfony\Component\ClassLoader\UniversalClassLoader();
+$classLoader->registerNamespaces(array(
+ 'Aws' => AWS_FILE_PREFIX,
+ 'Guzzle' => AWS_FILE_PREFIX,
+ 'Symfony' => AWS_FILE_PREFIX,
+ 'Doctrine' => AWS_FILE_PREFIX,
+ 'Psr' => AWS_FILE_PREFIX,
+ 'Monolog' => AWS_FILE_PREFIX
+));
+
+$classLoader->register();
+
+return $classLoader;
View
@@ -17,20 +17,8 @@
Phar::mapPhar('aws.phar');
define('AWS_PHAR', true);
+define('AWS_FILE_PREFIX', 'phar://aws.phar');
-require_once 'phar://aws.phar/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php';
-
-$classLoader = new Symfony\Component\ClassLoader\UniversalClassLoader();
-$classLoader->registerNamespaces(array(
- 'Aws' => 'phar://aws.phar/src',
- 'Guzzle' => 'phar://aws.phar/vendor/guzzle/guzzle/src',
- 'Symfony\\Component\\EventDispatcher' => 'phar://aws.phar/vendor/symfony/event-dispatcher',
- 'Doctrine\\Common' => 'phar://aws.phar/vendor/doctrine/common/lib',
- 'Psr\\Log' => 'phar://aws.phar/vendor/psr/log',
- 'Monolog' => 'phar://aws.phar/vendor/monolog/monolog/src'
-));
-$classLoader->register();
-
-return $classLoader;
+return (require 'phar://aws.phar/aws-autoloader.php');
__HALT_COMPILER();
View
@@ -23,7 +23,7 @@
"symfony/yaml": "Eases the ability to write manifests for creating jobs in AWS Import/Export"
},
"require-dev": {
- "doctrine/common": "2.3.*",
+ "doctrine/cache": "~1.0",
"ext-apc": "*",
"ext-openssl": "*",
"monolog/monolog": "1.4.*",

0 comments on commit 1f6c8e5

Please sign in to comment.