{"id":1815,"date":"2011-01-21T11:50:57","date_gmt":"2011-01-21T16:50:57","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=1815"},"modified":"2011-02-14T20:49:00","modified_gmt":"2011-02-15T01:49:00","slug":"ant","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=1815","title":{"rendered":"Ant Tips"},"content":{"rendered":"<span id=\"Import_Property_File\"><h3>Import Property File<\/h3><\/span>\n<p>* Import property file.<\/p>\n<pre lang=\"xml\">\r\n<project name=\"testproj\" default=\"init\">\r\n  <dirname property=\"testproj.dir\" file=\"${ant.file.testproj}\"\/>\r\n  <property file=\"${testproj.dir}\/build.properties\"\/>\r\n<\/pre>\n<p>* <a href=\"http:\/\/www.mail-archive.com\/ant-user@jakarta.apache.org\/msg04966.html\">Here <\/a>is good discussion on how to use multiple lines in property files. Basically, you use &#8216;\\n\\&#8217; in property files to separate lines.<\/p>\n<pre>\r\nmultiline=\\nThis is a \\n\\\r\nmultiple \\n\\\r\nline text.\r\n<\/pre>\n<span id=\"Import_Another_Build_File\"><h3>Import Another Build File<\/h3><\/span>\n<p>* You can import another build file and directly call targets contained within the imported file.<\/p>\n<pre lang=\"xml\">\r\n<import file=\"build_misc.xml\"\/>\r\n<\/pre>\n<span id=\"Escape_Characters\"><h3>Escape Characters<\/h3><\/span>\n<p>Use the dollar sign to escape characters.<\/p>\n<pre lang=\"xml\">\r\n        <echo>$${my.zip.file}: ${goldengate.zip.file}<\/echo>\r\n<\/pre>\n<span id=\"Check_for_OS\"><h3>Check for OS<\/h3><\/span>\n<pre lang=\"xml\">\r\n<condition property=\"is.win\">\r\n  <os family=\"windows\"\/>\r\n<\/condition>\r\n\r\n<condition property=\"is.unix\">\r\n  <os family=\"unix\"\/>\r\n<\/condition>\r\n  \r\n<target name=\"do.something\" depends=\"do.win, do.unix\"\/>\r\n\r\n<target name=\"do.win\" if=\"is.win\">\r\n  <echo message=\"This is Windows.\"\/>\r\n<\/target>\r\n\r\n<target name=\"do.unix\" if=\"is.unix\">\r\n  <echo message=\"This is Unix.\"\/>\r\n<\/target>\r\n\r\n<\/pre>\n<span id=\"Find_Hostname\"><h3>Find Hostname<\/h3><\/span>\n<pre lang=\"xml\">\r\n<property environment=\"env\"\/>\r\n<exec executable=\"hostname\" \r\n    os=\"SunOS\" <!-- use osfamily after Ant 1.7 -->\r\n    failifexecutionfails=\"false\" \r\n    outputproperty=\"env.COMPUTERNAME\"\/>\r\n<property name=\"deploy.to\" value=\"${env.COMPUTERNAME}\"\/>\r\n<\/pre>\n<span id=\"Import\"><h3>Import<\/h3><\/span>\n<p>* Child build file to be imported:<\/p>\n<pre lang=\"xml\">\r\n<project name=\"childbuild\" default=\"childtarget\">\r\n  <dirname property=\"childbuild.dir\" file=\"${ant.file.childbuild}\"\/>\r\n  <property file=\"${childbuild.dir}\/childbuild.properties\"\/>\r\n  <target name=\"childtarget\">\r\n    <echo>\r\n$${ant.project.name}: ${ant.project.name}\r\n$${ant.file.childbuild}: ${ant.file.childbuild}\r\n$${prop1}: ${prop1}\r\n$${prop2}: ${prop2}\r\n    <\/echo>\r\n  <\/target>\r\n<\/project><\/pre>\n<p>* Property file to be imported into child build file:<\/p>\n<pre lang=\"xml\">\r\nprop1=ThisIsPropertyOne\r\nprop2=ThisIsPropertyTwo<\/pre>\n<p>* Main build file overriding child target:<\/p>\n<pre lang=\"xml\">\r\nproject name=\"mainbuild\" default=\"childtarget\">\r\n  <import file=\"childbuild.xml\"\/>\r\n  <target name=\"childtarget\"\r\n    depends=\"childbuild.childtarget\">\r\n    <echo>\r\nOverriding childtarget.\r\n$${prop1}: ${prop1}\r\n$${prop2}: ${prop2}\r\n    <\/echo>\r\n  <\/target>\r\n<\/project><\/pre>\n<p>* Call child target from main build file:<\/p>\n<pre lang=\"xml\">\r\nC:\\TestAnt\\ant childtarget\r\n\r\nBuildfile: build.xml\r\n\r\nchildbuild.childtarget:\r\n     [echo]\r\n     [echo] ${ant.project.name}: mainbuild\r\n     [echo] ${ant.file.childbuild}: C:\\TestAnt\\childbuild.xml\r\n     [echo] ${prop1}: ThisIsPropertyOne\r\n     [echo] ${prop2}: ThisIsPropertyTwo\r\n     [echo]\r\n\r\nchildtarget:\r\n     [echo]\r\n     [echo] Overriding childtarget.\r\n     [echo] ${prop1}: ThisIsPropertyOne\r\n     [echo] ${prop2}: ThisIsPropertyTwo\r\n     [echo]\r\n\r\nBUILD SUCCESSFUL\r\nTotal time: 0 seconds<\/pre>\n<p>* List all targets<br \/>\nant -p list all targets<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Import Property File * Import property file. * Here is good discussion on how to use multiple lines in property files. Basically, you use &#8216;\\n\\&#8217; in property files to separate lines. multiline=\\nThis is a \\n\\ multiple \\n\\ line text. Import &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=1815\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[80],"tags":[],"class_list":["post-1815","post","type-post","status-publish","format-standard","hentry","category-ant"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/s8cRUO-ant","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1815","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1815"}],"version-history":[{"count":8,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1815\/revisions"}],"predecessor-version":[{"id":1927,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1815\/revisions\/1927"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}