Changeset 787

Show
Ignore:
Timestamp:
08/09/07 11:56:27 (1 year ago)
Author:
mikey
Message:

moved js-min from src to lib directory, added option to set the js min path within the task
copy javascript files to release as well as minified versions of them

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/info/phing/tasks/stubJsMinTask.php

    r773 r787  
    1212require_once 'phing/Task.php'; 
    1313/** 
    14  * Uses the jsmin PHP port 
    15  */ 
    16 require_once dirname(__FILE__) . '/jsmin-1.1.0.php'; 
    17 /** 
    1814 * Task to minimy javascript files. 
    1915 * 
     
    2319class stubJsMinTask extends Task 
    2420{ 
     21    /** 
     22     * path to JSmin 
     23     * 
     24     * @var  string 
     25     */ 
     26    protected $jsMinPath; 
    2527    /** 
    2628     * the source files 
     
    4244     */ 
    4345    protected $targetDir; 
     46 
     47    /** 
     48     * sets the path where JSmin can be found 
     49     * 
     50     * @param  string  $jsMinPath 
     51     */ 
     52    public function setJsMinPath($jsMinPath) 
     53    { 
     54        $this->jsMinPath = $jsMinPath; 
     55    } 
    4456 
    4557    /** 
     
    7789    public function init() 
    7890    { 
    79         // nothing to do here 
     91        return true; 
    8092    } 
    8193 
     
    8597    public function main() 
    8698    { 
     99        if (class_exists('JSMin', false) == false) { 
     100            require_once $this->jsMinPath; 
     101        } 
     102         
    87103        $error = false; 
    88104        foreach ($this->filesets as $fs) { 
     
    93109                    $this->log('Minifying file ' . $file); 
    94110                    try { 
    95                         $target = $this->targetDir . '/' . str_replace($fullPath, '', $file); 
     111                        $target = $this->targetDir . '/' . str_replace($fullPath, '', str_replace('.js', '-min.js', $file)); 
    96112                        if (file_exists(dirname($target)) == false) { 
    97113                            mkdir(dirname($target), 0700, true);