o instead of Ant conditions to test socket connections and http connections, use Jelly so that properties can be reset each time init is called.
Issue ID: MPAPPSERVER-7 git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@115051 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a32396668d
commit
e44ef24ca6
@ -284,25 +284,53 @@
|
||||
|
||||
<!-- a flag to see if the appserver is started -->
|
||||
<j:remove var="maven.appserver.started" />
|
||||
<ant:condition property="maven.appserver.started">
|
||||
<ant:and>
|
||||
<ant:socket server="${maven.appserver.host}"
|
||||
port="${maven.appserver.test.socket}" />
|
||||
<!-- only use the test url if defined, else just use the socket -->
|
||||
<j:if test="${context.getVariable('maven.appserver.test.url') != null}">
|
||||
<ant:http url="${maven.appserver.test.url}" />
|
||||
<j:remove var="failedSocket" />
|
||||
<j:set var="canHttpConnect" value="true" /><!-- default -->
|
||||
<j:if test="${context.getVariable('maven.appserver.test.url') != null}">
|
||||
<!-- override default true above because test url is optional -->
|
||||
<j:set var="canHttpConnect" value="false" />
|
||||
<!-- test url connection -->
|
||||
<j:catch var="httpConnectException" >
|
||||
<j:new className="java.net.URL" var="testURL" >
|
||||
<j:arg type="java.lang.String"
|
||||
value="${context.getVariable('maven.appserver.test.url')}" />
|
||||
</j:new>
|
||||
<j:invoke on="${testURL}" method="openConnection" var="testConnection"/>
|
||||
<j:invoke on="${testConnection}" method="getResponseCode" var="testResponse" />
|
||||
<j:if test="${testResponse gt 0 and testResponse lt 400}">
|
||||
<j:set var="canHttpConnect" value="true" />
|
||||
</j:if>
|
||||
</ant:and>
|
||||
</ant:condition>
|
||||
</j:catch>
|
||||
<j:if test="${httpConnectException.getCause().getCause().toString().indexOf('MalformedURLException') ge 0}">
|
||||
<exception:appserverTestURLInvalid
|
||||
propname="maven.appserver.test.url"
|
||||
propvalue="${context.getVariable('maven.appserver.test.url')}"
|
||||
cause="${httpConnectException}"/>
|
||||
</j:if>
|
||||
<!-- clean up the objects to prevent leak in long sessions -->
|
||||
<j:remove var="testURL" />
|
||||
<j:remove var="testConnection" />
|
||||
<j:remove var="testResponse" />
|
||||
</j:if>
|
||||
<!-- always test socket -->
|
||||
<j:catch var="failedSocket">
|
||||
<j:new className="java.net.Socket" var="dummy">
|
||||
<j:arg type="java.lang.String"
|
||||
value="${context.getVariable('maven.appserver.host')}" />
|
||||
<j:arg type="int"
|
||||
value="${context.getVariable('maven.appserver.test.socket')}" />
|
||||
</j:new>
|
||||
</j:catch>
|
||||
<j:if test="${failedSocket.getCause() == null and canHttpConnect == 'true'}">
|
||||
<j:set var="maven.appserver.started" value="true" />
|
||||
</j:if>
|
||||
|
||||
<!-- a flag to see if the appserver is installed -->
|
||||
<j:remove var="maven.appserver.installed" />
|
||||
<ant:condition property="maven.appserver.installed">
|
||||
<ant:and>
|
||||
<ant:available file="${maven.appserver.root}" type="dir" />
|
||||
<ant:available file="${maven.appserver.dir}" type="dir" />
|
||||
</ant:and>
|
||||
</ant:condition>
|
||||
<util:available file="${maven.appserver.root}" >
|
||||
<util:available file="${maven.appserver.dir}" >
|
||||
<j:set var="maven.appserver.installed" value="true" />
|
||||
</util:available>
|
||||
</util:available>
|
||||
|
||||
<j:if test="${context.getVariable('maven.appserver.started') == 'true' and context.getVariable('maven.appserver.installed') == 'true'}">
|
||||
<j:set var="maven.appserver.installedAndStarted" value="true" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user