diff --git a/src/DrupalCI/Plugin/BuildSteps/generic/Composer.php b/src/DrupalCI/Plugin/BuildSteps/generic/Composer.php new file mode 100644 index 0000000..fefc0f1 --- /dev/null +++ b/src/DrupalCI/Plugin/BuildSteps/generic/Composer.php @@ -0,0 +1,54 @@ +getJobCodebase()->getWorkingDir(); + + foreach ($data_list as $data) { + $cmd = $this->buildComposerCommand($data, $workingdir); + $this->exec($cmd, $cmdoutput, $result); + } + } + + /** + * Returns a full composer command based on the passed-in arguments. + * + * @param string $arguments + * The arguments for the composer command. + * + * @return string + * The full composer command string. + */ + protected function buildComposerCommand($data, $workingdir) { + return "composer $data $workingdir"; + } + +} diff --git a/src/DrupalCI/Plugin/BuildSteps/setup/Composer.php b/src/DrupalCI/Plugin/BuildSteps/setup/Composer.php deleted file mode 100644 index a8463cc..0000000 --- a/src/DrupalCI/Plugin/BuildSteps/setup/Composer.php +++ /dev/null @@ -1,53 +0,0 @@ -getJobCodebase()->getWorkingDir(); - - foreach ($data_list as $data) { - $cmd = $this->buildComposerCommand($data, $workingdir); - $this->exec($cmd, $cmdoutput, $result); - } - } - - /** - * Returns a full composer command based on the passed-in arguments. - * - * @param string $arguments - * The arguments for the composer command. - * - * @return string - * The full composer command string. - */ - protected function buildComposerCommand($data, $workingdir) { - return "composer $data $workingdir"; - } - -} diff --git a/src/DrupalCI/Plugin/Preprocess/definition/ComposerInstall.php b/src/DrupalCI/Plugin/Preprocess/definition/ComposerInstall.php index 999c056..43d62b0 100644 --- a/src/DrupalCI/Plugin/Preprocess/definition/ComposerInstall.php +++ b/src/DrupalCI/Plugin/Preprocess/definition/ComposerInstall.php @@ -43,6 +43,28 @@ class ComposerInstall { $definition['setup']['composer'] = []; } - $definition['setup']['composer'][] = "install --prefer-dist --working-dir "; + $definition['setup']['composer'][] = 'install --prefer-dist --working-dir '; + + // Run additional composer steps for contrib modules. + if ($this->hasComposerDependencies($definition)) { + $definition['setup']['composer'][] = 'config repositories.drupal composer https://packagist.drupal-composer.org --working-dir '; + $definition['setup']['composer'][] = 'require mile23/drupal-merge-plugin --working-dir '; + $definition['setup']['composer'][] = 'update --working-dir '; + } + } + + /** + * Check to see if additional repositories make use of composer. + * + * This will return TRUE for all cases where an additional repository is + * defined in the job because at this point the job is being preprocessed, + * and no files have been downloaded yet. + * + * @param array $definition + * The job definition array. + * @return boolean + */ + protected function hasComposerDependencies(array $definition) { + return count($definition['setup']['checkout']) > 1; } }