Changeset 4824

Show
Ignore:
Timestamp:
12/27/06 16:03:46 (2 years ago)
Author:
tarjei
Message:

The start of a importStyle task as well as linking of schemas (not all thugh )

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/build

    • Property svn:ignore set to
      –F
  • trunk/src/build.xml

    r4135 r4824  
    33        <!-- edit the properties in this file to your liking. 
    44        --> 
    5         <property file="build.properties"  />   
     5        <property file="build.properties"  /> 
    66        <property name="absolute_basedir" value="" /> 
    77        <resolvepath propertyName="absolute_basedir" file="${project.basedir}"/> 
    8          
    9         <taskdef classname="build.installMidcomDir"  
    10                      name="installMidcomDir"  
     8 
     9        <taskdef classname="build.installMidcomDir" 
     10                     name="installMidcomDir" 
    1111                         classpath="/${project.basedir}" 
    1212        /> 
    13         <taskdef classname="build.makeProjectList"  
    14                                      name="makeProjectList"  
     13        <taskdef classname="build.makeProjectList" 
     14                                     name="makeProjectList" 
    1515                                         classpath="/${project.basedir}" 
    1616                        /> 
    17         <taskdef classname="build.installMidcomCore"  
    18                                      name="installMidcomCore"  
     17        <taskdef classname="build.installMidcomCore" 
     18                                     name="installMidcomCore" 
    1919                                         classpath="/${project.basedir}" 
    2020                        /> 
    21         <taskdef classname="build.packageMidCOM"  
    22                                              name="packageMidCOM"  
     21        <taskdef classname="build.packageMidCOM" 
     22                                             name="packageMidCOM" 
    2323                                                 classpath="/${project.basedir}" 
    2424                                /> 
    2525        <!-- task to package static-icons for now --> 
    26         <taskdef classname="build.packageStatic"  
    27                                                      name="packageStatic"  
     26        <taskdef classname="build.packageStatic" 
     27                                                     name="packageStatic" 
    2828                                                         classpath="/${project.basedir}" 
    2929                                        /> 
    30         <taskdef classname="build.generateSchemaFile"  
    31                                              name="generateSchemaFile"  
     30        <taskdef classname="build.generateSchemaFile" 
     31                                             name="generateSchemaFile" 
    3232                                                 classpath="/${project.basedir}" 
    3333                                /> 
    34          
     34        <taskdef classname="build.importStyle" 
     35                                                     name="importStyle" 
     36                                                         classpath="/${project.basedir}" 
     37                                        /> 
     38 
    3539        <target name="schemafile"> 
    3640                <generateSchemaFile root="${project.basedir}" returnProperty="fileLocation" /> 
     
    4246        <target name="package"> 
    4347                <mkdir dir="${target_dir}"/> 
    44                 <packageMidCOM  
    45                         path="${project.basedir}"  
     48                <packageMidCOM 
     49                        path="${project.basedir}" 
    4650                        package="${package}" 
    4751                        target_dir="${target_dir}" 
    4852                        returnProperty="pear_name" 
    4953                > 
    50                          
     54 
    5155                </packageMidCOM> 
    5256                <echo>Package ${pear_name} created in ${target_dir}</echo> 
    5357        </target> 
    5458        <target name="package-all"> 
    55                 <makeProjectList path="${project.basedir}"  
     59                <makeProjectList path="${project.basedir}" 
    5660                                                 returnProperty="projects" /> 
    5761                <foreach list="${projects}" param="package" target="package"/> 
     
    6771        phing scaffold -Dmodule=com.example.mymodule 
    6872To generate a suggested schemafile to place in the midgard schemadirectory: 
    69         phing schemafile  
     73        phing schemafile 
    7074                        You can set install_dir, target_dir and other vars in build.properties. 
    7175Current settings: 
    7276install_dir = ${install_dir} // this is the dir that is linked to this checkout. 
    7377target_dir  = ${target_dir} // this is where pear packages are saved. 
    74                  
     78 
    7579                </echo> 
    7680        </target> 
     
    7882        <target name="install"> 
    7983                <mkdir dir="${install_dir}" /> 
    80                 <mkdir dir="${lib_dir}" />                      
     84                <mkdir dir="${lib_dir}" /> 
    8185                <mkdir dir="${static_dir}" /> 
    8286                <phingcall target="install_midcom"/> 
    8387                <phingcall target="install_static_packages" /> 
    84                 <makeProjectList path="${project.basedir}"  
     88                <makeProjectList path="${project.basedir}" 
    8589                                                 returnProperty="projects" /> 
    8690                <foreach list="${projects}" param="project" target="install_module_symlink"/> 
     
    101105                <resolvePath propertyName="static_path" file="${project.basedir}/../static"/> 
    102106                <resolvePath propertyName="template_path" file="${project.basedir}/../templates"/> 
    103                 <exec  
    104                         command="ln -s ${static_path}/stock-icons ${static_dir}/stock-icons "  
     107                <exec 
     108                        command="ln -s ${static_path}/stock-icons ${static_dir}/stock-icons " 
    105109                        dir="${project.basedir}/../static" /> 
    106                 <exec  
    107                         command="ln -s ${static_path}/Javascript_protoToolkit ${static_dir}/Javascript_protoToolkit"  
     110                <exec 
     111                        command="ln -s ${static_path}/Javascript_protoToolkit ${static_dir}/Javascript_protoToolkit" 
    108112                        dir="${project.basedir}/../static" /> 
    109                 <exec  
    110                         command="ln -s ${template_path}/* ${static_dir}/"  
     113                <exec 
     114                        command="ln -s ${template_path}/* ${static_dir}/" 
    111115                                dir="${template_path}" /> 
    112116        </target> 
    113117        <target name="install_midcom"> 
    114118                <mkdir dir="${lib_dir}/midcom" /> 
    115                 <installMidcomCore  install_dir="${lib_dir}"  
    116                                                 project_dir="${absolute_basedir}"  
    117                 static_dir="${static_dir}"  
     119                <installMidcomCore  install_dir="${lib_dir}" 
     120                                                project_dir="${absolute_basedir}" 
     121                static_dir="${static_dir}" 
    118122                /> 
    119123        </target> 
    120124        <target name="install_module_symlink"> 
    121                 <echo>Installing to ${install_dir} </echo>      
    122                 <installMidcomDir install_dir="${lib_dir}"  
     125                <echo>Installing to ${install_dir} </echo> 
     126                <installMidcomDir install_dir="${lib_dir}" 
    123127                                                project_dir="${absolute_basedir}" 
    124                                                 module="${project}"  
    125                                                 static_dir="${static_dir}"  
     128                                                module="${project}" 
     129                                                static_dir="${static_dir}" 
     130                                                schema_dir="${schema_dir}" 
    126131                                                umask="${install_umask}" /> 
    127132        </target> 
     
    137142 
    138143        </target> 
    139                  
     144 
    140145                <target name="resolve_module_to_dir" > 
    141                          
     146 
    142147                        <php function="str_replace" returnProperty="module_dir_basic"> 
    143148                                <param value="."/> 
     
    155160                                <param value="Y-M-D" /> 
    156161                        </php> 
    157                                  
    158                         <available  
    159                                 file="${basedir}/${module_dir}"  
    160                                 property="module_dir_exists"  
    161                                 value="yes"  
     162 
     163                        <available 
     164                                file="${basedir}/${module_dir}" 
     165                                property="module_dir_exists" 
     166                                value="yes" 
    162167                                type="dir" 
    163168                        /> 
    164169                        <property name="midcom_root" value="${project.basedir}" /> 
    165170                </target> 
    166                  
     171 
    167172                <target name="create_module" if="module_dir" unless="module_dir_exists"> 
    168173                        <mkdir dir="${module_dir}"/> 
     
    174179                        <mkdir dir="${module_dir}/locale" /> 
    175180                        <mkdir dir="${module_dir}/static" /> 
    176                          
    177                         <input propertyname="module_description"  
     181 
     182                        <input propertyname="module_description" 
    178183                                defaultValue="MidCOM module ${module}" 
    179184                                > 
    180185                                Enter module description: 
    181186                        </input> 
    182                          
     187 
    183188                        <copy todir="${module_dir}"> 
    184189                                 <filterchain> 
     
    191196                                </fileset> 
    192197                        </copy> 
    193                          
     198 
    194199                        <copy todir="${module_dir}/config"> 
    195200                                 <filterchain> 
     
    242247                        </copy> 
    243248                </target> 
    244          
     249 
    245250        <target name="package-static"> 
    246251                <mkdir dir="${target_dir}"/> 
    247252                <packageStatic 
    248                         path="${project.basedir}/../static/"  
     253                        path="${project.basedir}/../static/" 
    249254                        package="${package}" 
    250255                        target_dir="${target_dir}" 
     
    254259                <echo>Package ${pear_name} created in ${target_dir}</echo> 
    255260        </target> 
     261 
     262        <target name="import_style" > 
     263                <fail unless="style" 
     264                        message="You must set a template to upload. -Dstyle=[templatename]" /> 
     265                <resolvepath propertyName="template_dir" file="${project.basedir}/../templates"/> 
     266                <importStyle template="${style}" 
     267                                         path="${template_dir}" 
     268 
     269                /> 
     270    </target> 
     271 
    256272</project> 
    257          
     273 
  • trunk/src/build/installMidcomDir.php

    r3772 r4824  
    66 * @copyright The Midgard Project, http://www.midgard-project.org 
    77 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License 
    8  *  
     8 * 
    99 * Creates the module directory based on the path and module name 
    10  *  
     10 * 
    1111 */ 
    12   
     12 
    1313require_once "phing/Task.php"; 
    1414 
     
    2424     */ 
    2525    protected $install_dir = "/tmp"; 
    26      
     26 
    2727    public function setInstall_dir($str) { 
    2828        $this->install_dir = $str; 
     
    3232     */ 
    3333    protected $project_dir = null; 
    34      
     34 
    3535    public function setProject_dir($str) { 
    3636        $this->project_dir = $str; 
     
    4747        $this->umask = $str; 
    4848    } 
    49      
     49 
    5050    public function setModule($str) { 
    5151        $this->module = $str; 
    5252    } 
    53  
     53        protected $schema_dir = ""; 
     54        public function setSchema_dir($str) { 
     55                $this->schema_dir = $str; 
     56        } 
    5457    /** 
    5558     * The init method: Do init steps. 
     
    6063 
    6164    /** 
    62      * Create the projectdir and then make a symlink into the structure.  
     65     * Create the projectdir and then make a symlink into the structure. 
    6366     */ 
    6467    public function main() { 
     
    7073        $module_path = $this->install_dir . "/" . implode('/',$dirs); 
    7174        //echo "module_path: " .  $module_path . "\n"; 
    72          
     75 
    7376        if (!file_exists($module_path) && !mkdir ($module_path,0777, true)) { 
    7477            echo "Failed to create directory {$module_path}\n"; 
     
    7780        $from = "{$this->project_dir}/{$this->module}"; 
    7881        $this->make_symlink($from,$link); 
    79          
     82 
    8083        $static = sprintf("%s/%s/static", $this->project_dir, $this->module); 
    8184        $link   = sprintf("%s/%s",$this->static_dir, $this->module ); 
    8285        if (is_dir($static)) { 
    83             $this->make_symlink($static, $link );             
     86            $this->make_symlink($static, $link ); 
    8487        } 
    85          
     88 
     89        $schema = sprintf("%s/%s/config/mgdschema.xml", $this->project_dir, $this->module); 
     90        if (file_exists($schema)) 
     91        { 
     92                echo "Symlinking schema {$schema} to " . $this->schema_dir . "/" . $this->module . ".xml"; 
     93                $this->make_symlink($schema, $this->schema_dir . "/" . $this->module . ".xml"); 
     94        } 
     95 
    8696    } 
    87      
     97 
    8898    /** 
    8999     * Creates a symlink to the file or directory 
     
    92102    private function make_symlink($from , $link, $debug = false) 
    93103    { 
    94         if (is_link($link))  
     104        if (is_link($link)) 
    95105        { 
    96106            return; 
    97         }    
     107        } 
    98108        $command = sprintf("ln -s %s %s", $from, $link); 
    99109        $this->exec_command($command, $debug); 
    100110    } 
    101          
     111 
    102112    /** 
    103113     * Executes a given command. 
     
    105115     * @throws exception 
    106116     * @param string $command the command to be executed 
    107      * @param boolean $debug set to true if you want to just se the  
     117     * @param boolean $debug set to true if you want to just se the 
    108118     * command to be executed. 
    109119     */ 
     
    119129            throw new Exception("Exec of $command returned non zero code $ret"); 
    120130        } 
    121          
     131 
    122132    } 
    123133}