diff --git a/src/Composer/Composer.php b/src/Composer/Composer.php
index b5bbb0a0b..c7ab40039 100644
--- a/src/Composer/Composer.php
+++ b/src/Composer/Composer.php
@@ -55,6 +55,17 @@ class Composer
const RELEASE_DATE = '@release_date@';
const SOURCE_VERSION = '2.0-dev+source';
+ /**
+ * Version number of the internal composer-runtime-api package
+ *
+ * This is used to version features available to projects at runtime
+ * like the platform-check file, the Composer\InstalledVersions class
+ * and possibly others in the future.
+ *
+ * @var string
+ */
+ const RUNTIME_API_VERSION = '2.0.0';
+
public static function getVersion()
{
// no replacement done, this must be a source checkout
diff --git a/src/Composer/DependencyResolver/Transaction.php b/src/Composer/DependencyResolver/Transaction.php
index 1e681a04f..a919238f6 100644
--- a/src/Composer/DependencyResolver/Transaction.php
+++ b/src/Composer/DependencyResolver/Transaction.php
@@ -261,9 +261,9 @@ class Transaction
// is this a plugin or a dependency of a plugin?
if ($isPlugin || count(array_intersect($package->getNames(), $pluginRequires))) {
- // get the package's requires, but filter out any platform requirements or 'composer-plugin-api'
+ // get the package's requires, but filter out any platform requirements
$requires = array_filter(array_keys($package->getRequires()), function ($req) {
- return $req !== 'composer-plugin-api' && !preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req);
+ return !preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req);
});
// is this a plugin with no meaningful dependencies?
diff --git a/src/Composer/Plugin/PluginInterface.php b/src/Composer/Plugin/PluginInterface.php
index 4390764ff..f18799e7b 100644
--- a/src/Composer/Plugin/PluginInterface.php
+++ b/src/Composer/Plugin/PluginInterface.php
@@ -25,6 +25,11 @@ interface PluginInterface
/**
* Version number of the internal composer-plugin-api package
*
+ * This is used to denote the API version of Plugin specific
+ * features, but is also bumped to a new major if Composer
+ * includes a major break in internal APIs which are susceptible
+ * to be used by plugins.
+ *
* @var string
*/
const PLUGIN_API_VERSION = '2.0.0';
diff --git a/src/Composer/Plugin/PluginManager.php b/src/Composer/Plugin/PluginManager.php
index 97757f4fa..1dbbd2960 100644
--- a/src/Composer/Plugin/PluginManager.php
+++ b/src/Composer/Plugin/PluginManager.php
@@ -134,8 +134,8 @@ class PluginManager
$currentPluginApiVersion = $this->getPluginApiVersion();
$currentPluginApiConstraint = new Constraint('==', $this->versionParser->normalize($currentPluginApiVersion));
- if ($requiresComposer->getPrettyString() === '1.0.0' && $this->getPluginApiVersion() === '1.0.0') {
- $this->io->writeError('The "' . $package->getName() . '" plugin requires composer-plugin-api 1.0.0, this *WILL* break in the future and it should be fixed ASAP (require ^1.0 for example).');
+ if ($requiresComposer->getPrettyString() === $this->getPluginApiVersion()) {
+ $this->io->writeError('The "' . $package->getName() . '" plugin requires composer-plugin-api '.$this->getPluginApiVersion().', this *WILL* break in the future and it should be fixed ASAP (require ^'.$this->getPluginApiVersion().' instead for example).');
} elseif (!$requiresComposer->matches($currentPluginApiConstraint)) {
$this->io->writeError('The "' . $package->getName() . '" plugin was skipped because it requires a Plugin API version ("' . $requiresComposer->getPrettyString() . '") that does not match your Composer installation ("' . $currentPluginApiVersion . '"). You may need to run composer update with the "--no-plugins" option.');
diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php
index 5e9e0c5b3..7082d29c2 100644
--- a/src/Composer/Repository/ComposerRepository.php
+++ b/src/Composer/Repository/ComposerRepository.php
@@ -502,7 +502,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
{
if (!$this->hasPartialPackages() || !isset($this->partialPackagesByName[$name])) {
// skip platform packages, root package and composer-plugin-api
- if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name) || '__root__' === $name || 'composer-plugin-api' === $name) {
+ if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name) || '__root__' === $name) {
return array();
}
@@ -672,7 +672,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
$realName = preg_replace('{~dev$}', '', $name);
// skip platform packages, root package and composer-plugin-api
- if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $realName) || '__root__' === $realName || 'composer-plugin-api' === $realName) {
+ if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $realName) || '__root__' === $realName) {
continue;
}
diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php
index 84f3d4b66..6ee05ca60 100644
--- a/src/Composer/Repository/PlatformRepository.php
+++ b/src/Composer/Repository/PlatformRepository.php
@@ -20,6 +20,7 @@ use Composer\Util\ProcessExecutor;
use Composer\Util\Silencer;
use Composer\Util\Platform;
use Composer\XdebugHandler\XdebugHandler;
+use Composer\Composer;
use Symfony\Component\Process\ExecutableFinder;
/**
@@ -27,7 +28,7 @@ use Symfony\Component\Process\ExecutableFinder;
*/
class PlatformRepository extends ArrayRepository
{
- const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[a-z0-9](?:[_.-]?[a-z0-9]+)*|composer-plugin-api)$}iD';
+ const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[a-z0-9](?:[_.-]?[a-z0-9]+)*|composer-(?:plugin|runtime)-api)$}iD';
private $versionParser;
@@ -79,6 +80,12 @@ class PlatformRepository extends ArrayRepository
$composerPluginApi->setDescription('The Composer Plugin API');
$this->addPackage($composerPluginApi);
+ $prettyVersion = Composer::RUNTIME_API_VERSION;
+ $version = $this->versionParser->normalize($prettyVersion);
+ $composerRuntimeApi = new CompletePackage('composer-runtime-api', $version, $prettyVersion);
+ $composerRuntimeApi->setDescription('The Composer Runtime API');
+ $this->addPackage($composerRuntimeApi);
+
try {
$prettyVersion = PHP_VERSION;
$version = $this->versionParser->normalize($prettyVersion);