From 49d0f4fac81e65c258f64e15b5c28e7319dd31ce Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Thu, 15 Dec 2016 15:40:58 -0500
Subject: [PATCH] Install Phing w/ Composer rather than vice versa. (#865)

- Also use Phing for Swagger-UI installation for better cross-platform support.
---
 .travis.yml   |  6 ++----
 README.md     |  5 +----
 build.xml     | 23 +++++++++++++++++++++--
 composer.json |  4 +++-
 4 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index cbbbd1f96d8..878d1fab0ad 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,12 +10,10 @@ env:
   - VUFIND_HOME=$PWD VUFIND_LOCAL_DIR=$PWD/local
 
 before_script:
-  - pear install pear/Http_Request2
-  - pear channel-discover pear.phing.info
-  - pear install phing/phing
   - phpenv config-rm xdebug.ini
   - phpenv rehash
+  - composer install
   - npm install -g eslint@"<3.0.0"
 
 script:
-  - phing composer phpunitfast phpcs-console php-cs-fixer-dryrun eslint
+  - vendor/bin/phing phpunitfast phpcs-console php-cs-fixer-dryrun eslint
diff --git a/README.md b/README.md
index a890008bc6e..2f25f7734eb 100644
--- a/README.md
+++ b/README.md
@@ -12,10 +12,7 @@ Installation
 ------------
 See our [online installation documentation](https://vufind.org/wiki/installation) for step-by-step instructions for installing from packaged releases to popular platforms.
 
-VuFind's [packaged releases](http://vufind-org.github.io/vufind/downloads.html) have all dependencies included. If you are installing directly from a Git checkout, you will need to load these dependencies manually by following these steps from inside VuFind's home directory:
-
-- Load PHP dependencies using the [Composer](https://getcomposer.org) tool by running `composer install`.
-- Install Solr using the [Phing](https://www.phing.info/) tool by running `phing installsolr`.
+VuFind's [packaged releases](http://vufind-org.github.io/vufind/downloads.html) have all dependencies included. If you are installing directly from a Git checkout, you will need to load these dependencies manually using the [Composer](https://getcomposer.org) tool by running `composer install` from the VuFind home directory.
 
 
 Documentation and Support
diff --git a/build.xml b/build.xml
index 8848e550cf5..1639855d34a 100644
--- a/build.xml
+++ b/build.xml
@@ -177,6 +177,24 @@
     </if>
   </target>
 
+  <target name="installswaggerui">
+    <delete dir="${srcdir}/public/swagger-ui" includeemptydirs="true" failonerror="false" />
+    <copy todir="${srcdir}/public/swagger-ui">
+      <fileset dir="${srcdir}/vendor/swagger-api/swagger-ui/dist" defaultexcludes="false" />
+    </copy>
+    <reflexive>
+      <fileset dir="${srcdir}/public/swagger-ui">
+        <include pattern="index.html" />
+      </fileset>
+      <filterchain>
+        <replaceregexp>
+          <regexp pattern="defaultModelRendering: 'schema'" replace="defaultModelRendering: 'model'" />
+          <regexp pattern="url = &quot;.*&quot;" replace="url = &quot;../api/v1?swagger&quot;" />
+        </replaceregexp>
+      </filterchain>
+    </reflexive>
+  </target>
+
   <target name="composer" description="Install dependencies with Composer">
     <httpget url="https://getcomposer.org/composer.phar" sslVerifyPeer="false" dir="${srcdir}" />
     <echo message="Installing dependencies..." />
@@ -187,7 +205,6 @@
   <target name="startup" description="install and activate demo">
     <!-- get dependencies -->
     <phingcall target="composer" />
-    <phingcall target="installsolr" />
 
     <!-- set up appropriate read/write permissions for Apache -->
     <exec command="chmod -R a+w ${srcdir}/local/cache" />
@@ -344,7 +361,6 @@
     <phingcall target="composer">
       <property name="composer_extra_params" value="--no-dev" />
     </phingcall>
-    <phingcall target="installsolr" />
     <exec command="git archive HEAD --format=tar | tar -x -C ${builddir}/export/vufind/usr/local/vufind" />
     <copy todir="${builddir}/export/vufind/usr/local/vufind/vendor">
       <fileset dir="${srcdir}/vendor" defaultexcludes="false" />
@@ -352,6 +368,9 @@
     <copy todir="${builddir}/export/vufind/usr/local/vufind/solr/vendor">
       <fileset dir="${srcdir}/solr/vendor" defaultexcludes="false" />
     </copy>
+    <copy todir="${builddir}/export/vufind/usr/local/vufind/public/swagger-ui">
+      <fileset dir="${srcdir}/public/swagger-ui" defaultexcludes="false" />
+    </copy>
 
     <!-- create a version-specific symlink so that tar/zip packages will have
          appropriate directory structures. -->
diff --git a/composer.json b/composer.json
index 3a153c71f9e..ce25f6fbf3d 100644
--- a/composer.json
+++ b/composer.json
@@ -18,7 +18,9 @@
         "ocramius/proxy-manager": "1.0.2",
         "oyejorge/less.php": "1.7.0.9",
         "pear/file_marc": "1.1.2",
+        "pear/http_request2": "2.3.0",
         "pear/validate_ispn": "dev-master",
+        "phing/phing": "2.15.2",
         "serialssolutions/summon": "1.0.0",
         "symfony/yaml": "2.7.6",
         "swagger-api/swagger-ui": "2.2.4",
@@ -43,6 +45,6 @@
         "squizlabs/php_codesniffer": "2.6.0"
     },
     "scripts": {
-        "post-update-cmd": "rm -rf public/swagger-ui; cp -r vendor/swagger-api/swagger-ui/dist public/swagger-ui; sed -i.orig \"s/defaultModelRendering: 'schema'/defaultModelRendering: 'model'/\" public/swagger-ui/index.html; sed -i.orig 's/url = \".*\"/url = \"..\\/api\\/v1\\?swagger\"/' public/swagger-ui/index.html"
+        "post-update-cmd": "phing installsolr installswaggerui"
     } 
 }
-- 
GitLab