diff --git a/src/Phing/Phing.php b/src/Phing/Phing.php
index a546149204..f8c365fbb4 100644
--- a/src/Phing/Phing.php
+++ b/src/Phing/Phing.php
@@ -112,6 +112,14 @@ class Phing
* Used by utility function getResourcePath().
*/
private static $importPaths;
+ /**
+ * Cache of the Phing version information when it has been loaded.
+ */
+ private static $phingVersion;
+ /**
+ * Cache of the short Phing version information when it has been loaded.
+ */
+ private static $phingShortVersion;
/**
* System-wide static properties (moved from System).
*/
@@ -590,33 +598,56 @@ public static function printVersion()
}
/**
- * Gets the current Phing version based on VERSION.TXT file.
+ * Gets the current Phing version based on VERSION.TXT file. Once the information
+ * has been loaded once, it's cached and returned from the cache on future
+ * calls.
*
* @throws ConfigurationException
*/
public static function getPhingVersion(): string
{
- $versionPath = self::getResourcePath('phing/etc/VERSION.TXT');
- if (null === $versionPath) {
- $versionPath = self::getResourcePath('etc/VERSION.TXT');
- }
- if (null === $versionPath) {
- throw new ConfigurationException('No VERSION.TXT file found; try setting phing.home environment variable.');
- }
+ if (self::$phingVersion === null) {
+ $versionPath = self::getResourcePath('phing/etc/VERSION.TXT');
+ if (null === $versionPath) {
+ $versionPath = self::getResourcePath('etc/VERSION.TXT');
+ }
+ if (null === $versionPath) {
+ throw new ConfigurationException('No VERSION.TXT file found; try setting phing.home environment variable.');
+ }
- try { // try to read file
- $file = new File($versionPath);
- $reader = new FileReader($file);
- $phingVersion = trim($reader->read());
- } catch (IOException $iox) {
- throw new ConfigurationException("Can't read version information file");
- }
+ try { // try to read file
+ $file = new File($versionPath);
+ $reader = new FileReader($file);
+ $phingVersion = trim($reader->read());
+ } catch (IOException $iox) {
+ throw new ConfigurationException("Can't read version information file");
+ }
- $basePath = dirname(__DIR__, 2);
+ $basePath = dirname(__DIR__, 2);
- $version = new Version($phingVersion, $basePath);
+ $version = new Version($phingVersion, $basePath);
+ self::$phingShortVersion = (method_exists($version, 'asString') ? $version->asString() : $version->getVersion());
- return 'Phing ' . (method_exists($version, 'asString') ? $version->asString() : $version->getVersion());
+ self::$phingVersion = 'Phing ' . self::$phingShortVersion;
+ }
+ return self::$phingVersion;
+ }
+
+ /**
+ * Returns the short Phing version information, if available. Once the information
+ * has been loaded once, it's cached and returned from the cache on future
+ * calls.
+ *
+ * @return the short Phing version information as a string
+ *
+ * @throws ConfigurationException
+ */
+ public static function getPhingShortVersion(): string
+ {
+ if (self::$phingShortVersion === null) {
+ self::getPhingVersion();
+ }
+ return self::$phingShortVersion;
}
/**
@@ -1530,8 +1561,7 @@ private function addInputHandler(Project $project): void
*/
private function comparePhingVersion($version): void
{
- $current = strtolower(self::getPhingVersion());
- $current = trim(str_replace('phing', '', $current));
+ $current = self::getPhingShortVersion();
// make sure that version checks are not applied to trunk
if ('dev' === $current) {
diff --git a/src/Phing/Type/AbstractFileSet.php b/src/Phing/Type/AbstractFileSet.php
index 22473ba9c0..4f79254df6 100644
--- a/src/Phing/Type/AbstractFileSet.php
+++ b/src/Phing/Type/AbstractFileSet.php
@@ -316,7 +316,7 @@ public function setIncludesfile(File $incl)
*
* @throws BuildException
*/
- public function setExcludesfile($excl)
+ public function setExcludesfile(File $excl)
{
if ($this->isReference()) {
throw $this->tooManyAttributes();
diff --git a/tests/Phing/Test/Task/System/CopyTaskTest.php b/tests/Phing/Test/Task/System/CopyTaskTest.php
index 23792ba55b..38809885bf 100644
--- a/tests/Phing/Test/Task/System/CopyTaskTest.php
+++ b/tests/Phing/Test/Task/System/CopyTaskTest.php
@@ -35,7 +35,7 @@ public function setUp(): void
{
$this->configureProject(
PHING_TEST_BASE
- . '/etc/tasks/system/CopyTaskTest.xml'
+ . '/etc/tasks/system/CopyTask/CopyTaskTest.xml'
);
$this->executeTarget('setup');
}
@@ -90,11 +90,26 @@ public function testOverwriteExistingSymlink(): void
{
$this->executeTarget(__FUNCTION__);
$this->assertInLogs('Copying 1 file to');
- $this->assertEquals('tmp/target-a', readlink(PHING_TEST_BASE . '/etc/tasks/system/tmp/link-b'));
+ $this->assertEquals('tmp/target-a', readlink(PHING_TEST_BASE . '/etc/tasks/system/CopyTask/tmp/link-b'));
}
public function testGranularity(): void
{
$this->expectLogContaining(__FUNCTION__, 'Test omitted, Test is up to date');
}
+
+ public function testFilesetFiles(): void
+ {
+ $destinationDir = PHING_TEST_BASE . '/etc/tasks/system/CopyTask/tmp/destination';
+ $this->assertDirectoryDoesNotExist($destinationDir);
+ $this->executeTarget(__FUNCTION__);
+ $this->assertFileExists("$destinationDir/Foo/Foo.php");
+ $this->assertFileExists("$destinationDir/Bar/Bar.php");
+ $this->assertFileExists("$destinationDir/Baz/Baz.php");
+ $this->assertFileExists("$destinationDir/Qux/Qux.php");
+ $this->assertFileDoesNotExist("$destinationDir/Foo/FooTest.php");
+ $this->assertFileDoesNotExist("$destinationDir/Bar/BarTest.php");
+ $this->assertFileDoesNotExist("$destinationDir/Baz/BazTest.php");
+ $this->assertFileDoesNotExist("$destinationDir/Qux/QuxTest.php");
+ }
}
diff --git a/tests/etc/tasks/system/CopyTaskTest.xml b/tests/etc/tasks/system/CopyTask/CopyTaskTest.xml
similarity index 72%
rename from tests/etc/tasks/system/CopyTaskTest.xml
rename to tests/etc/tasks/system/CopyTask/CopyTaskTest.xml
index 152296f3bd..f58cc60bc8 100644
--- a/tests/etc/tasks/system/CopyTaskTest.xml
+++ b/tests/etc/tasks/system/CopyTask/CopyTaskTest.xml
@@ -80,5 +80,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/etc/tasks/system/CopyTask/excludes.txt b/tests/etc/tasks/system/CopyTask/excludes.txt
new file mode 100644
index 0000000000..418870a5b4
--- /dev/null
+++ b/tests/etc/tasks/system/CopyTask/excludes.txt
@@ -0,0 +1 @@
+**/*Test.php
diff --git a/tests/etc/tasks/system/CopyTask/includes.txt b/tests/etc/tasks/system/CopyTask/includes.txt
new file mode 100644
index 0000000000..27098fe8b7
--- /dev/null
+++ b/tests/etc/tasks/system/CopyTask/includes.txt
@@ -0,0 +1 @@
+**/*.php