Using Ant, Fail if does not start with a particlar string without ant-contrib -


i new ant scripting , version 1.6.5 on suse linux 11, can please in achieving below

       <fileset dir="${target.location}" includes  = "${file.list}"/> 

here target.location directory passed input property file user. need write validation make sure directory location should start /properties.

the user can pass /properties// , starting string should "/properties" or else throw error user , exit, cannot use ant-contrib because adding libraries existing ant should go through lot of approval process.

you can use javascript implement custom script condition check. support javascript comes jvm doesn't require additional jars:

<project name="demo" default="check">    <property name="target.location" value="/properties/some/path"/>    <condition property="found.prefix">     <scriptcondition language="javascript">       self.setvalue(string(project.getproperty("target.location")).indexof("/properties")==0)     </scriptcondition>   </condition>    <target name="check">     <fail message="target.location must prefixed '/properties'" unless="found.prefix"/>   </target>  </project> 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -