Changeset 32340 for main/trunk
- Timestamp:
- 2018-08-14T20:38:17+12:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/build.xml
r32339 r32340 102 102 </if> 103 103 104 <!-- Use macrodef task from ant 1.6+ to define a macro https://ant.apache.org/manual/Tasks/macrodef.html -->105 <macrodef name="propertycopy">106 <attribute name="name"/>107 <attribute name="from"/>108 <sequential>109 <property name="@{name}" value="${@{from}}"/>110 </sequential>111 </macrodef>112 104 113 105 <!-- If internal.tomcat.port not yet set, work it out based on server.protocol … … 153 145 </if> 154 146 147 <!-- 148 1. Using the macrodef task from ant 1.6+ (https://ant.apache.org/manual/Tasks/macrodef.html) 149 to define "propertycopy" macro that then allows us to use nested variables in build.xml 150 (Is there any way to use nested variables in build.properties?) 151 Defining the propertycopy macro: 152 http://ant.apache.org/faq.html#propertyvalue-as-name-for-property 153 --> 154 <macrodef name="propertycopy"> 155 <attribute name="name"/> 156 <attribute name="from"/> 157 <sequential> 158 <property name="@{name}" value="${@{from}}"/> 159 </sequential> 160 </macrodef> 155 161 <!-- 156 Now use the macro to use a propertyvalue (server.protocol) as a part of the name for a property 162 2. Now can use the 'propertycopy' macro defined above to allow us to use a property's value 163 (e.g. server.protocol's value) as a part of the name for a property. 157 164 So we want do something like ${tomcat.port.${server.protocol}}, which, if server.protocol=http, 158 we want it to turn into tomcat.port.http. Then we want to use the constructed variable name 159 to assign its value to a new variable. Use as follows: 160 propertycopy name="tomcat.port.protocol" from="tomcat.port.${server.protocol}" 161 http://ant.apache.org/faq.html#propertyvalue-as-name-for-property 165 we'd like it to turn into tomcat.port.http. Then we want to use the constructed variable name 166 to assign its value to a new variable. Use is as follows: 167 propertycopy name="tomcat.port.protocol" from="tomcat.port.${server.protocol}" 162 168 http://ant.1045680.n5.nabble.com/Property-expansion-in-macrodef-attributes-td5476406.html 163 169 --> 164 170 <propertycopy name="internal.tomcat.port" from="tomcat.port.${server.protocol}"/> 165 171 <if> 166 <bool><matches string="${internal.tomcat.port}" pattern="tomcat "/></bool>172 <bool><matches string="${internal.tomcat.port}" pattern="tomcat\.port"/></bool> 167 173 <fail>... 168 174 ********* ERROR: Unable to set tomcat.port: … … 170 176 matching tomcat.port.${server.protocol} property line is enabled and set to a valid port number.</fail> 171 177 </if> 172 173 <echo>### PORT PROTOCOL: ${internal.tomcat.port}</echo>174 175 178 176 179 <!-- If we got here, we got a valid tomcat port. Set tomcat.port in build.properties … … 183 186 even though we can write it back out again to build.properties. 184 187 --> 188 <echo>Using tomcat port: ${internal.tomcat.port}</echo> 185 189 <propertyfile file="build.properties"> 186 190 <entry key="tomcat.port" value="${internal.tomcat.port}"/>
Note:
See TracChangeset
for help on using the changeset viewer.