Skip to content
Snippets Groups Projects
build.xml 24.2 KiB
Newer Older
Demian Katz's avatar
Demian Katz committed
<?xml version="1.0" encoding="UTF-8"?>
<project name="vufind" basedir="." default="main">
Demian Katz's avatar
Demian Katz committed
  <property name="tmp" value="/tmp" />
  <property name="package"  value="${phing.project.name}" override="true" />
  <property name="builddir" value="${tmp}/build/${phing.project.name}" override="true" />
  <property name="srcdir"   value="${project.basedir}" override="true" />
  <property name="apacheconfdir" value="/etc/apache2/conf.d" />
  <property name="apachectl" value="false" /><!-- set to apachectl path to spin up Apache instance -->
  <property name="seleniumjar" value="false" /><!-- set to Selenium jar path to spin up Selenium instance -->
  <!-- command for extra cleanup during shutdown; e.g. to change cache ownership after testing w/ Apache so deletion won't fail: -->
  <property name="extra_shutdown_cleanup" value="false" />
Demian Katz's avatar
Demian Katz committed
  <property name="vufindurl" value="http://localhost/vufind" />
  <property name="vufinddb" value="vufind_test" />
  <property name="vufinddbuser" value="vufindtest" />
  <property name="vufinddbpass" value="vufindtestpass" />
  <property name="dbtype" value="mysql" /><!-- use pgsql for PostgreSQL -->
  <property name="mysqlhost" value="localhost" />
  <property name="mysqlrootuser" value="root" />
  <property name="mysqlrootpass" value="password" />
  <property name="pgsqlhost" value="localhost" />
  <property name="pgsqlrootuser" value="postgres" />
  <property name="phpunit_extra_params" value="" />
  <property name="composer_extra_params" value="" />
  <property name="mink_driver" value="selenium" />
  <property name="selenium_browser" value="firefox" />
  <property name="snooze_multiplier" value="1" /><!-- can be used to slow down tests (selenium only) -->
Demian Katz's avatar
Demian Katz committed
  <property name="solr_startup_sleep" value="0" />
  <property name="solr_version" value="7.3.1" />
  <property name="phpdoc_version" value="2.9.0" />
Demian Katz's avatar
Demian Katz committed
  <property name="version" value="5.1" />
  <!-- We only need the -p switch if the password is non-blank -->
  <if><not><equals arg1="${mysqlrootpass}" arg2="" /></not><then>
    <property name="mysqlpwswitch" value="-p" />
  </then></if>

Demian Katz's avatar
Demian Katz committed
  <!-- Main Target -->
  <target name="main" description="main target">
    <phingcall target="startup" />
    <trycatch property="exceptionmsg">
      <try>
Demian Katz's avatar
Demian Katz committed
        <phingcall target="ci-tasks" />
Demian Katz's avatar
Demian Katz committed
        <phingcall target="shutdown" />
        <fail>Unexpected error during continuous integration tasks -- ${exceptionmsg}</fail>
      </catch>
    </trycatch>
    <phingcall target="shutdown" />
  </target>

  <!-- Continuous Integration Tasks -->
  <target name="ci-tasks" description="continuous integration tasks">
Demian Katz's avatar
Demian Katz committed

    <!-- Create dirs -->
    <mkdir dir="${builddir}/reports"/>
    <mkdir dir="${builddir}/reports/coverage"/>

    <!-- Call standard tasks -->
    <phingcall target="phpcs"/>
    <phingcall target="php-cs-fixer-dryrun"/>
    <phingcall target="phpunit"/>
Demian Katz's avatar
Demian Katz committed
    <phingcall target="phpcpd"/>
Demian Katz's avatar
Demian Katz committed
    <phingcall target="phpmd"/>
    <phingcall target="pdepend"/>
Demian Katz's avatar
Demian Katz committed
    <phingcall target="phploc"/>
    <phingcall target="eslint-report"/>
    <phingcall target="jshint-report"/>
Demian Katz's avatar
Demian Katz committed
  </target>

Demian Katz's avatar
Demian Katz committed
  <!-- Report rule violations with PHPMD (mess detector) -->
  <target name="phpmd">
    <exec command="${srcdir}/vendor/bin/phpmd ${srcdir}/module xml ${srcdir}/tests/phpmd.xml --exclude ${srcdir}/module/VuFind/tests,${srcdir}/module/VuDL/tests,${srcdir}/module/VuFindSearch/tests --reportfile ${builddir}/reports/phpmd.xml" />
Demian Katz's avatar
Demian Katz committed
  </target>

Demian Katz's avatar
Demian Katz committed
  <!-- Measure project with phploc -->
  <target name="phploc">
    <exec command="${srcdir}/vendor/bin/phploc --log-csv ${builddir}/reports/phploc.csv ${srcdir}/module" />
  </target>

  <!-- PHP_Depend code analysis -->
  <target name="pdepend">
    <exec command="${srcdir}/vendor/bin/pdepend --jdepend-xml=${builddir}/reports/jdepend.xml --jdepend-chart=${builddir}/reports/dependencies.svg --overview-pyramid=${builddir}/reports/pdepend-pyramid.svg ${srcdir}/module" />
Demian Katz's avatar
Demian Katz committed
  </target>

  <!-- PHP copy-and-paste detection -->
  <target name="phpcpd">
    <exec command="${srcdir}/vendor/bin/phpcpd --log-pmd ${builddir}/reports/pmd-cpd.xml --exclude tests ${srcdir}/module" />
  <target name="phpcbf">
    <exec command="${srcdir}/vendor/bin/phpcbf --standard=${srcdir}/tests/phpcs.xml" escape="false" passthru="true" checkreturn="true" />
  </target>
    <exec command="${srcdir}/vendor/bin/phpcs --standard=${srcdir}/tests/phpcs.xml --report=checkstyle &gt; ${builddir}/reports/checkstyle.xml" escape="false" />
  </target>
  <target name="phpcs-console">
    <exec command="${srcdir}/vendor/bin/phpcs --standard=${srcdir}/tests/phpcs.xml" escape="false" passthru="true" checkreturn="true" />
  <!-- php-cs-fixer (first task applies fixes, second task simply checks if they are needed) -->
Demian Katz's avatar
Demian Katz committed
  <target name="php-cs-fixer">
    <exec command="${srcdir}/vendor/bin/php-cs-fixer fix --config=${srcdir}/tests/vufind.php_cs -vvv" passthru="true" escape="false" />
    <exec command="${srcdir}/vendor/bin/php-cs-fixer fix --config=${srcdir}/tests/vufind_templates.php_cs -vvv" passthru="true" escape="false" />
  </target>
  <target name="php-cs-fixer-dryrun">
    <exec command="${srcdir}/vendor/bin/php-cs-fixer fix --config=${srcdir}/tests/vufind.php_cs --dry-run -vvv --diff" passthru="true" escape="false" checkreturn="true" />
    <exec command="${srcdir}/vendor/bin/php-cs-fixer fix --config=${srcdir}/tests/vufind_templates.php_cs --dry-run -vvv --diff" passthru="true" escape="false" checkreturn="true" />
Demian Katz's avatar
Demian Katz committed
  </target>

  <!-- ESLint -->
  <target name="eslint">
    <exec command="eslint -c ${srcdir}/.eslintrc.js ${srcdir}/themes/bootstrap3/js/*.js" escape="false" checkreturn="true" passthru="true" />
  </target>
  <target name="eslint-fix">
    <exec command="eslint -c ${srcdir}/.eslintrc.js ${srcdir}/themes/bootstrap3/js/*.js --fix" escape="false" passthru="true" />
  </target>
  <target name="eslint-report">
    <exec command="eslint -c ${srcdir}/.eslintrc.js ${srcdir}/themes/bootstrap3/js/*.js --format checkstyle -o ${builddir}/reports/eslint-checkstyle.xml" escape="false" />
  </target>

  <!-- JSHint -->
  <target name="jshint">
    <exec command="jshint --config=${srcdir}/tests/jshint.json --exclude=themes/*/js/vendor ${srcdir}/themes" checkreturn="true" passthru="true" />
  </target>
  <target name="jshint-report">
    <exec command="jshint --config=${srcdir}/tests/jshint.json --exclude=themes/*/js/vendor --reporter=checkstyle ${srcdir}/themes &gt; ${builddir}/reports/jshint-checkstyle.xml" />
  <!-- PHP API Documentation -->
  <target name="phpdoc">
    <!-- GET phpDocumentor.phar -->
    <if>
      <not><available file="${srcdir}/vendor/bin/phpDocumentor-${phpdoc_version}.phar" /></not>
      <then>
        <httpget followRedirects="true" url="https://github.com/phpDocumentor/phpDocumentor2/releases/download/v${phpdoc_version}/phpDocumentor.phar" dir="${srcdir}/vendor/bin" filename="phpDocumentor-${phpdoc_version}.phar" />
        <chmod mode="0755">
          <fileset dir="${srcdir}/vendor/bin">
            <include name="phpDocumentor-${phpdoc_version}.phar" />
          </fileset>
        </chmod>
      </then>
    </if>
    <!-- Run phpdoc -->
    <mkdir dir="${builddir}/apidocs" />
    <!-- Old embedded version; no longer works correctly...
Demian Katz's avatar
Demian Katz committed
    <phpdoc2 title="VuFind API Documentation"
      pharlocation="${srcdir}/vendor/bin/phpDocumentor-${phpdoc_version}.phar"
Demian Katz's avatar
Demian Katz committed
      destdir="${builddir}/apidocs">
Demian Katz's avatar
Demian Katz committed
      <fileset dir=".">
        <include name="module/*/src/**/*.php" />
Demian Katz's avatar
Demian Katz committed
      </fileset>
Demian Katz's avatar
Demian Katz committed
    </phpdoc2>
    -->
    <exec command="php ${srcdir}/vendor/bin/phpDocumentor-${phpdoc_version}.phar --title=&quot;VuFind API Documentation&quot; -t ${builddir}/apidocs -d ${srcdir}/module" passthru="true" />
Demian Katz's avatar
Demian Katz committed
  </target>

  <!-- PHPUnit -->
  <target name="phpunit" description="Run tests">
    <exec dir="${srcdir}/module/VuFind/tests" command="VUFIND_MINK_DRIVER=${mink_driver} VUFIND_SELENIUM_BROWSER=${selenium_browser} VUFIND_SNOOZE_MULTIPLIER=${snooze_multiplier} VUFIND_LOCAL_DIR=${srcdir}/local VUFIND_URL=${vufindurl} ${srcdir}/vendor/bin/phpunit -dzend.enable_gc=0 --log-junit ${builddir}/reports/phpunit.xml --coverage-clover ${builddir}/reports/coverage/clover.xml --coverage-html ${builddir}/reports/coverage/ ${phpunit_extra_params}" passthru="true" checkreturn="true" />
  </target>

  <target name="phpunitfast" description="Run tests">
    <exec dir="${srcdir}/module/VuFind/tests" command="VUFIND_MINK_DRIVER=${mink_driver} VUFIND_SELENIUM_BROWSER=${selenium_browser} VUFIND_SNOOZE_MULTIPLIER=${snooze_multiplier} VUFIND_LOCAL_DIR=${srcdir}/local VUFIND_URL=${vufindurl} ${srcdir}/vendor/bin/phpunit -dzend.enable_gc=0 ${phpunit_extra_params}" passthru="true" checkreturn="true" />
  <target name="installsolr" description="Install Solr">
    <!-- load previously installed version from marker file, if present -->
    <if>
      <available file="${srcdir}/solr/vendor/.installedVersion" />
      <then>
        <loadfile property="existing_solr_version" file="${srcdir}/solr/vendor/.installedVersion" />
      </then>
    </if>
    <!-- only attempt to install Solr if the desired version is not already there -->
    <if>
      <not><equals arg1="${existing_solr_version}" arg2="${solr_version}" /></not>
      <then>
        <!-- make sure we don't run out of memory during installation: -->
        <php expression="ini_set('memory_limit', '1G');" />

        <!-- download from Apache if not already present in the downloads cache -->
        <if>
          <not><available file="${srcdir}/downloads/solr-${solr_version}.tgz" /></not>
           <then>
            <mkdir dir="${srcdir}/downloads" />
Demian Katz's avatar
Demian Katz committed
            <httpget url="http://archive.apache.org/dist/lucene/solr/${solr_version}/solr-${solr_version}.tgz" dir="${srcdir}/downloads" />
          </then>
        </if>
        <!-- unpack the archive into solr/vendor -->
        <mkdir dir="${builddir}/solr" />
        <untar file="${srcdir}/downloads/solr-${solr_version}.tgz" todir="${builddir}/solr" />
        <delete dir="${srcdir}/solr/vendor" includeemptydirs="true" failonerror="false" />
        <move file="${builddir}/solr/solr-${solr_version}" tofile="${srcdir}/solr/vendor" />
        <!-- make scripts executable -->
        <chmod mode="0755">
          <fileset dir="${srcdir}/solr/vendor/bin">
            <include name="**/**" />
            <exclude name="**/*.cmd" />
          </fileset>
        </chmod>
        <!-- update the marker file with the installed version -->
        <echo file="${srcdir}/solr/vendor/.installedVersion" message="${solr_version}" />
      </then>
    </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..." />
    <exec command="php ${srcdir}/composer.phar install ${composer_extra_params}" passthru="true" checkreturn="true" />
Demian Katz's avatar
Demian Katz committed
  <!-- Install and Activate VuFind -->
  <target name="startup" description="install and activate demo">
    <!-- get dependencies -->
    <phingcall target="composer" />

Demian Katz's avatar
Demian Katz committed
    <!-- set up appropriate read/write permissions for Apache -->
    <exec command="chmod -R a+w ${srcdir}/local/cache" />

    <php expression="end(explode('/', '${vufindurl}'))" returnProperty="basepath" />
    <exec command="php ${srcdir}/install.php --basepath=/${basepath} --non-interactive" />
    <!-- Activate Selenium (if a path has been provided) -->
    <if>
      <istrue value="${seleniumjar}" />
      <then>
        <exec command="xvfb-run --server-args=&quot;-screen 0 1024x768x24&quot; java -jar ${seleniumjar}" passthru="true" spawn="true" checkreturn="true" />
    <!-- Activate Apache (if an apachectl path has been provided) -->
    <if>
      <istrue value="${apachectl}" />
      <then>
        <copy file="${srcdir}/local/httpd-vufind.conf" tofile="${apacheconfdir}/vufindtest.conf" />
Demian Katz's avatar
Demian Katz committed
        <exec command="${apachectl} restart" outputProperty="LASTOUTPUT" />
        <echo message="${LASTOUTPUT}" />
Demian Katz's avatar
Demian Katz committed

    <!-- build and configure the requested database type -->
    <if>
      <equals arg1="${dbtype}" arg2="pgsql" />
      <then>
Demian Katz's avatar
Demian Katz committed
        <!-- build database -->
        <exec command="sudo su -c &quot;psql -c \&quot;DROP DATABASE ${vufinddb};\&quot;&quot; ${pgsqlrootuser}" />
        <exec command="sudo su -c &quot;psql -c \&quot;DROP USER ${vufinddbuser};\&quot;&quot; ${pgsqlrootuser}" />
        <exec command="sudo su -c &quot;psql -c \&quot;CREATE DATABASE ${vufinddb};\&quot;&quot; ${pgsqlrootuser}" checkreturn="true" />
        <exec command="sudo su -c &quot;psql -c \&quot;CREATE USER ${vufinddbuser} PASSWORD '${vufinddbpass}';\&quot;&quot; ${pgsqlrootuser}" checkreturn="true" />
        <exec command="sudo su -c &quot;psql -c \&quot;GRANT ALL ON DATABASE ${vufinddb} TO ${vufinddbuser};\&quot;&quot; ${pgsqlrootuser}" checkreturn="true" />
        <!--<exec command="sudo su -c &quot;psql -c \&quot;select 'grant SELECT,INSERT,UPDATE,DELETE on '||schemaname||'.'||tablename||' to ${vufinddbuser};' from pg_tables where schemaname in ('${vufinddb}') order by schemaname, tablename;\&quot;&quot; ${pgsqlrootuser}" checkreturn="true" />-->
        <exec command="PGPASSWORD=${vufinddbpass} psql -U ${vufinddbuser} -f ${srcdir}/module/VuFind/sql/pgsql.sql ${vufinddb}" checkreturn="true" />
Demian Katz's avatar
Demian Katz committed

        <!-- configure VuFind -->
        <property name="db_connection_string" value="pgsql://${vufinddbuser}:${vufinddbpass}@${pgsqlhost}/${vufinddb}" />
Demian Katz's avatar
Demian Katz committed
      </then>
      <else>
Demian Katz's avatar
Demian Katz committed
        <!-- build database -->
        <exec command="mysqladmin -f -h ${mysqlhost} -u ${mysqlrootuser} ${mysqlpwswitch}${mysqlrootpass} drop ${vufinddb}" />
        <exec command="mysqladmin -h ${mysqlhost} -u ${mysqlrootuser} ${mysqlpwswitch}${mysqlrootpass} create ${vufinddb}" checkreturn="true" />
        <exec command="mysql -h ${mysqlhost} -u ${mysqlrootuser} ${mysqlpwswitch}${mysqlrootpass} -e &quot;GRANT SELECT,INSERT,UPDATE,DELETE ON ${vufinddb}.* TO '${vufinddbuser}'@'${mysqlhost}' IDENTIFIED BY '${vufinddbpass}' WITH GRANT OPTION&quot;" checkreturn="true" />
        <exec command="mysql -h ${mysqlhost} -u ${mysqlrootuser} ${mysqlpwswitch}${mysqlrootpass} -e &quot;FLUSH PRIVILEGES&quot;" checkreturn="true" />
        <exec command="mysql -h ${mysqlhost} -u ${mysqlrootuser} ${mysqlpwswitch}${mysqlrootpass} -D ${vufinddb} &lt; ${srcdir}/module/VuFind/sql/mysql.sql" checkreturn="true" />
Demian Katz's avatar
Demian Katz committed

        <!-- configure VuFind -->
        <property name="db_connection_string" value="mysql://${vufinddbuser}:${vufinddbpass}@${mysqlhost}/${vufinddb}" />
Demian Katz's avatar
Demian Katz committed
      </else>
    </if>

    <!-- Update config.ini to activate DB connection and exception logging -->
    <copy file="${srcdir}/config/vufind/config.ini" tofile="${srcdir}/local/config/vufind/config.ini">
      <filterchain>
        <replaceregexp>
          <regexp pattern="mysql://root@localhost/vufind" replace="${db_connection_string}" />
          <regexp pattern=";file\s+= /var/log/vufind.log:alert,error,notice,debug" replace="file = ${srcdir}/vufind-exception.log:alert-5,error-5" />
        </replaceregexp>
      </filterchain>
    </copy>
    <exec command="touch ${srcdir}/vufind-exception.log" />
    <exec command="chmod a+w ${srcdir}/vufind-exception.log" />

    <!-- start Solr (use restart in case of old PID files) -->
Demian Katz's avatar
Demian Katz committed
    <exec command="touch ${srcdir}/local/vufindtest.pid" />
    <exec command="VUFIND_HOME=${srcdir} ${srcdir}/solr.sh restart" outputProperty="LASTOUTPUT" />
Demian Katz's avatar
Demian Katz committed
    <if>
      <equals arg1="0" arg2="${solr_startup_sleep}" />
      <then>
        <!-- do nothing -->
      </then>
      <else>
        <echo message="Waiting ${solr_startup_sleep} seconds for Solr to be ready..." />
        <exec command="sleep ${solr_startup_sleep}" />
      </else>
    </if>

Demian Katz's avatar
Demian Katz committed
    <!-- import marc test records into vufind index (note: the marc test records have prefix "testsample#") -->
    <exec escape="false" command="find ${srcdir}/tests/data -name '*.mrc' -printf '%p,'" outputProperty="buglist" />
Demian Katz's avatar
Demian Katz committed
    <foreach list="${buglist}" param="filename" delimiter="," target="importrec" />
    <exec escape="false" command="find ${srcdir}/tests/data/authority -name '*.mrc' -printf '%p,'" outputProperty="authlist" />
    <foreach list="${authlist}" param="filename" delimiter="," target="importauthrec" />

    <!-- build alphabrowse index -->
    <exec command="VUFIND_HOME=${srcdir} VUFIND_LOCAL_DIR=${srcdir}/local ${srcdir}/index-alphabetic-browse.sh" outputProperty="LASTOUTPUT" />
    <echo message="${LASTOUTPUT}" />
Demian Katz's avatar
Demian Katz committed
  </target>

  <!-- Uninstall and Deactivate VuFind -->
  <target name="shutdown" description="deactivate and uninstall demo">

    <!-- Remove Apache settings (if Apache was enabled) -->
    <if>
      <istrue value="${apachectl}" />
      <then>
        <delete file="${apacheconfdir}/vufindtest.conf" />
        <exec command="${apachectl} restart" />
      </then>
    </if>
Demian Katz's avatar
Demian Katz committed

    <!-- drop database -->
    <if>
      <equals arg1="${dbtype}" arg2="pgsql" />
      <then>
Demian Katz's avatar
Demian Katz committed
        <exec command="sudo su -c &quot;psql -c \&quot;DROP DATABASE ${vufinddb};\&quot;&quot; ${pgsqlrootuser}" checkreturn="true" />
        <exec command="sudo su -c &quot;psql -c \&quot;DROP USER ${vufinddbuser};\&quot;&quot; ${pgsqlrootuser}" checkreturn="true" />
Demian Katz's avatar
Demian Katz committed
      </then>
      <else>
        <exec command="mysqladmin -f -h ${mysqlhost} -u ${mysqlrootuser} ${mysqlpwswitch}${mysqlrootpass} drop ${vufinddb}" />
Demian Katz's avatar
Demian Katz committed
      </else>
    </if>

    <!-- stop Solr -->
Demian Katz's avatar
Demian Katz committed
    <exec command="VUFIND_HOME=${srcdir} ${srcdir}/solr.sh stop" outputProperty="LASTOUTPUT" />
Demian Katz's avatar
Demian Katz committed
    <echo message="${LASTOUTPUT}" />

    <!-- run extra cleanup action, if any -->
    <if>
      <istrue value="${extra_shutdown_cleanup}" />
      <then>
        <exec command="VUFIND_HOME=${srcdir} VUFIND_LOCAL_DIR=${srcdir}/local ${extra_shutdown_cleanup}" />
      </then>
    </if>

    <!-- shut down selenium if necessary -->
    <if>
      <istrue value="${seleniumjar}" />
      <then>
        <exec command="pkill -f xvfb" />
        <exec command="pkill -f &quot;java -jar `basename ${seleniumjar}`&quot;" />
Demian Katz's avatar
Demian Katz committed
    <!-- delete the configuration, sample index, logs and cache data -->
    <delete file="${srcdir}/import/solrmarc.log" failonerror="true" />
Demian Katz's avatar
Demian Katz committed
    <delete dir="${srcdir}/solr" includeemptydirs="true" failonerror="true" />
    <delete file="${srcdir}/composer.phar" failonerror="false" />
    <delete file="${srcdir}/vufind-exception.log" failonerror="false" />
    <delete dir="${srcdir}/vendor" includeemptydirs="true" failonerror="false" />
    <delete dir="${srcdir}/local" includeemptydirs="true" failonerror="true" />
    <exec command="git reset --hard" />
Demian Katz's avatar
Demian Katz committed
  </target>

  <!-- Prepare VuFind for distribution -->
  <target name="package" description="build VuFind packages for distribution">
    <!-- make sure the work area is empty, then rebuild it -->
    <delete dir="${builddir}/packages" includeemptydirs="true" failonerror="false" />
Demian Katz's avatar
Demian Katz committed
    <mkdir dir="${builddir}/packages" />
    <delete dir="${builddir}/export" includeemptydirs="true" failonerror="false" />
    <mkdir dir="${builddir}/export/vufind/usr/local/vufind" />

    <!-- load the relevant files into the work area -->
    <phingcall target="composer">
      <property name="composer_extra_params" value="--no-dev" />
    </phingcall>
    <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" />
    </copy>
    <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. -->
    <exec command="ln -s ${builddir}/export/vufind/usr/local/vufind ${builddir}/export/vufind-${version}" />
Demian Katz's avatar
Demian Katz committed

    <!-- build the standard tar.gz archive -->
    <echo message="Building .tar.gz...." />
    <exec command="cd ${builddir}/export ; tar czfh ${builddir}/packages/vufind-${version}.tar.gz vufind-${version}" checkreturn="true" />
    <!-- build the a zip archive -->
    <echo message="Building .zip...." />
    <exec command="cd ${builddir}/export ; zip -r ${builddir}/packages/vufind-${version}.zip vufind-${version}" checkreturn="true" />
    <!-- build the DEB package -->
    <echo message="Building .deb...." />
    <move file="${builddir}/export/vufind/usr/local/vufind/packages/DEBIAN" todir="${builddir}/export/vufind" includeemptydirs="true"/>
    <exec command="chmod 0775 ${builddir}/export/vufind/DEBIAN/postinst" />
    <exec command="dpkg-deb -b ${builddir}/export/vufind ${builddir}/packages/vufind_${version}.deb" checkreturn="true" />

    <!-- clean up -->
    <delete dir="${builddir}/export" includeemptydirs="true" failonerror="true" />

Demian Katz's avatar
Demian Katz committed
    <!-- report success -->
    <echo message="Packages successfully generated in ${builddir}/packages" />
  </target>

  <target name="importauthrec" description="import each of the MARC authority test records">
    <if>
    <istrue value="${filename}"/>       <!-- To ignore the last token, as find command output list has ',' after last filename -->
      <then>
        <exec command="basename ${filename}" outputProperty="BASENAME" />

        <!-- perform the import -->
        <exec command="VUFIND_HOME=${srcdir} VUFIND_LOCAL_DIR=${srcdir}/local ${srcdir}/import-marc-auth.sh ${filename} marc_auth_ils.properties" outputProperty="LASTOUTPUT" />
        <echo message="${LASTOUTPUT}" />
      </then>
    </if>
  </target>

  <target name="importrec" description="import each of the MARC bibliographic test records">
Demian Katz's avatar
Demian Katz committed
    <if>
    <istrue value="${filename}"/>       <!-- To ignore the last token, as find command output list has ',' after last filename -->
      <then>
Demian Katz's avatar
Demian Katz committed
        <exec command="basename ${filename}" outputProperty="BASENAME" />
Demian Katz's avatar
Demian Katz committed
        <!-- create custom import configurations to load the MARC filename into the building facet to help
             test cases to limit searches to within specific collections of test records. -->
        <copy file="${srcdir}/import/marc_local.properties" tofile="${srcdir}/local/import/marc-${BASENAME}.properties" />
        <exec command="echo building=\&quot;${BASENAME}\&quot; &gt;&gt; ${srcdir}/local/import/marc-${BASENAME}.properties" />
Demian Katz's avatar
Demian Katz committed
        <exec command="sed -e &quot;s!marc_local.properties!marc-${BASENAME}.properties!&quot; ${srcdir}/local/import/import.properties &gt; ${srcdir}/local/import/import-${BASENAME}.properties" />
        <!-- if there is a file-specific import configuration, load it now: -->
        <if>
          <available file="${filename}.properties" />
          <then>
            <echo message="Found custom import configs for ${filename}." />
            <exec command="cat ${filename}.properties &gt;&gt; ${srcdir}/local/import/marc-${BASENAME}.properties" />
          </then>
        </if>

Demian Katz's avatar
Demian Katz committed
        <!-- perform the import -->
        <exec command="VUFIND_HOME=${srcdir} VUFIND_LOCAL_DIR=${srcdir}/local ${srcdir}/import-marc.sh -p ${srcdir}/local/import/import-${BASENAME}.properties ${filename}" outputProperty="LASTOUTPUT" />
        <echo message="${LASTOUTPUT}" />
Demian Katz's avatar
Demian Katz committed
        <!-- clean up temp files -->
        <delete file="${srcdir}/local/import/marc-${BASENAME}.properties" />
        <delete file="${srcdir}/local/import/import-${BASENAME}.properties" />
Demian Katz's avatar
Demian Katz committed
      </then>
    </if>
  </target>