PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS #burningkeyboards @denis_ristic
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS INTRO ‣Maintaining code quality over time is a hard challenge. It becomes even harder in large projects developed by many programmers. ‣Each person has different code styles and different ways to approach problems. ‣Over time, this may result in confusing and unmaintainable code. ‣Static analysis tools can help developers solve this problem, they enforce coding standards, detect common errors and cleanup code blocks. 2
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS CODE SNIFFER ‣https://github.com/squizlabs/PHP_CodeSniffer ‣Code Sniffer is arguably the most popular tool to enforce a strict style guide in your PHP code. ‣It ships with support for popular coding standards such as PSR2, Zend, PEAR among others. ‣The PSR standard family is used by most people nowadays because it was created by the FIG group so if you are looking for a standard to adopt, PSR2 is a good option. 3
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS CODE SNIFFER $ phpcs tests.php --report-full --standard=PSR2 FILE: tests.php -------------------------------------------------------------------------- FOUND 7 ERRORS AND 2 WARNINGS AFFECTING 6 LINES -------------------------------------------------------------------------- 2 | WARNING | [ ] Line exceeds 120 characters; contains 128 characters 3 | WARNING | [ ] Line exceeds 120 characters; contains 139 characters 8 | ERROR | [ ] Each class must be in a namespace of at least one leve 8 | ERROR | [ ] Class name "foo_foo" is not in camel caps format 16 | ERROR | [ ] Method name "foo_foo::bar_bar" is not in camel caps 23 | ERROR | [ ] Each class must be in a file by itself 23 | ERROR | [ ] Each class must be in a namespace of at least one leve 33 | ERROR | [x] Expected 1 newline at end of file; 0 found 33 | ERROR | [x] A closing tag is not permitted at the end of a file -------------------------------------------------------------------------- PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY -------------------------------------------------------------------------- 4
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS MESS DETECTOR ‣https://phpmd.org/ ‣PHPMD can be seen as an user friendly and easy to configure frontend for the raw metrics measured by PHP Depend. ‣It takes a given PHP source code base and look for several potential problems within that source. These problems can be things like: ‣Possible bugs ‣Suboptimal code ‣Overcomplicated expressions ‣Unused parameters, methods, properties 5
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS MESS DETECTOR $ phpmd tests.php text ruleset tests.php:8 The class foo_foo is not named in CamelCase. tests.php:8 The property $my_property is not named in camelCase. tests.php:16 Avoid unused parameters such as '$arg1'. tests.php:16 Avoid unused parameters such as '$arg2'. tests.php:16 bar_bar accesses the super-global variable $_POST. tests.php:16 The method bar_bar is not named in camelCase. tests.php:19 Avoid unused local variables such as '$some_name'. tests.php:27 The method barBar has 11 parameters. Consider to reduce parameter number under 10. tests.php:29 Avoid unused local variables such as '$someName'. 6
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS PHP DEPEND ‣https://pdepend.org/ ‣PHP_Depend can be used in an automated build environment and the generated reports are always objective, it just measures the quality facts of a given source base. ‣PHP_Depend scales with growing source bases, where human code reviews will fail at some day. ‣PHP_Depend allows you to identify suspect parts in a software system that should be part of a code review, without looking into the source. ‣PHP_Depend also supports some fancy metrics that will become very useful, when you have reached certain level of metrics knowledge. 7
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS PHP DEPEND $ pdepend —summary-xml=/tmp/summary.xml —jdepend-chart=/tmp/jdepend.svg --overview-pyramid=/tmp/pyramid.svg /usr/local/share/pear/PDepend PHP_Depend 0.9.4 by Manuel Pichler Parsing source files: ............................................................ 60 Executing NPathComplexity-Analyzer: ........................................... 869 Executing Coupling-Analyzer: ........................................................... 1193 Executing NodeCount-Analyzer: ................................. 677 Executing Dependency-Analyzer: ................................... 703 Executing Hierarchy-Analyzer: ........................................... 880 Executing Inheritance-Analyzer: ..................... 421 Executing CodeRank-Analyzer: ...... 126 Executing CyclomaticComplexity-Analyzer: ........................................... 869 Generating pdepend log files, this may take a moment. Time: 00:13; Memory: 15.00Mb 8
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS PHP DEPEND 9
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS PHP COPY/PASTE DETECTOR ‣https://github.com/sebastianbergmann/phpcpd ‣Copy/Paste Detector (CPD) for PHP code. 10
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS PHP COPY/PASTE DETECTOR $ phpcpd . phpcpd 2.0.1 by Sebastian Bergmann. Found 1 exact clones with 19 duplicated lines in 2 files: - foo.php:9-28 bar.php:18-37 1.32% duplicated lines out of 1439 total lines of code. Time: 21 ms, Memory: 2.50Mb 11
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS PHPMETRICS ‣http://www.phpmetrics.org/ ‣PhpMetrics provides various metrics about PHP projects: ‣Complexity: Cyclomatic complexity, Myer's interval, Relative system complexity ‣Volume: Vocabulary, Data complexity, Lines of code, Readability... ‣Object Oriented: Lack of cohesion of methods, Coupling, Abstraction... ‣Maintainability: Maintainability index, Halstead's metrics, Effort... 12
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS PHPMETRICS 13
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS PHP CS FIXER ‣https://github.com/fabpot/PHP-CS-Fixer ‣A tool to automatically fix PHP coding standards issues 14
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS PHP CS FIXER $ php-cs-fixer fix --dry-run . --level=psr2 1) foo.php (php_closing_tag, eof_ending) 2) bar.php (braces, function_declaration, eof_ending) 15
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS PHP CODE BEAUTIFIER AND FIXER ‣https://github.com/squizlabs/PHP_CodeSniffer ‣Automatically corrects coding standard violations 16
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS PHP CODE BEAUTIFIER AND FIXER $ phpcbf /path/to/code Processing init.php [PHP => 7875 tokens in 960 lines]... DONE in 274ms (12 fixable violations) => Fixing file: 0/12 violations remaining [made 3 passes]... DONE in 412ms Processing config.php [PHP => 8009 tokens in 957 lines]... DONE in 421ms (155 fixable violations) => Fixing file: 0/155 violations remaining [made 7 passes]... DONE in 937ms Patched 2 files Time: 2.55 secs, Memory: 25.00Mb 17
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS PHPLOC ‣https://github.com/sebastianbergmann/phploc ‣A tool for quickly measuring the size of a PHP project. 18
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS PHPLOC $ phploc src phploc 4.0.0 by Sebastian Bergmann. Directories 3 Files 10 Size Lines of Code (LOC) 1882 Comment Lines of Code (CLOC) 255 (13.55%) Non-Comment Lines of Code (NCLOC) 1627 (86.45%) Logical Lines of Code (LLOC) 377 (20.03%) Classes 351 (93.10%) Average Class Length 35 Minimum Class Length 0 Maximum Class Length 172 Average Method Length 2 Minimum Method Length 1 Maximum Method Length 117 Functions 0 (0.00%) Average Function Length 0 Not in classes or functions 26 (6.90%) 19
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS PHPLOC Cyclomatic Complexity Average Complexity per LLOC 0.49 Average Complexity per Class 19.60 Minimum Class Complexity 1.00 Maximum Class Complexity 139.00 Average Complexity per Method 2.43 Minimum Method Complexity 1.00 Maximum Method Complexity 96.00 Dependencies Global Accesses 0 Global Constants 0 (0.00%) Global Variables 0 (0.00%) Super-Global Variables 0 (0.00%) Attribute Accesses 85 Non-Static 85 (100.00%) Static 0 (0.00%) Method Calls 280 Non-Static 276 (98.57%) Static 4 (1.43%) 20
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS PHPLOC Structure Namespaces 3 Interfaces 1 Traits 0 Classes 9 Abstract Classes 0 (0.00%) Concrete Classes 9 (100.00%) Methods 130 Scope Non-Static Methods 130 (100.00%) Static Methods 0 (0.00%) Visibility Public Methods 103 (79.23%) Non-Public Methods 27 (20.77%) Functions 0 Named Functions 0 (0.00%) Anonymous Functions 0 (0.00%) Constants 0 Global Constants 0 (0.00%) Class Constants 0 (0.00%) 21
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS PHPDOX ‣http://phpdox.de/ ‣phpDox is the documentation generator for PHP projects. ‣This includes, but is not limited to, API documentation. ‣DEMO: http://phpdox.de/demo.html 22
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS PHPDOCUMENTATOR ‣https://www.phpdoc.org/ ‣phpDocumentor analyzes your code to create great documentation ‣phpDocumentor enables you to generate documentation from your PHP source code. ‣This documentation provides an in-depth view of your project to you, your consumers and contributors. ‣DEMO: http://demo.phpdoc.org/ 23
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS * PHING ‣https://www.phing.info/ ‣Phing is a PHP project build system or build tool based on Apache Ant. You can do anything with it that you could do with a traditional build system like GNU make, and its use of simple XML build files and extensible PHP "task" classes make it an easy-to-use and highly flexible build framework. ‣Features include running PHPUnit unit tests (including test result and coverage reports), file transformations (e.g. token replacement, XSLT transformation, template transformations), file system operations, interactive build support, SQL execution, Git operations, tools for creating PEAR packages, code analysis, documentation generation (PhpDocumentor, PhpDox) and much, much more. ‣If you find yourself writing custom scripts to handle the packaging, deploying, or testing of your applications, then we suggest looking at Phing. Pre-packaged with numerous out-of-the-box operation modules (tasks), and an easy-to-use OO model to extend or add your own custom tasks. 24
PHP STATIC ANALYSIS TOOLS & DOCUMENTATION GENERATORS * PHING <?xml version="1.0" encoding="UTF-8"?> <project name="FooBar" default="dist"> <target name="prepare"> <echo msg="Making directory ./build" /> <mkdir dir="./build" /> </target> <target name="build" depends="prepare"> <echo msg="Copying files to build directory..." /> <echo msg="Copying ./about.php to ./build directory..." /> <copy file="./about.php" tofile="./build/about.php" /> <echo msg="Copying ./browsers.php to ./build directory..." /> <copy file="./browsers.php" tofile="./build/browsers.php" /> </target> <target name="dist" depends="build"> <echo msg="Creating archive..." /> <tar destfile="./build/build.tar.gz" compression="gzip"> <fileset dir="./build"> <include name="*" /> </fileset> </tar> <echo msg="Files copied and compressed in build directory OK!" /> </target> </project> 25

20 PHP Static Analysis and Documentation Generators #burningkeyboards

  • 1.
    PHP STATIC ANALYSIS TOOLS& DOCUMENTATION GENERATORS #burningkeyboards @denis_ristic
  • 2.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS INTRO ‣Maintaining code quality over time is a hard challenge. It becomes even harder in large projects developed by many programmers. ‣Each person has different code styles and different ways to approach problems. ‣Over time, this may result in confusing and unmaintainable code. ‣Static analysis tools can help developers solve this problem, they enforce coding standards, detect common errors and cleanup code blocks. 2
  • 3.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS CODE SNIFFER ‣https://github.com/squizlabs/PHP_CodeSniffer ‣Code Sniffer is arguably the most popular tool to enforce a strict style guide in your PHP code. ‣It ships with support for popular coding standards such as PSR2, Zend, PEAR among others. ‣The PSR standard family is used by most people nowadays because it was created by the FIG group so if you are looking for a standard to adopt, PSR2 is a good option. 3
  • 4.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS CODE SNIFFER $ phpcs tests.php --report-full --standard=PSR2 FILE: tests.php -------------------------------------------------------------------------- FOUND 7 ERRORS AND 2 WARNINGS AFFECTING 6 LINES -------------------------------------------------------------------------- 2 | WARNING | [ ] Line exceeds 120 characters; contains 128 characters 3 | WARNING | [ ] Line exceeds 120 characters; contains 139 characters 8 | ERROR | [ ] Each class must be in a namespace of at least one leve 8 | ERROR | [ ] Class name "foo_foo" is not in camel caps format 16 | ERROR | [ ] Method name "foo_foo::bar_bar" is not in camel caps 23 | ERROR | [ ] Each class must be in a file by itself 23 | ERROR | [ ] Each class must be in a namespace of at least one leve 33 | ERROR | [x] Expected 1 newline at end of file; 0 found 33 | ERROR | [x] A closing tag is not permitted at the end of a file -------------------------------------------------------------------------- PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY -------------------------------------------------------------------------- 4
  • 5.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS MESS DETECTOR ‣https://phpmd.org/ ‣PHPMD can be seen as an user friendly and easy to configure frontend for the raw metrics measured by PHP Depend. ‣It takes a given PHP source code base and look for several potential problems within that source. These problems can be things like: ‣Possible bugs ‣Suboptimal code ‣Overcomplicated expressions ‣Unused parameters, methods, properties 5
  • 6.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS MESS DETECTOR $ phpmd tests.php text ruleset tests.php:8 The class foo_foo is not named in CamelCase. tests.php:8 The property $my_property is not named in camelCase. tests.php:16 Avoid unused parameters such as '$arg1'. tests.php:16 Avoid unused parameters such as '$arg2'. tests.php:16 bar_bar accesses the super-global variable $_POST. tests.php:16 The method bar_bar is not named in camelCase. tests.php:19 Avoid unused local variables such as '$some_name'. tests.php:27 The method barBar has 11 parameters. Consider to reduce parameter number under 10. tests.php:29 Avoid unused local variables such as '$someName'. 6
  • 7.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS PHP DEPEND ‣https://pdepend.org/ ‣PHP_Depend can be used in an automated build environment and the generated reports are always objective, it just measures the quality facts of a given source base. ‣PHP_Depend scales with growing source bases, where human code reviews will fail at some day. ‣PHP_Depend allows you to identify suspect parts in a software system that should be part of a code review, without looking into the source. ‣PHP_Depend also supports some fancy metrics that will become very useful, when you have reached certain level of metrics knowledge. 7
  • 8.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS PHP DEPEND $ pdepend —summary-xml=/tmp/summary.xml —jdepend-chart=/tmp/jdepend.svg --overview-pyramid=/tmp/pyramid.svg /usr/local/share/pear/PDepend PHP_Depend 0.9.4 by Manuel Pichler Parsing source files: ............................................................ 60 Executing NPathComplexity-Analyzer: ........................................... 869 Executing Coupling-Analyzer: ........................................................... 1193 Executing NodeCount-Analyzer: ................................. 677 Executing Dependency-Analyzer: ................................... 703 Executing Hierarchy-Analyzer: ........................................... 880 Executing Inheritance-Analyzer: ..................... 421 Executing CodeRank-Analyzer: ...... 126 Executing CyclomaticComplexity-Analyzer: ........................................... 869 Generating pdepend log files, this may take a moment. Time: 00:13; Memory: 15.00Mb 8
  • 9.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS PHP DEPEND 9
  • 10.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS PHP COPY/PASTE DETECTOR ‣https://github.com/sebastianbergmann/phpcpd ‣Copy/Paste Detector (CPD) for PHP code. 10
  • 11.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS PHP COPY/PASTE DETECTOR $ phpcpd . phpcpd 2.0.1 by Sebastian Bergmann. Found 1 exact clones with 19 duplicated lines in 2 files: - foo.php:9-28 bar.php:18-37 1.32% duplicated lines out of 1439 total lines of code. Time: 21 ms, Memory: 2.50Mb 11
  • 12.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS PHPMETRICS ‣http://www.phpmetrics.org/ ‣PhpMetrics provides various metrics about PHP projects: ‣Complexity: Cyclomatic complexity, Myer's interval, Relative system complexity ‣Volume: Vocabulary, Data complexity, Lines of code, Readability... ‣Object Oriented: Lack of cohesion of methods, Coupling, Abstraction... ‣Maintainability: Maintainability index, Halstead's metrics, Effort... 12
  • 13.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS PHPMETRICS 13
  • 14.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS PHP CS FIXER ‣https://github.com/fabpot/PHP-CS-Fixer ‣A tool to automatically fix PHP coding standards issues 14
  • 15.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS PHP CS FIXER $ php-cs-fixer fix --dry-run . --level=psr2 1) foo.php (php_closing_tag, eof_ending) 2) bar.php (braces, function_declaration, eof_ending) 15
  • 16.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS PHP CODE BEAUTIFIER AND FIXER ‣https://github.com/squizlabs/PHP_CodeSniffer ‣Automatically corrects coding standard violations 16
  • 17.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS PHP CODE BEAUTIFIER AND FIXER $ phpcbf /path/to/code Processing init.php [PHP => 7875 tokens in 960 lines]... DONE in 274ms (12 fixable violations) => Fixing file: 0/12 violations remaining [made 3 passes]... DONE in 412ms Processing config.php [PHP => 8009 tokens in 957 lines]... DONE in 421ms (155 fixable violations) => Fixing file: 0/155 violations remaining [made 7 passes]... DONE in 937ms Patched 2 files Time: 2.55 secs, Memory: 25.00Mb 17
  • 18.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS PHPLOC ‣https://github.com/sebastianbergmann/phploc ‣A tool for quickly measuring the size of a PHP project. 18
  • 19.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS PHPLOC $ phploc src phploc 4.0.0 by Sebastian Bergmann. Directories 3 Files 10 Size Lines of Code (LOC) 1882 Comment Lines of Code (CLOC) 255 (13.55%) Non-Comment Lines of Code (NCLOC) 1627 (86.45%) Logical Lines of Code (LLOC) 377 (20.03%) Classes 351 (93.10%) Average Class Length 35 Minimum Class Length 0 Maximum Class Length 172 Average Method Length 2 Minimum Method Length 1 Maximum Method Length 117 Functions 0 (0.00%) Average Function Length 0 Not in classes or functions 26 (6.90%) 19
  • 20.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS PHPLOC Cyclomatic Complexity Average Complexity per LLOC 0.49 Average Complexity per Class 19.60 Minimum Class Complexity 1.00 Maximum Class Complexity 139.00 Average Complexity per Method 2.43 Minimum Method Complexity 1.00 Maximum Method Complexity 96.00 Dependencies Global Accesses 0 Global Constants 0 (0.00%) Global Variables 0 (0.00%) Super-Global Variables 0 (0.00%) Attribute Accesses 85 Non-Static 85 (100.00%) Static 0 (0.00%) Method Calls 280 Non-Static 276 (98.57%) Static 4 (1.43%) 20
  • 21.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS PHPLOC Structure Namespaces 3 Interfaces 1 Traits 0 Classes 9 Abstract Classes 0 (0.00%) Concrete Classes 9 (100.00%) Methods 130 Scope Non-Static Methods 130 (100.00%) Static Methods 0 (0.00%) Visibility Public Methods 103 (79.23%) Non-Public Methods 27 (20.77%) Functions 0 Named Functions 0 (0.00%) Anonymous Functions 0 (0.00%) Constants 0 Global Constants 0 (0.00%) Class Constants 0 (0.00%) 21
  • 22.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS PHPDOX ‣http://phpdox.de/ ‣phpDox is the documentation generator for PHP projects. ‣This includes, but is not limited to, API documentation. ‣DEMO: http://phpdox.de/demo.html 22
  • 23.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS PHPDOCUMENTATOR ‣https://www.phpdoc.org/ ‣phpDocumentor analyzes your code to create great documentation ‣phpDocumentor enables you to generate documentation from your PHP source code. ‣This documentation provides an in-depth view of your project to you, your consumers and contributors. ‣DEMO: http://demo.phpdoc.org/ 23
  • 24.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS * PHING ‣https://www.phing.info/ ‣Phing is a PHP project build system or build tool based on Apache Ant. You can do anything with it that you could do with a traditional build system like GNU make, and its use of simple XML build files and extensible PHP "task" classes make it an easy-to-use and highly flexible build framework. ‣Features include running PHPUnit unit tests (including test result and coverage reports), file transformations (e.g. token replacement, XSLT transformation, template transformations), file system operations, interactive build support, SQL execution, Git operations, tools for creating PEAR packages, code analysis, documentation generation (PhpDocumentor, PhpDox) and much, much more. ‣If you find yourself writing custom scripts to handle the packaging, deploying, or testing of your applications, then we suggest looking at Phing. Pre-packaged with numerous out-of-the-box operation modules (tasks), and an easy-to-use OO model to extend or add your own custom tasks. 24
  • 25.
    PHP STATIC ANALYSISTOOLS & DOCUMENTATION GENERATORS * PHING <?xml version="1.0" encoding="UTF-8"?> <project name="FooBar" default="dist"> <target name="prepare"> <echo msg="Making directory ./build" /> <mkdir dir="./build" /> </target> <target name="build" depends="prepare"> <echo msg="Copying files to build directory..." /> <echo msg="Copying ./about.php to ./build directory..." /> <copy file="./about.php" tofile="./build/about.php" /> <echo msg="Copying ./browsers.php to ./build directory..." /> <copy file="./browsers.php" tofile="./build/browsers.php" /> </target> <target name="dist" depends="build"> <echo msg="Creating archive..." /> <tar destfile="./build/build.tar.gz" compression="gzip"> <fileset dir="./build"> <include name="*" /> </fileset> </tar> <echo msg="Files copied and compressed in build directory OK!" /> </target> </project> 25