String substitution error

Comments

2 comments

  • Avatar
    juanjo

    The substitute action is not recursive. To make it work recursively, you should place the action in the folder containing the files to modify. For example, if you are packing the 'test' directory in a folder named test_folder:

              <folder>
                 <name>test_folder</name>
                 <destination>${installdir}/</destination>
                 <distributionFileList>
                     <distributionDirectory origin="/home/johndoe/test"/>
                 </distributionFileList>
                 <actionList>
                   <substitute>
                        <customErrorMessage>Error with string substitution</customErrorMessage>
                        <files>*/test/*</files>
                        <type>exact</type>
                        <substitutionList>
                                <substitution>
                                    <pattern>@LOCAL_PORT@</pattern>
                                    <value>11112</value>
                                </substitution>
                         </substitutionList>
                   </substitute>
                 </actionList>
              </folder>
    

    Regarding the <type> tag, you are right, it refers to the type of pattern.

  • Avatar
    juanjo

    The <folder> must be defined in the component's folderList, and it will require to pack the files at build time (it uses the list of packed files so it is easier than checking the filesystem for the files matching the patterns). In your case, the installer should be probably failing because the action is trying to apply the substitution to directories. You could try the below code, which does not rely on using a folder:

    <substitute> 
      <customErrorMessage>Error with string substitution</customErrorMessage> 
      <files>${installdir}/test/{*,*/*,*/*/*,*/*/*/*,*/*/*/*/*}{.xml,.sql}</files> 
      <type>exact</type>
      <substitutionList> 
         <substitution> 
           <pattern>@LOCAL_PORT@</pattern> 
           <value>11112</value>
         </substitution> 
      </substitutionList> 
    </substitute>
    

Please sign in to leave a comment.