Hello,

I'm trying to test the string substitution capabilities and keep getting an error.

Here is my substitute XML:

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

I'd like to recursively search all files in ${installdir}\test I've tried multiple variations on this, but I continually get an error. Is there any logging or debugging available to get more info on what is causing the error?

Also, I'd like to be able to search all sub directories for specific file types. For example, recursively search ${installdir}\test\ for all files that end in .xml or in .sql. What syntax can I use in the <files></files> to do that?

Just to make sure I'm understanding things correctly. I'm assuming that <type>exact</type> is the type for the <pattern> search, not for the <files> search. Is that correct?

Thanks!

asked 04 Jun '12, 14:24

courtenayt's gravatar image

courtenayt
1222
accept rate: 0%


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.

link

answered 04 Jun '12, 15:31

juanjo's gravatar image

juanjo ♦♦
5.8k413
accept rate: 23%

Can you explain more about how folders work? Do they have to be defined where files are pulled & packaged with the installer, or is there a way to use them later in the process?

E.g. in my installer I download and extract a directory in the Post-installation Action section. The files I need do substitution on are a sub-directory of the unzipped directory. I tried adding a "folder" code in the Post-installation section, but the xml validator tells me it's not allowed. Do I need to add the "folder" code within some other component in that section?

Thank you for your help!

(11 Jun '12, 17:52) courtenayt

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>
link

answered 12 Jun '12, 05:15

juanjo's gravatar image

juanjo ♦♦
5.8k413
accept rate: 23%

Thank you again! That looks really helpful!

Is there a documentation page for how you came up with how to list which files you are searching?

From what I can tell the <files>${installdir}/test/{*,*/*,*/*/*,*/*/*/*,*/*/*/*/*}{.xml,.sql}</files> section says to search the directory ${installdir}/test/ directory up to several levels deep for any file ending in .xml or .sql, is that correct?

I'd also like to add several files to specifically exclude from the list, but wasn't sure of the syntax for that.

(12 Jun '12, 10:39) courtenayt
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×29
×13
×10
×3

Asked: 04 Jun '12, 14:24

Seen: 1,945 times

Last updated: 12 Jun '12, 10:39