2011-08-05 9 views
18

में कुछ निर्देशिकाओं और फ़ाइलों को बाहर निकालें मेरे प्रोजेक्ट में कुछ निर्देशिकाएं और कुछ php फ़ाइलें हैं जो आकार में बहुत बड़ी हैं जिसके कारण मेरा निर्माण विफल हो रहा है और मैं उन्हें बाहर करना चाहता हूं मेरी build.xmlpdepend, phpmd, phpcpd, phpcs, phpdoc, phploc

Ques1- में मैं इस परियोजना में हर php फ़ाइल के लिए --ignore="path/filename" लिखने के लिए है?

Ques2- कुछ फ़ाइलों जो php नहीं हैं, लेकिन .dat तो मैं --ignore भी में इन फ़ाइलों का उल्लेख करना चाहिए रहे हैं?

Ques3- क्या मैं अपने आकार के आधार पर फ़ाइलों को बाहर करने के लिए निर्दिष्ट कर सकता हूं जैसे कि मैं 500kb से बड़ी सभी फ़ाइलों को बहिष्कृत करता हूं?

मेरे वर्तमान xml फ़ाइल इस तरह दिखता है:

<?xml version="1.0" encoding="UTF-8"?> 

<project name="name-of-project" default="build" basedir="."> 
    <property name="root.dir" value="${basedir}/.."/> 
    <property name="source" value="${root.dir}"/> 

<target name="clean" 
     description="Clean up and create artifact directories"> 
    <delete dir="${basedir}/build/api"/> 
    <delete dir="${basedir}/build/code-browser"/> 
    <delete dir="${basedir}/build/coverage"/> 
    <delete dir="${basedir}/build/logs"/> 
    <delete dir="${basedir}/build/pdepend"/> 

    <mkdir dir="${basedir}/build/api"/> 
    <mkdir dir="${basedir}/build/code-browser"/> 
    <mkdir dir="${basedir}/build/coverage"/> 
    <mkdir dir="${basedir}/build/logs"/> 
    <mkdir dir="${basedir}/build/pdepend"/> 
</target> 

<target name="phpunit" 
     description="Run unit tests using PHPUnit and generates junit.xml and clover.xml"> 
    <exec executable="phpunit" failonerror="true"> 
    <env key="DOCUMENT_ROOT" value="${source}/api"/> 
    <env key="MODEL_ROOT" value="${source}/model"/> 
    </exec> 
</target> 

<target name="parallelTasks" 
     description="Run the pdepend, phpmd, phpcpd, phpcs, phpdoc and phploc tasks in parallel using a maximum of 2 threads."> 
    <parallel threadCount="2"> 
    <sequential> 
    <antcall target="pdepend"/> 
    <antcall target="phpmd"/> 
    </sequential> 
    <antcall target="phpcpd"/> 
    <antcall target="phpcs"/> 
    <antcall target="phpdoc"/> 
    <antcall target="phploc"/> 
    </parallel> 
</target> 

<target name="pdepend" 
     description="Generate jdepend.xml and software metrics charts using PHP_Depend"> 
    <exec executable="pdepend"> 
    <arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" /> 
    <arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" /> 
    <arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" /> 
    <arg value="--ignore=${source}/web" /> 
    <arg path="${source}" /> 
    </exec> 
</target> 

<target name="phpmd" 
     description="Generate pmd.xml using PHPMD"> 
    <exec executable="phpmd"> 
    <arg path="${source}" /> 
    <arg value="xml" /> 
    <arg value="${basedir}/build/phpmd.xml" /> 
    <arg value="--reportfile" /> 
    <arg value="${basedir}/build/logs/pmd.xml" /> 
    <arg value="--exclude" /> 
    <arg value="${basedir}/web" /> 
    </exec> 
</target> 

<target name="phpcpd" 
     description="Generate pmd-cpd.xml using PHPCPD"> 
    <exec executable="phpcpd"> 
    <arg value="--log-pmd" /> 
    <arg value="${basedir}/build/logs/pmd-cpd.xml" /> 
    <arg value="--exclude" /> 
    <arg value="${basedir}/web" /> 
    <arg path="${source}" /> 
    </exec> 
</target> 

<target name="phploc" 
     description="Generate phploc.csv"> 
    <exec executable="phploc"> 
    <arg value="--log-csv" /> 
    <arg value="${basedir}/build/logs/phploc.csv" /> 
    <arg value="--exclude" /> 
    <arg value="${basedir}/web" /> 
    <arg path="${source}" /> 
    </exec> 
</target> 

<target name="phpcs" 
     description="Generate checkstyle.xml using PHP_CodeSniffer"> 
    <exec executable="phpcs" output="/dev/null"> 
    <arg value="--report=checkstyle" /> 
    <arg value="--report-file=${basedir}/build/logs/checkstyle.xml" /> 
    <arg value="--standard=${basedir}/build/phpcs.xml" /> 
    <arg value="--ignore=${source}/web" /> 
    <arg path="${source}" /> 
    </exec> 
</target> 

<target name="phpdoc" 
     description="Generate API documentation using PHPDocumentor"> 
    <exec executable="phpdoc"> 
    <arg value="--directory" /> 
    <arg path="${source}" /> 
    <arg value="--target" /> 
    <arg path="${basedir}/build/api" /> 
    <arg value="--ignore" /> 
    <arg path="${basedir}/web" /> 
    </exec> 
</target> 

<target name="phpcb" 
     description="Aggregate tool output with PHP_CodeBrowser"> 
    <exec executable="phpcb"> 
    <arg value="--log" /> 
    <arg path="${basedir}/build/logs" /> 
    <arg value="--source" /> 
    <arg path="${source}" /> 
    <arg value="--ignore" /> 
    <arg path="${basedir}/web" /> 
    <arg value="--output" /> 
    <arg path="${basedir}/build/code-browser" /> 
    </exec> 
</target> 

<target name="build" depends="clean,parallelTasks,phpunit,phpcb"/> 
</project> 

और मैं इन

pdepend: 
    [exec] PHP_Depend 0.10.5 by Manuel Pichler 

    [exec] Parsing source files: 
    [exec] phpcpd 1.3.2 by Sebastian Bergmann. 

    [exec] PHP Fatal error: Allowed memory size of 262144000 bytes exhausted (tried to allocate 71 bytes) in /usr/share/pear/PHPCPD/Detector.php on line 115 
    [exec] PHP Stack trace: 
    [exec] PHP 1. {main}() /usr/bin/phpcpd:0 
    [exec] PHP 2. PHPCPD_TextUI_Command::main() /usr/bin/phpcpd:51 
    [exec] PHP 3. PHPCPD_Detector->copyPasteDetection() /usr/share/pear/PHPCPD/TextUI/Command.php:216 
    [exec] PHP 4. token_get_all() /usr/share/pear/PHPCPD/Detector.php:115 
    [exec] Result: 255 

phploc: 
    [exec] phploc 1.6.1 by Sebastian Bergmann. 

    [exec] PHP Fatal error: Allowed memory size of 262144000 bytes exhausted (tried to allocate 71 bytes) in /usr/share/pear/PHPLOC/Analyser.php on line 279 
    [exec] PHP Stack trace: 
    [exec] PHP 1. {main}() /usr/bin/phploc:0 
    [exec] PHP 2. PHPLOC_TextUI_Command::main() /usr/bin/phploc:51 
    [exec] PHP 3. PHPLOC_Analyser->countFiles() /usr/share/pear/PHPLOC/TextUI/Command.php:215 
    [exec] PHP 4. PHPLOC_Analyser->countFile() /usr/share/pear/PHPLOC/Analyser.php:170 
    [exec] PHP 5. token_get_all() /usr/share/pear/PHPLOC/Analyser.php:279 
    [exec] Result: 255 

क्या मैं इसे हल करने के लिए क्या करना चाहिए की तरह त्रुटियों मिल रहा है? यदि मैं मैन्युअल रूप से निर्देशिका से बड़ी फ़ाइलों को हटा देता हूं तो बिल्ड बस पास हो जाता है लेकिन मैं चाहता हूं कि निर्माण स्वचालित रूप से svn से कोड बेस को जांचने के लिए चलाए, जिसमें इन बड़ी फ़ाइलें होंगी।

Ques4- क्या मैं अपने चेकआउट को इस तरह से कॉन्फ़िगर कर सकता हूं कि इन फ़ाइलों को चेक आउट नहीं किया जा सके?

उत्तर

27

हर लक्ष्य के लिए आप फ़ाइलसेट संपत्ति का उपयोग करें या जोड़ने निर्देशिकाओं को निकालने मैन्युअल

<target name="phploc" description="Measure project size using PHPLOC"> 
    <exec executable="phploc"> 
     <arg value="--log-csv"/> 
     <arg value="${basedir}/build/logs/phploc.csv"/> 
     <arg value="--exclude"/> 
     <arg value="${src}/api/"/> 
     <arg value="--exclude"/> 
     <arg value="${src}/external/"/> 
     <arg path="${src}"/> 
    </exec> 
</target> 

<target name="pdepend" 
     description="Calculate software metrics using PHP_Depend"> 
    <exec executable="pdepend"> 
     <arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml"/> 
     <arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg"/> 
     <arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg"/> 
     <arg value="--ignore=/dir/one/,/dir/two/"/> 
     <arg path="${src}"/> 
    </exec> 
</target> 

<target name="phpcpd" description="Find duplicate code using PHPCPD"> 
    <exec executable="phpcpd"> 
     <arg value="--log-pmd"/> 
     <arg value="${basedir}/build/logs/pmd-cpd.xml"/> 
     <arg value="--exclude"/> 
     <arg value="${src}/api/"/> 
     <arg value="--exclude"/> 
     <arg value="${src}/exclude/"/><arg path="${src}"/> 
    </exec> 
</target> 

आशा है कि मेरा उत्तर किसी के लिए उपयोगी होगा कर सकते हैं।

+6

-1 आपके नमूना कोड में 'फाइलसेट' का कोई उदाहरण नहीं है! – Ben

+1

यदि आपको फ़ाइलों को बाहर करने की आवश्यकता है (निर्देशिका नहीं), तो विकल्प का उपयोग करें - नाम- Select0r

1

In my project there are certain directories and certain php files which are very large in size due to which my build is failing and I want to exclude them in my build.xml

There are certain files which are not php but .dat so should I mention these files in the --ignore too?

मैं इस मामले में क्या कर रहा हूं, आवश्यक फाइलों की प्रतिलिपि बनाना और वहां से काम करना है। या तो पूरी निर्देशिका की प्रतिलिपि बनाएँ और कुछ फ़ाइलों को हटाएं, या केवल आवश्यक फाइलों पर प्रतिलिपि बनाएँ। पूर्व के मामले में, find कार्यक्रम करना होगा:

cp /my/large/project /tmp/work 
find /tmp/work -name "*.dat" -delete 
find /tmp/work -size 500k -delete 

बाद में, मैं ant's <copy> task उपयोग कर रहा हूँ:

<copy todir="${dir.source.our}" includeEmptyDirs="true"> 
    <fileset dir="${dir.source}/ext" includes="${glob.source.our}"/> 
</copy> 

PHP Fatal error: Allowed memory size of 262144000 bytes exhausted

आप php में पीएचपी स्मृति आकार बढ़ाने के लिए होगा .inimemory_limit के लिए खोजें और 512 एमबी की तरह कुछ मान सेट करें, उदा।

memory_limit = 512M 
+1

आप इनआई_सेट ('memory_limit', '512M') का भी उपयोग कर सकते हैं, बस इसे कॉन्फ़िगरेशन फ़ाइल में डाल दें और इसे शामिल करें। –

+1

यह सही नहीं लगता है ... – Ben

+0

एकमात्र अन्य पाठ्यक्रम विश्लेषण विफल रहा है। एक चुनो। – demonkoryu

संबंधित मुद्दे