Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
418 lines (357 sloc) 18.7 KB
<?xml version="1.0" encoding="UTF-8"?>
<!--
## @file
## ADS Phing build script
## @version
## $Id: 596381b6a5a4773293efe09d800ea9a5a83f8efb $
##
## Read more:
## http://www.phing.info/
##
## Quick PEAR installation:
## $> pear channel-discover pear.phing.info
## $> pear install phing/phing
-->
<project name="build-ads" basedir="." default="build-ads">
<import file="${phing.dir.build_ads}/phing/includes/build.debug.xml" />
<!--
## Build
-->
<target name="build-ads" depends="
ads-make
"/>
<target name="ads-make" depends="
build-init,
build-drupal,
set-dir-permissions
"/>
<target name="ads-install" depends="
build-init,
install-drupal,
post-install-drupal
"/>
<target name="ads-install-skip-post-install-drupal" depends="
build-init,
install-drupal
"/>
<!--
## Initialise
-->
<import file="${phing.dir.build_ads}/phing/includes/build.import.xml" />
<target name="build-init" depends="build-load-properties"/>
<!--
## Load Properties
-->
<target name="build-load-properties">
<log message="Assigning project directories and files to phing properties...${line.separator}" level="debug"/>
<property name="project.dir.dist" value="${phing.dir.build_ads}"/>
<property name="project.dir.profile" value="${project.dir.dist}"/>
<property name="project.dir.src" value="${project.dir.profile}/src"/>
<!-- <property name="project.dir.taxonomies" value="${project.dir.src}/sites/all/modules/ads/ads_features"/> -->
<log message="Building ADS into &quot;${project.dir.src}&quot;" level="verbose"/>
<!-- <property name="project.dir.src.ads_features" value="${project.dir.src}/sites/all/modules/ads/ads_features"/> -->
<property name="project.file.makefile" value="build-ads.make"/>
<log message="Assigning drush properties...${line.separator}" level="debug"/>
<property name="project.drush.args" value="--verbose --yes"/>
<property name="project.drush.cmd" value="${phing.dir.build_ads}/vendor/drush/drush/drush ${project.drush.args}"/>
<property name="project.drush.make.args" value="-y --prepare-install --working-copy --no-gitinfofile --verbose --concurrency=4"/>
<property name="project.drush.make.args2" value="-y --no-core --prepare-install --working-copy --no-gitinfofile --verbose --concurrency=4"/>
<log message="Loading configuration file..." level="debug"/>
<available file="${project.dir.dist}/build.properties" property="project.properties.exist" />
<if>
<not><isset property="project.properties.exist"/></not>
<then>
<copy
file="${project.dir.dist}/phing/build.properties.example"
tofile="${project.dir.dist}/build.properties"
overwrite="true"/>
<!-- or: <exec command="cp -v ${project.dir.dist}/build.properties.example ${project.dir.dist}/build.properties"
dir="${project.dir.dist}" checkreturn="true" /> -->
<log message="" level="warning" />
<log message="Hello :)" level="warning" />
<log message="Thank you for installing ADS distribution." level="warning" />
<log message="I have created a build.properties in ${project.dir.dist}.${line.separator}" level="warning" />
<log message="ACTION REQUIRED" level="warning" />
<log message="Please edit this file with your settings." level="warning" />
<log message="And then re-run the script again." level="warning" />
<log message="Thank You :)" level="warning" />
<fail message="See you again in a moment...${line.separator}" />
<log message="" level="warning" />
</then>
<else>
<property file="${project.dir.dist}/build.properties" />
<if>
<isset property="properties.notset"/>
<then>
<log message="" level="error" />
<log message="ACTION REQUIRED!" level="error" />
<log message="Please edit ${project.dir.dist}/build.properties" level="error" />
<log message="After you finish, please delete properties.notset section." level="error" />
<log message="" level="error" />
<fail />
</then>
</if>
</else>
</if>
<!-- Enable the pulling from other forks -->
<if>
<isset property="pullfrom" />
<then>
<!-- <log message"Overriding gihub.user with ${pullfrom}" />
<property name="github.user" value="${pullfrom}"/>-->
</then>
</if>
<property environment="env" />
<!-- Checking for variable overrides by environment variables -->
<if>
<isset property="env.ADS_SEARCH"/>
<then>
<log message="Found environment variable ADS_SEARCH, overriding project.drupal.configure.search = &quot;${env.ADS_SEARCH}&quot;" level="verbose" indent="1" />
<property name="project.drupal.configure.search" value="${env.ADS_SEARCH}" override="true"/>
</then>
</if>
<log message="" level="verbose"/>
</target>
<!--
## Build Drupal code using drush make
-->
<target name="build-drupal" depends="build-init">
<log message="Downloading and building Drupal sources... (it may take a while)" level="verbose" />
<!-- Detection of makefile variant -->
<if>
<equals arg1="${project.drupal.build.stable}" arg2="true"/>
<then>
<property name="project.drupal.build.option.stable" value="stable" override="true"/>
</then>
<else>
<property name="project.drupal.build.option.stable" value="latest" override="true"/>
</else>
</if>
<property name="project.drupal.build.option.type" value="${project.drupal.build.type}" override="true"/>
<property name="project.file.makefile" value="build-ads-${project.drupal.build.option.stable}-${project.drupal.build.option.type}.make" override="true"/>
<exec command="${project.drush.cmd} make ${project.dir.profile}/${project.file.makefile} ${project.dir.src} ${project.drush.make.args}" dir="${project.dir.dist}" outputProperty="project.drupal.exists" passthru="1" LogOutput="true" />
<!--
<if><not><equals arg1="${project.drupal.exists}" arg2="0" /></not>
<then>
<log message="Drupal instance exists, updating the existing sources...${line.separator}" />
<exec command="${project.drush.cmd} make ${project.dir.profile}/${project.file.makefile} ${project.dir.src} ${project.drush.make.args2}" dir="${project.dir.dist}" LogOutput="true" />
</then>
</if>
-->
<available file="${project.dir.src}" property="project.src.exist" />
<if>
<not><isset property="project.src.exist"/></not>
<then>
<log message="" level="error" />
<log message="Drupal build failed, directory &quot;${project.dir.src}&quot; does not exist" level="error" />
<log message="" level="error" />
<fail message="Drupal build failed, directory &quot;${project.dir.src}&quot; does not exist" />
</then>
</if>
<if>
<isset property="out"/>
<then>
<log message="Moving Drupal build folder &quot;${project.dir.src}&quot; to destination &quot;${out}&quot;" level="debug" />
<move todir="${out}">
<fileset dir="${project.dir.src}">
<include name="**/*" />
</fileset>
</move>
</then>
</if>
<!-- Done -->
<log message="" level="info" />
<log message="Done" level="info" />
<log message="" level="info" />
<log message="NOTE:" level="info" />
<log message="Distribution can be found in the directory: ${project.dir.src}" level="info" />
<log message="You can move your newly created distribution to your webroot." level="info" />
<log message="Or you can install it by the following command:" level="info" />
<log message=" phing ads-install" level="info" />
<log message="" level="info" />
</target>
<target name="check-db" depends="build-init">
<log message="Checking database connection..." level="verbose" />
<property name="project.db.url" value="${project.db.driver}://${project.db.username}:${project.db.password}@${project.db.host}:${project.db.port}/${project.db.database}" />
<exec command="${project.drush.cmd} sql-query --db-url=${project.db.url} &quot;SHOW TABLES;&quot;" returnProperty="cmd.return" passthru="1" LogOutput="true" />
<if><not><equals arg1="${cmd.return}" arg2="0" /></not>
<then>
<log msg="Cannot access selected database! Check your database connection at &quot;${project.db.url}&quot;!" indent="1" />
<fail msg="Cannot access selected database! Check your database connection at &quot;${project.db.url}&quot;!" />
</then>
<else>
<log msg="OK" indent="1" />
</else>
</if>
<log msg="" />
</target>
<!--
## Install Drupal code using drush make
-->
<target name="install-drupal" depends="build-init, check-db">
<log message="Installing Drupal from the profile" level="verbose" />
<log message="" level="verbose" />
<property name="project.db.url" value="${project.db.driver}://${project.db.username}:${project.db.password}@${project.db.host}:${project.db.port}/${project.db.database}" />
<exec command="${project.drush.cmd} site-install ads --db-url=${project.db.url} --account-name=${project.drupal.admin.user} --account-mail=&quot;${project.drupal.admin.email}&quot; --account-pass=&quot;${project.drupal.admin.pass}&quot; --site-mail=&quot;${project.drupal.site.email}&quot; --site-name=&quot;${project.drupal.site.name}&quot; install_configure_form.site_default_country=&quot;${project.drupal.site.default_country}&quot; install_configure_form.date_default_timezone=&quot;${project.drupal.site.default_time_zone}&quot; update_notifications.update_status_module=&quot;${project.drupal.site.check_for_updates}&quot; variables.file_private_path=&quot;${project.drupal.private.dir}&quot;"
dir="${project.dir.src}" returnProperty="cmd.return" passthru="1" LogOutput="true" />
<if><not><equals arg1="${cmd.return}" arg2="0" /></not>
<then>
<log msg="Can't install Drupal! Check your database connection at &quot;${project.db.url}&quot;!" indent="1" />
<fail msg="Can't install Drupal! Check your database connection at &quot;${project.db.url}&quot;!" />
</then>
</if>
<log msg="Drupal installed" />
<log msg="" />
</target>
<!--
## Set proper system permissions
-->
<target name="set-dir-permissions" depends="build-init">
<log message="Creating Drupal default files directory..." level="verbose" />
<mkdir dir="${project.dir.src}/${project.drupal.public.dir}" />
<log message="Creating Drupal private files directory..." level="verbose" />
<mkdir dir="${project.dir.src}/${project.drupal.private.dir}" />
<!-- Fix permissions for the default site directory and settings.
The owner must be able to delete the directories during subsequent builds. -->
<log message="Setting up the permissions..." level="verbose" />
<chmod file="${project.dir.src}/${project.drupal.private.dir}"
mode="0775" failonerror="true" />
<chmod file="${project.dir.src}/${project.drupal.public.dir}"
mode="0775" failonerror="true" />
</target>
<!--
## Run phing scripts
-->
<target name="run-phing-scripts" depends="build-init">
<!-- Build site -->
<if><equals arg1="${project.drupal.build.site}" arg2="true" />
<then>
<log message="Found project.drupal.build.site = true, executing build-site.xml" level="verbose"/>
<import-file path="${phing.dir.build_ads}/phing/build-site.xml" absolute="true" />
<execute-import-file-target name="build-site" />
</then>
</if>
<!-- Enable DB search -->
<if><equals arg1="${project.drupal.configure.search}" arg2="db" />
<then>
<log message="Found project.drupal.configure.search = db, executing enable-search-db.xml" level="verbose"/>
<import-file path="${phing.dir.build_ads}/phing/enable-search-db.xml" absolute="true" />
<execute-import-file-target name="enable-search-db" />
</then>
</if>
<!-- Enable Solr search -->
<if><equals arg1="${project.drupal.configure.search}" arg2="solr" />
<then>
<log message="Found project.drupal.configure.search = solr, executing enable-search-solr.xml" level="verbose"/>
<import-file path="${phing.dir.build_ads}/phing/enable-search-solr.xml" absolute="true" />
<execute-import-file-target name="enable-search-solr" />
</then>
</if>
<!-- Enable development environment -->
<if><equals arg1="${project.drupal.build.type}" arg2="dev" />
<then>
<log message="Found project.drupal.build.type = dev, executing build-dev-env.xml" level="verbose"/>
<import-file path="${phing.dir.build_ads}/phing/build-dev-env.xml" absolute="true" />
<execute-import-file-target name="build-dev-env" />
</then>
</if>
<!-- Drupal modules auto-configuration -->
<import-file path="${phing.dir.build_ads}/phing/build-configure.xml" absolute="true" />
<!-- We don't want locations import in this build -->
<property name="exclude" value="ads_locations" />
<!-- Configuring modules -->
<execute-import-file-target name="run-ads-configure" />
<!-- Generate taxonomy terms -->
<if><equals arg1="${project.drupal.generate.terms}" arg2="true" />
<then>
<log message="Found project.drupal.generate.terms = true, executing generate-terms.xml" level="verbose" />
<import-file path="${phing.dir.build_ads}/phing/generate-terms.xml" absolute="true" />
<execute-import-file-target name="generate-terms" />
</then>
</if>
<!-- Generate users -->
<if><equals arg1="${project.drupal.generate.users}" arg2="true" />
<then>
<log message="Found project.drupal.generate.users = true, executing generate-users.xml" level="verbose" />
<import-file path="${phing.dir.build_ads}/phing/generate-users.xml" absolute="true" />
<execute-import-file-target name="generate-users" />
</then>
</if>
<!-- Generate content -->
<if><equals arg1="${project.drupal.generate.content}" arg2="true" />
<then>
<log message="Found project.drupal.generate.content = true, executing generate-content.xml" level="verbose" />
<import-file path="${phing.dir.build_ads}/phing/generate-content.xml" absolute="true" />
<execute-import-file-target name="generate-content" />
</then>
</if>
<!-- Generate adverts -->
<if><equals arg1="${project.drupal.generate.ads}" arg2="true" />
<then>
<log message="Found project.drupal.generate.ads = true, executing generate-ads.xml" level="verbose" />
<import-file path="${phing.dir.build_ads}/phing/generate-ads.xml" absolute="true" />
<execute-import-file-target name="generate-ads" />
</then>
</if>
</target>
<target name="configure" depends="build-init">
<import-file path="${phing.dir.build_ads}/phing/build-configure.xml" absolute="true" />
<execute-import-file-target name="run-ads-configure" />
</target>
<!--
## Finalize Drupal installation
-->
<target name="post-install-drupal" depends="build-init">
<!-- Somehow ads_content_types is not enabling votingapi and fivestar modules even if fivestar in its dependency, we have to enable them explicitly -->
<!--
<log message="Enabling votingapi and fivestar modulse (should be enabled along with ads_content_types, assuming it's a features module bug)" level="verbose" />
<exec command="${project.drush.cmd} en votingapi fivestar" dir="${project.dir.src}" checkreturn="true" LogOutput="true" spawn="true" />
-->
<!-- Update Database and Features -->
<log message="Updating database" level="verbose" />
<exec command="${project.drush.cmd} updb" dir="${project.dir.src}" checkreturn="true" LogOutput="true" spawn="true" />
<!-- Clear cache -->
<!--
<log message="Clearing Drupal cache...${line.separator}" />
<exec command="${project.drush.cmd} cc all" dir="${project.dir.src}" checkreturn="true" LogOutput="true" spawn="true" />
-->
<!-- Revert configuration from features -->
<!-- Check if grep command is available -->
<exec command="grep --version" dir="${project.dir.src}" outputProperty="project.cmd.avail.grep" />
<if>
<contains string="${project.cmd.avail.grep}" substring="grep" />
<then>
<!-- Checking if "features" module is enabled -->
<exec command="${project.drush.cmd} pm-info features | grep -ci --regexp=&quot;Status\s+:\s:(enabled)&quot;" dir="${project.dir.src}" outputProperty="project.enabledmodules.features" />
<if>
<equals arg1="${project.enabledmodules.features}" arg2="1" />
<then>
<!-- Pull new configuration from features -->
<log message="Features module is enabled, reverting features" level="verbose" />
<exec command="${project.drush.cmd} features-revert-all" dir="${project.dir.src}" checkreturn="true" LogOutput="true" spawn="true" />
</then>
<else>
<log message="Features are not enabled. No revert will take place" level="verbose" />
</else>
</if>
</then>
</if>
<!-- Run cron -->
<log message="Running Drupal cron" level="verbose" />
<exec command="${project.drush.cmd} --php=&quot;`which php` -d sendmail_path=/dev/null&quot; core-cron" dir="${project.dir.src}" checkreturn="true" LogOutput="true" spawn="true" />
<!-- Run additional phing scripts -->
<log message="Checking phing scripts" level="verbose" />
<execute-import-file-target name="run-phing-scripts" />
<!-- Done -->
<log message="" level="info" />
<log message="Done" level="info" />
<log message="" level="info" />
<log message="NOTE:" level="info" />
<log message="You can move your newly installed distribution to your webroot" level="info" />
<log message="Or you should point your webroot at the '${project.dir.src}' folder" level="info" />
<log message="Also make sure that the following folders:" level="info" />
<log message="${project.drupal.public.dir}, ${project.drupal.private.dir}" level="info" />
<log message="are write accessible by your web server user." level="info" />
<log message="" level="info" />
</target>
</project>
You can’t perform that action at this time.