Changeset 32339
- Timestamp:
- 2018-08-14T20:16:08+12:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/build.xml
r32338 r32339 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> 104 112 105 113 <!-- If internal.tomcat.port not yet set, work it out based on server.protocol … … 107 115 https://grokbase.com/t/ant/user/04698xjbp3/nested-variables-in-ant 108 116 http://ant.apache.org/faq.html#propertyvalue-as-name-for-property 109 https://marc.info/?l=ant-user&m=111231719328847 110 http://ant-contrib.sourceforge.net/tasks/tasks/propertycopy.html 111 http://www.jguru.com/faq/view.jsp?EID=1072238 112 * propfile: 113 https://ant.apache.org/manual/Tasks/propertyfile.html 114 * valid ports range from 1024â49151 115 https://stackoverflow.com/questions/113224/what-is-the-largest-tcp-ip-network-port-number-allowable-for-ipv4 116 --> 117 118 <!-- If internal.tomcat.port not yet set, work it out based on server.protocol 119 Would be great if we could just use nested variables in build.properties 120 https://grokbase.com/t/ant/user/04698xjbp3/nested-variables-in-ant 121 http://ant.apache.org/faq.html#propertyvalue-as-name-for-property 117 http://ant.1045680.n5.nabble.com/Property-expansion-in-macrodef-attributes-td5476406.html 118 122 119 https://marc.info/?l=ant-user&m=111231719328847 123 120 http://ant-contrib.sourceforge.net/tasks/tasks/propertycopy.html … … 130 127 <if> 131 128 <bool> 132 <not> 133 <or> 134 <and> 135 <equals arg1="${server.protocol}" arg2="http" trim="true" casesensitive="false" forcestring="true"/> 136 <isset property="tomcat.port.http"/> 137 <matches string="${tomcat.port.http}" pattern="^\d{3,4}\s*$"/> 138 </and> 139 <and> 140 <equals arg1="${server.protocol}" arg2="https" trim="true" casesensitive="false" forcestring="true"/> 141 <isset property="tomcat.port.https"/> 142 <matches string="${tomcat.port.https}" pattern="^\d{3,4}\s*$"/> 143 </and> 144 </or> 145 </not> 129 <and> 130 <isset property="tomcat.port.http"/> 131 <not><matches string="${tomcat.port.http}" pattern="^\d{3,4}\s*$"/></not> 132 </and> 146 133 </bool> 147 <fail>ERROR: Unable to set tomcat.port. 148 In file build.properties server.protocol=${server.protocol} and requires at minimum that its 149 matching tomcat.port.${server.protocol} property line be set and is assigned a valid port number. 150 (Ensure any other enabled tomcat port is valid too)</fail> 151 <else> 152 <condition property="internal.tomcat.port" value="${tomcat.port.https}" else="${tomcat.port.http}"> 153 <equals arg1="${server.protocol}" arg2="https" trim="true" casesensitive="false" forcestring="true"/> 154 </condition> 155 <echo>### tomcat.port.http: ${tomcat.port.http}</echo> 156 </else> 157 </if> 158 159 <!-- Set autogenerated properties (properties we calculate here in build.xml) 134 <fail>... 135 ********* ERROR: tomcat.port.http in file build.properties is set to an invalid port number. 136 Valid ports range from 1024â49151. But don't choose any port already in use by another application. 137 Try setting to tomcat.port.http=8383 138 </fail> 139 </if> 140 141 <if> 142 <bool> 143 <and> 144 <isset property="tomcat.port.https"/> 145 <not><matches string="${tomcat.port.https}" pattern="^\d{3,4}\s*$"/></not> 146 </and> 147 </bool> 148 <fail>... 149 ********* ERROR: tomcat.port.https in file build.properties is set to an invalid port number. 150 Valid ports range from 1024â49151. But don't choose any port already in use by another application. 151 Try setting tomcat.port.https=8443 152 </fail> 153 </if> 154 155 <!-- 156 Now use the macro to use a propertyvalue (server.protocol) as a part of the name for a property 157 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 162 http://ant.1045680.n5.nabble.com/Property-expansion-in-macrodef-attributes-td5476406.html 163 --> 164 <propertycopy name="internal.tomcat.port" from="tomcat.port.${server.protocol}"/> 165 <if> 166 <bool><matches string="${internal.tomcat.port}" pattern="tomcat"/></bool> 167 <fail>... 168 ********* ERROR: Unable to set tomcat.port: 169 In file build.properties server.protocol=${server.protocol} and requires at minimum that its 170 matching tomcat.port.${server.protocol} property line is enabled and set to a valid port number.</fail> 171 </if> 172 173 <echo>### PORT PROTOCOL: ${internal.tomcat.port}</echo> 174 175 176 <!-- If we got here, we got a valid tomcat port. Set tomcat.port in build.properties 177 Set autogenerated properties (properties we calculate here in build.xml) 160 178 in build.properties. https://ant.apache.org/manual/Tasks/propertyfile.html 161 179 For now only internal.tomcat.port is determined by build.xml … … 165 183 even though we can write it back out again to build.properties. 166 184 --> 167 <if> 168 <bool><isset property="internal.tomcat.port"/></bool> 169 <propertyfile file="build.properties"> 170 <entry key="tomcat.port" value="${internal.tomcat.port}"/> 171 </propertyfile> 172 </if> 185 <propertyfile file="build.properties"> 186 <entry key="tomcat.port" value="${internal.tomcat.port}"/> 187 </propertyfile> 188 173 189 174 190 <!-- now we've read in properties, apply defaults -->
Note:
See TracChangeset
for help on using the changeset viewer.