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
Post a Comment