Ramya
Ramya

Reputation: 103

how to check JBOSS version using ANT script

I have written ant script to check for java version. Similarly I would like to know how to check for JBOSS version using ant script.

  <project basedir="." default="check-java-version">
  <target name="get-java-version">
  <echo message="Java Version: ${java.version}"/> 
    <echo message="Java home: ${java.home}"/> 
    <fail message="Unsupported Java version: ${java.version}. Make sure that  
     the version of the Java compiler is 1.7 or greater."> 
        <condition> 
            <not> 
                <or> 
                    <contains string="${java.version}" substring="1.7" casesensitive="false" />                         
                     <contains string="${java.version}" substring="1.8" casesensitive="false" /> 
                </or>                       
            </not> 
        </condition> 
    </fail> 
  </target>
  <target name="check-java-version" depends="get-java-version"              
  unless="java.version">

   </target>
 </project>

Upvotes: 0

Views: 211

Answers (1)

Daniele
Daniele

Reputation: 1063

if you are trying to do this from the same box where jboss is installed you can try the exec task on "standalone.bat --version" or the "run.sh --version"

if you want to query a remote JBOSS instance you can execute curl against http://yourserver:port/jmx-console/HtmlAdaptor?action=inspectMBean&name=jboss.system%3Atype%3DServer

you can also check: What version of JBoss I am running? for how to derive it from the jar.

-- Adding a sample on how to implement this in Ant:

<exec dir="${yourJbossDir}" executable="run.sh" outputproperty="JbossVersion">
   <arg line="--version"/>
</exec>

then you would get the vesrsion stored in the JbossVersion property. see also: https://ant.apache.org/manual/Tasks/exec.html

Upvotes: 1

Related Questions